forked from nullstack/nullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerFunctions.test.js
More file actions
56 lines (45 loc) · 1.74 KB
/
ServerFunctions.test.js
File metadata and controls
56 lines (45 loc) · 1.74 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
const puppeteer = require('puppeteer');
let browser;
let page;
beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:6969/server-functions');
});
describe('ServerFunctions', () => {
test('instance can use returned values', async () => {
await page.click('.set-count-to-one');
await page.waitForSelector('[data-count="1"]');
const element = await page.$('[data-count="1"]');
expect(element).toBeTruthy();
});
test('server functions accept an object as argument', async () => {
await page.click('.set-count-to-two');
await page.waitForSelector('[data-count="2"]');
const element = await page.$('[data-count="2"]');
expect(element).toBeTruthy();
});
test('server functions serialize and deserialize dates', async () => {
await page.click('.set-date');
await page.waitForSelector('[data-year="1992"]');
const element = await page.$('[data-year="1992"]');
expect(element).toBeTruthy();
});
test('server functions have access to node.js environment', async () => {
await page.waitForSelector(`[data-statement="import Nullstack from 'nullstack';"]`);
const element = await page.$(`[data-statement="import Nullstack from 'nullstack';"]`);
expect(element).toBeTruthy();
});
test('server functions have access to fetch', async () => {
await page.waitForSelector('[data-response="User-Agent: *"]');
const element = await page.$('[data-response="User-Agent: *"]');
expect(element).toBeTruthy();
});
test('isomorphic imports stay in the client', async () => {
const element = await page.$('[data-client-only]');
expect(element).toBeTruthy();
});
});
afterAll(async () => {
browser.close();
});