-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
44 lines (37 loc) · 1.2 KB
/
test.js
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
'use strict'
const tap = require('tap')
const main = require('./example')
const firstPost = {
userId: 1,
id: 1,
title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
body: 'quia et suscipit\n' +
'suscipit recusandae consequuntur expedita et cum\n' +
'reprehenderit molestiae ut ut quas totam\n' +
'nostrum rerum est autem sunt rem eveniet architecto'
}
const tenthPost = {
userId: 1,
id: 10,
title: 'optio molestias id quia eum',
body: 'quo et expedita modi cum officia vel magni\n' +
'doloribus qui repudiandae\n' +
'vero nisi sit\n' +
'quos veniam quod sed accusamus veritatis error'
}
tap.test('manifetch', async (t) => {
t.plan(2)
const { client, posts, post } = await main(true)
const { json: postsFromNested } = await client.nestedDemonstration.getPosts()
const { json: postFromNested } = await client.nestedDemonstration.getPost({ id: 10 })
t.test('should work without params', (t) => {
t.plan(2)
t.strictSame(posts[0], firstPost)
t.strictSame(postsFromNested[0], firstPost)
})
t.test('should work with params', (t) => {
t.plan(2)
t.strictSame(post, tenthPost)
t.strictSame(postFromNested, tenthPost)
})
})