forked from nullstack/nullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstanceKey.test.js
More file actions
37 lines (29 loc) · 987 Bytes
/
InstanceKey.test.js
File metadata and controls
37 lines (29 loc) · 987 Bytes
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
const puppeteer = require('puppeteer');
let browser;
let page;
beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/instance-key');
await page.click('.increment-by-two');
await page.waitForSelector('[data-count="3"]');
});
describe('InstanceKey', () => {
test('components can share the same instance', async () => {
const elements = await page.$$('[data-count="3"]');
expect(elements.length).toBe(2);
});
test('moving a component with a key will keep its instance alive', async () => {
await page.click('.move-component');
await page.waitForTimeout(500);
const elements = await page.$$('[data-count="3"]');
expect(elements.length).toBe(2);
});
test('shared instances only run the lifecycle once', async () => {
const element = await page.$('[data-prepared="1"]');
expect(element).toBeTruthy();
});
});
afterAll(async () => {
browser.close();
});