-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathRefs.test.js
More file actions
70 lines (60 loc) · 2.52 KB
/
Refs.test.js
File metadata and controls
70 lines (60 loc) · 2.52 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
61
62
63
64
65
66
67
68
69
70
describe('Refs', () => {
beforeEach(async () => {
await page.goto('http://localhost:6969/')
await page.click('[href="/refs"]')
})
test('refs should be loaded during hydrate', async () => {
await page.waitForSelector('[data-id="hydrate-element"]')
const element = await page.$('[data-id="hydrate-element"]')
expect(element).toBeTruthy()
})
test('refs accept composed computed references', async () => {
await page.waitForSelector('[data-id="composed-computed"]')
const element = await page.$('[data-id="composed-computed"]')
expect(element).toBeTruthy()
})
test('refs accept logical computed references', async () => {
await page.waitForSelector('[data-id="logical-computed"]')
const element = await page.$('[data-id="logical-computed"]')
expect(element).toBeTruthy()
})
test('refs accept literal computed references', async () => {
await page.waitForSelector('[data-id="literal-computed"]')
const element = await page.$('[data-id="literal-computed"]')
expect(element).toBeTruthy()
})
test('refs functions receive an element as argument', async () => {
await page.waitForSelector('[data-id="function"]')
const element = await page.$('[data-id="function"]')
expect(element).toBeTruthy()
})
test('refs functions receive attributes as argument', async () => {
await page.waitForSelector('[data-ref-received-props]')
const element = await page.$('[data-ref-received-props]')
expect(element).toBeTruthy()
})
test('refs functions only run after the element is appended do DOM', async () => {
await page.waitForSelector('[data-dom="0"]')
const element = await page.$('[data-dom="0"]')
expect(element).toBeTruthy()
})
test('refs can be bubbled down', async () => {
await page.waitForSelector('[data-id="bubble"]')
const element = await page.$('[data-id="bubble"]')
expect(element).toBeTruthy()
})
test('refs functions run when the ref object changes', async () => {
await page.waitForSelector('[data-dom="0"]')
await page.click('button')
await page.waitForSelector('[data-dom="1"]')
const element = await page.$('[data-dom="1"]')
expect(element).toBeTruthy()
})
test('refs are reassigned when the ref object changes ', async () => {
await page.waitForSelector('[data-dom="0"]')
await page.click('button')
await page.waitForSelector('[data-id="hydrate-element"][data-instance="1"]')
const element = await page.$('[data-id="hydrate-element"][data-instance="1"]')
expect(element).toBeTruthy()
})
})