-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
51 lines (44 loc) · 1018 Bytes
/
index.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
import test from 'ava'
import {
withDirectory,
writeFile,
withChromePath,
} from '../../test/helpers/index.js'
import {
openBrowser,
closeBrowser,
openTab,
getTabs,
findElement,
} from '../../index.js'
withChromePath(test)
withDirectory(test)
test('listing the currently open tabs', async (t) => {
const {directory} = t.context
const browser = await openBrowser(global.chromePath)
const onePath = await writeFile(
directory,
'one.html',
`
<!doctype html>
<meta charset="utf-8">
<div>One</div>
`,
)
const twoPath = await writeFile(
directory,
'two.html',
`
<!doctype html>
<meta charset="utf-8">
<div>Two</div>
`,
)
await openTab(browser, `file://${onePath}`)
await openTab(browser, `file://${twoPath}`)
const tabs = await getTabs(browser)
t.is(tabs.length, 2)
t.is((await findElement(tabs[0], 'div')).textContent, 'One')
t.is((await findElement(tabs[1], 'div')).textContent, 'Two')
await closeBrowser(browser)
})