-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patherrorSpec.js
50 lines (38 loc) · 1.22 KB
/
errorSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function waitsForBootstrap() {
expect(angular.hasBootstrapped()).toBe(false);
waitsFor(angular.hasBootstrapped);
}
function resetAngularJs() {
var check = false;
window['angular'] = {
loader: angularjs_loader,
// The module does not need to do anything for angularjs loader.
module: function() {},
// Easy way to check if the app bootstrapped.
bootstrap: function() { check = true; },
hasBootstrapped: function() { return check; }
};
angularjs_loader_reset();
}
describe('error module', function() {
beforeEach(resetAngularJs);
it('should format error messages', function() {
expect(function() {
angularjs_loader_error(1, [2, 3], 'Hello {0} World {1}.');
}).toThrow('Hello 2 World 3.');
});
it('should allow you to set your own handler', function() {
var reported = false;
var id = 1;
var params = [2, 3];
angular.loader.config({
error: function(a, b) {
reported = true;
expect(a).toBe(id);
expect(b).toBe(params);
}
});
angularjs_loader_error(1, params);
expect(reported).toBe(true);
});
});