-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
module.test.js
100 lines (75 loc) · 3.29 KB
/
module.test.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
/* global jest, describe, beforeEach, afterEach, it, expect */
const EdgeLauncher = require('chromium-edge-launcher')
const {launchChrome} = require('./steps/serveExtension')
jest.mock('./steps/manifest-entries/watch/createUserDataDir')
describe('webpack-run-edge-extension', () => {
describe('webpack config', () => {
describe('serveExtension', () => {
let spy
beforeEach(() => {
spy = jest.spyOn(EdgeLauncher, 'launch')
})
afterEach(() => {
spy.mockRestore()
})
it('`extensionPath` config sets respective browser flag', async () => {
await launchChrome({
autoReload: false,
extensionPath: 'my/extension/path'
})
const { edgeFlags } = await EdgeLauncher.launch.mock.calls[0][0]
const flag = edgeFlags.find(flag => flag.startsWith('--load-extension'))
expect(flag.endsWith('my/extension/path')).toBe(true)
})
it(
'`browserFlags` config sets respective user-specified browser flags',
async () => {
await launchChrome({
browserFlags: ['--some-flag=flagvalue', '--another-flag=value2']
})
const { edgeFlags } = await EdgeLauncher.launch.mock.calls[0][0]
const flag1 = edgeFlags.find(flag => flag.startsWith('--some-flag'))
const flag2 = edgeFlags.find(flag => flag.startsWith('--another-flag'))
expect(flag1.endsWith('value')).toBe(true)
expect(flag2.endsWith('value2')).toBe(true)
}
)
it('`userDataDir` config sets respective browser flag', async () => {
await launchChrome({ userDataDir: 'my/profile/dir' })
const { userDataDir } = await EdgeLauncher.launch.mock.calls[0][0]
expect(userDataDir).toBe('my/profile/dir')
})
it('`startingUrl` config sets respective browser flag', async () => {
await launchChrome({ startingUrl: 'my/starting/url' })
const { startingUrl } = await EdgeLauncher.launch.mock.calls[0][0]
expect(startingUrl).toBe('my/starting/url')
})
it('`autoReload` config loads reload extesion by default', async () => {
await launchChrome()
const { edgeFlags } = await EdgeLauncher.launch.mock.calls[0][0]
const flag1 = edgeFlags.find(flag => flag.startsWith('--load-extension'))
expect(flag1.endsWith('extension,')).toBe(true)
})
it(
'`autoReload` config does not load reload extesion by default',
async () => {
await launchChrome({ autoReload: false })
const { edgeFlags } = await EdgeLauncher.launch.mock.calls[0][0]
const flag1 = edgeFlags.find(flag => flag.startsWith('--load-extension'))
expect(flag1.endsWith('extension')).not.toBe(true)
}
)
it(
'`autoReload` config loads both user extension and reloader as expected',
async () => {
await launchChrome({ extensionPath: 'my/extension/path' })
const { edgeFlags } = await EdgeLauncher.launch.mock.calls[0][0]
const flags = edgeFlags.find(flag => flag.startsWith('--load-extension'))
const [flag1, flag2] = flags.split(',')
expect(flag1.endsWith('extension')).toBe(true)
expect(flag2.endsWith('my/extension/path')).toBe(true)
}
)
})
})
})