-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathscreamer.spec.js
78 lines (68 loc) · 2.62 KB
/
screamer.spec.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// API stuff
describe("Support:", function() {
it("should verify if browser supports Notification API", function(){
expect(Screamer.verifySupport()).toBeTruthy();
});
});
describe('Permissions:', function() {
it("should checkPermission and it's granted", function(){
expect(Screamer.checkPermission('granted')).toBeTruthy();
});
it("should checkPermission and it's denied", function(){
expect(Screamer.checkPermission('denied')).toBeFalsy();
});
});
// Plugin stuff
describe('Instantiation:', function() {
it("should instantiate the Screamer object", function() {
screamObj = new Screamer({'title': 'hello'});
expect(screamObj instanceof window.Screamer).toBeTruthy();
});
it("should instantiate the Screamer object even without new operator", function() {
screamObj = Screamer({'title': 'hello without new'});
expect(screamObj instanceof window.Screamer).toBeTruthy();
});
it('should call notify without param and throw an error', function() {
expect(function(){
screamError = new Screamer();
}).toThrow();
});
it('should call notify with title different than string and throw an error', function() {
expect(function(){
screamError = new Screamer({'title': 123});
}).toThrow();
});
});
// test parameters
describe('Parameters:', function() {
it("should instantiate the Screamer object with title and verify title", function() {
screamObj = new Screamer({'title': 'Hello'});
expect(screamObj.options.title).toEqual('Hello');
});
it("should instantiate the Screamer object with title with quotes and accents", function() {
screamObj = new Screamer({'title': 'A matéria "teste" foi publicada.'});
expect(screamObj.options.title).toEqual('A matéria "teste" foi publicada.');
});
it("should instantiate the Screamer object with many options and wait same options", function() {
options = {
'title': 'hello',
'body': 'world',
'icon': '../example/ico_sucesso.png'
};
screamObj = new Screamer(options);
expect(screamObj.options).toEqual(options);
});
it("should instantiate the Screamer object with many options including before and after and wait same options", function() {
options = {
title: 'hello',
before: function() {
console.log('init');
},
after: function() {
console.log('finished');
}
};
screamObj = new Screamer(options);
expect(screamObj.options).toEqual(options);
});
});