-
Notifications
You must be signed in to change notification settings - Fork 15
/
tests.js
84 lines (80 loc) · 2.42 KB
/
tests.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
79
80
81
82
83
84
'use strict';
const defineAutoTests = () => {
describe('WiFiManager (window.wifiManager)', () => {
it('should exist', () => {
expect(window.wifiManager).toBeDefined();
});
it('should contain a connect function', () => {
expect(window.wifiManager.connect).toBeDefined();
expect(typeof window.wifiManager.connect === 'function').toBe(true);
});
it('should contain a disconnect function', () => {
expect(window.wifiManager.disconnect).toBeDefined();
expect(typeof window.wifiManager.disconnect === 'function').toBe(true);
});
});
describe('connect method', () => {
it('should throw with no arguments', () => {
expect(() => {
window.wifiManager.connect();
}).toThrow();
});
it('should throw if 1st argument is not string', () => {
expect(() => {
window.wifiManager.connect(
0,
'TARGET_PASSPHRASE',
() => {},
() => {}
);
}).toThrow();
});
it('should throw if 2nd argument is not string', () => {
expect(() => {
window.wifiManager.connect(
'TARGET_SSID',
1,
() => {},
() => {}
);
}).toThrow();
});
it('should throw if success callback is not function', () => {
expect(() => {
window.wifiManager.connect('TARGET_SSID', 'TARGET_PASSPHRASE', 'foo', () => {});
}).toThrow();
});
it('should throw if failure callback is not function', () => {
expect(() => {
window.wifiManager.connect('TARGET_SSID', 'TARGET_PASSPHRASE', () => {}, 'bar');
}).toThrow();
});
});
describe('disconnect method', () => {
it('should throw with no arguments', () => {
expect(() => {
window.wifiManager.disconnect();
}).toThrow();
});
it('should throw if 1st argument is not string', () => {
expect(() => {
window.wifiManager.disconnect(
undefined,
() => {},
() => {}
);
}).toThrow();
});
it('should throw if success callback is not function', () => {
expect(() => {
window.wifiManager.disconnect('TARGET_SSID', 'foo', () => {});
}).toThrow();
});
it('should throw if failure callback is not function', () => {
expect(() => {
window.wifiManager.disconnect('TARGET_SSID', () => {}, 'bar');
}).toThrow();
});
});
};
exports.defineAutoTests = defineAutoTests;