-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathInstanceable.test.js
More file actions
40 lines (33 loc) · 1.27 KB
/
Instanceable.test.js
File metadata and controls
40 lines (33 loc) · 1.27 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
beforeAll(async () => {
await page.goto('http://localhost:6969/instanceable')
})
describe('Instanceable', () => {
const testCycle = async (title, value) => {
const selector = `[data-title="${title}"][data-hydrated]`
await page.waitForSelector(selector)
const p = await page.$(selector)
const text = await page.evaluate((element) => element.textContent, p)
const expectedValue = new Array(2).fill(value).join(' ')
expect(text).toBe(expectedValue)
}
test('server lifecycle can change instance', async () => {
await testCycle('prepare', 'Prepared!')
})
test('client lifecycle can change instance', async () => {
await testCycle('hydrate', 'Hydrated!')
})
test("instance can use foreign methods which calls it's back", async () => {
await page.click('button')
await page.waitForSelector('[data-change-instanceable]')
await testCycle('title', 'Nullstack!')
})
test("main key is 'application'", async () => {
const p = await page.$('[data-application-key]')
expect(p).toBeTruthy()
})
test('instance key ignores the route suffix if a key is declared', async () => {
await page.waitForSelector('[data-key="instanceable"]')
const element = await page.$('[data-key="instanceable"]')
expect(element).toBeTruthy()
})
})