forked from marcorinck/angular-growl
-
Notifications
You must be signed in to change notification settings - Fork 97
/
growlFactoryTests.js
63 lines (50 loc) · 1.82 KB
/
growlFactoryTests.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
51
52
53
54
55
56
57
58
59
60
61
62
63
describe("growlFactory Spec", function() {
"use strict";
var growlFactory,
growlMessages;
beforeEach(module('angular-growl'));
beforeEach(inject(['growl', 'growlMessages', function (gf, gm) {
growlFactory = gf;
growlMessages = gm;
}]));
/// TESTS
it('Should be defined', function () {
expect(growlFactory).toBeDefined();
expect(growlMessages).toBeDefined();
});
it('Should set proper values on default message types', function () {
var builtinTypes = [
'info',
'error',
'warning',
'success'
];
var severity;
var sampleText = 'text';
for (var i = 0; i < builtinTypes.length; i++) {
severity = builtinTypes[i];
expect(growlFactory[severity]).toBeDefined();
var msg = growlFactory.general(sampleText, null, severity);
expect(msg).toBeDefined();
expect(msg.text.toString()).toEqual(sampleText);
expect(msg.referenceId).toEqual(0);
expect(msg.position).toEqual('top-right');
expect(msg.severity).toEqual(severity);
}
});
it('Should add and remove 1 message', function () {
var msg = growlFactory.info('text');
expect(growlMessages.getAllMessages().length).toEqual(1);
msg.destroy();
expect(growlMessages.getAllMessages().length).toEqual(0);
});
it('Should be able to destroy all messages', function () {
var messageCount = 10;
for (var i = 0; i < messageCount; i++) {
growlFactory.info('Test ' + i);
}
expect(growlMessages.getAllMessages().length).toEqual(messageCount);
growlMessages.destroyAllMessages();
expect(growlMessages.getAllMessages().length).toEqual(0);
});
});