forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi-dialog-spec.js
112 lines (90 loc) · 3.26 KB
/
api-dialog-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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const { expect } = require('chai')
const { dialog } = require('electron').remote
describe('dialog module', () => {
describe('showOpenDialog', () => {
it('throws errors when the options are invalid', () => {
expect(() => {
dialog.showOpenDialog({ properties: false })
}).to.throw(/Properties must be an array/)
expect(() => {
dialog.showOpenDialog({ title: 300 })
}).to.throw(/Title must be a string/)
expect(() => {
dialog.showOpenDialog({ buttonLabel: [] })
}).to.throw(/Button label must be a string/)
expect(() => {
dialog.showOpenDialog({ defaultPath: {} })
}).to.throw(/Default path must be a string/)
expect(() => {
dialog.showOpenDialog({ message: {} })
}).to.throw(/Message must be a string/)
})
})
describe('showSaveDialog', () => {
it('throws errors when the options are invalid', () => {
expect(() => {
dialog.showSaveDialog({ title: 300 })
}).to.throw(/Title must be a string/)
expect(() => {
dialog.showSaveDialog({ buttonLabel: [] })
}).to.throw(/Button label must be a string/)
expect(() => {
dialog.showSaveDialog({ defaultPath: {} })
}).to.throw(/Default path must be a string/)
expect(() => {
dialog.showSaveDialog({ message: {} })
}).to.throw(/Message must be a string/)
expect(() => {
dialog.showSaveDialog({ nameFieldLabel: {} })
}).to.throw(/Name field label must be a string/)
})
})
describe('showMessageBox', () => {
it('throws errors when the options are invalid', () => {
expect(() => {
dialog.showMessageBox(undefined, { type: 'not-a-valid-type' })
}).to.throw(/Invalid message box type/)
expect(() => {
dialog.showMessageBox(null, { buttons: false })
}).to.throw(/Buttons must be an array/)
expect(() => {
dialog.showMessageBox({ title: 300 })
}).to.throw(/Title must be a string/)
expect(() => {
dialog.showMessageBox({ message: [] })
}).to.throw(/Message must be a string/)
expect(() => {
dialog.showMessageBox({ detail: 3.14 })
}).to.throw(/Detail must be a string/)
expect(() => {
dialog.showMessageBox({ checkboxLabel: false })
}).to.throw(/checkboxLabel must be a string/)
})
})
describe('showErrorBox', () => {
it('throws errors when the options are invalid', () => {
expect(() => {
dialog.showErrorBox()
}).to.throw(/Insufficient number of arguments/)
expect(() => {
dialog.showErrorBox(3, 'four')
}).to.throw(/Error processing argument at index 0/)
expect(() => {
dialog.showErrorBox('three', 4)
}).to.throw(/Error processing argument at index 1/)
})
})
describe('showCertificateTrustDialog', () => {
it('throws errors when the options are invalid', () => {
expect(() => {
dialog.showCertificateTrustDialog()
}).to.throw(/options must be an object/)
expect(() => {
dialog.showCertificateTrustDialog({})
}).to.throw(/certificate must be an object/)
expect(() => {
dialog.showCertificateTrustDialog({ certificate: {}, message: false })
}).to.throw(/message must be a string/)
})
})
})