forked from nullstack/nullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContextLoading.test.js
More file actions
42 lines (33 loc) · 1.11 KB
/
ContextLoading.test.js
File metadata and controls
42 lines (33 loc) · 1.11 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
const puppeteer = require('puppeteer');
let browser;
let page;
beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/context-loading');
});
describe('ContextLoading', () => {
test('is part of the context worker', async () => {
const element = await page.$('[data-loading]');
expect(element).toBeTruthy();
});
test('has false keys by default', async () => {
const element = await page.$('[data-loading-function]');
expect(element).toBeFalsy();
});
test('sets a key with the function name to true before it requests', async () => {
await page.click('button');
await page.waitForSelector('[data-loading-function]');
const element = await page.$('[data-loading-function]');
expect(element).toBeTruthy();
});
test('removes the key with the function name after it requests', async () => {
await page.click('button');
await page.waitForTimeout(1500);
const element = await page.$('[data-loading-function]');
expect(element).toBeFalsy();
});
});
afterAll(async () => {
browser.close();
});