@@ -7,22 +7,14 @@ test.before(globalBeforeAll({
7
7
} ) ) ;
8
8
test . after ( globalAfterAll ( ) ) ;
9
9
10
- test ( 'Test api prefix (GET /api/v2)' , async ( t ) => {
11
- try {
12
- await api . get ( '/users/categories' ) ;
13
- } catch ( err ) {
14
- t . is ( err . response . status , 404 ) ;
15
- }
16
- } ) ;
17
-
18
10
test ( 'Test first level api (GET /api/v2/users)' , async ( t ) => {
19
11
const { data} = await api . get ( '/users' ) ;
20
12
t . true ( data . ok ) ;
21
13
} ) ;
22
14
23
- test ( 'Test second level api (GET /api/v2/users/categories ) - should give 404' , async ( t ) => {
15
+ test ( 'Test second level api (GET /api/v2/foo ) - should give 404' , async ( t ) => {
24
16
try {
25
- await api . get ( '/users/categories ' ) ;
17
+ await api . get ( '/foo ' ) ;
26
18
} catch ( err ) {
27
19
t . is ( err . response . status , 404 ) ;
28
20
}
@@ -60,11 +52,13 @@ test('Test hybrid api data flow client side', async (t) => {
60
52
const clickEvent = new window . Event ( 'click' ) ;
61
53
const path = window . document . querySelector ( '.index span.path' ) ;
62
54
const okay = window . document . querySelector ( '.index span.okay' ) ;
55
+ const idParam = window . document . querySelector ( '.index span.id-param' ) ;
63
56
const changePath = window . document . querySelector ( '.index .change-path' ) ;
64
57
65
58
changePath . dispatchEvent ( clickEvent ) ;
66
59
await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // wait for API request
67
60
68
- t . is ( path . textContent , '/api/v2/users' ) ;
61
+ t . is ( path . textContent , '/api/v2/users/1 ' ) ;
69
62
t . is ( okay . textContent , "It's okay!" ) ;
63
+ t . is ( idParam . textContent , '1' ) ;
70
64
} ) ;
0 commit comments