-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathBodyFragment.test.js
More file actions
60 lines (52 loc) · 2.33 KB
/
BodyFragment.test.js
File metadata and controls
60 lines (52 loc) · 2.33 KB
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
beforeEach(async () => {
await page.goto('http://localhost:6969/body-fragment')
})
describe('BodyFragment', () => {
test('the body behaves as a fragment and creates no markup', async () => {
const element = await page.$('body > #application > h1')
expect(element).toBeTruthy()
})
test('when the body is nested regular attributes are overwritten by the last one in the tree', async () => {
const element = await page.$('body[data-chars="b"]')
expect(element).toBeTruthy()
})
test('when the body is nested classes are merged togheter', async () => {
const element = await page.$('body[class="class-one class-two class-three class-four"]')
expect(element).toBeTruthy()
})
test('when the body is nested styles are merged togheter', async () => {
const element = await page.$('body[style="background-color: black; color: white;"]')
expect(element).toBeTruthy()
})
test('when the body is nested events are invoked sequentially', async () => {
await page.waitForSelector('body[data-hydrated]')
await page.click('body')
await page.waitForSelector('[data-keys][data-objected][data-visible]')
const element = await page.$('[data-keys][data-objected][data-visible]')
expect(element).toBeTruthy()
})
test('when a body is added to the vdom attributes are added', async () => {
await page.waitForSelector('body[data-hydrated]')
await page.click('body')
await page.waitForSelector('body[data-visible]')
const element = await page.$('body[data-visible]')
expect(element).toBeTruthy()
})
test('when a body is removed from the vdom attributes are removed', async () => {
await page.waitForSelector('body[data-hydrated]')
await page.click('body')
await page.waitForSelector('body[data-visible]')
await page.click('body')
await page.waitForSelector('body:not([data-visible])')
const element = await page.$('body:not([data-visible])')
expect(element).toBeTruthy()
})
test('the body removes events when the fragment leaves the tree', async () => {
await page.waitForSelector('body[data-hydrated]')
await page.click('[href="/"]')
await page.waitForSelector('[data-application-hydrated]:not([data-count])')
await page.click('body')
const element = await page.$('[data-application-hydrated]:not([data-count])')
expect(element).toBeTruthy()
})
})