This repository has been archived by the owner on Jan 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Notification.spec.js
49 lines (35 loc) · 1.71 KB
/
Notification.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
describe("Notification", function() {
var Notification = window.Notification;
it('Should be an Object', function() {
expect(Notification instanceof Object).toBe(true);
});
it('Should be a function', function() {
expect(typeof Notification).toBe('function');
});
it('Permission Property', function() {
expect(typeof Notification.permission).toBeDefined();
expect(typeof Notification.permission).toBe('string');
});
it('RequestPermission method', function() {
var permission = Notification.permission;
var requestPermission = Notification.requestPermission();
expect(typeof Notification.requestPermission).toBeDefined();
expect(typeof Notification.requestPermission).toBe('function');
expect(Notification.requestPermission() instanceof Promise).toBe(true);
});
it('Instance creation', function() {
// Test notification with no params.
expect(function() {return new Notification}).toThrowError();
// Test notification with params which is not an object
expect(function() {return new Notification('', '')}).toThrowError();
// If title is null/undefined - it should be displayed as null/undefined
expect((new Notification(null)).title).toBe('null');
expect((new Notification(undefined)).title).toBe('undefined');
});
it('Test dir param', function() {
// Test incorrect dir option
expect(function() {return new Notification('', {'dir': 'a'})}).toThrowError();
expect(function() {return new Notification('', {'dir': 'undefined'})}).toThrowError();
expect(function() {return new Notification('', {'dir': null})}).toThrowError();
});
});