@@ -11,8 +11,9 @@ t.beforeEach(async (t) => {
11
11
} )
12
12
13
13
t . test ( 'GET /users 200' , async ( t ) => {
14
+ // Arrange
14
15
const { app, accessToken, refreshToken } = t . context
15
- console . log ( 'accessToken ' , accessToken . value )
16
+
16
17
// Act
17
18
const response = await app . inject ( {
18
19
method : 'GET' ,
@@ -30,3 +31,43 @@ t.test('GET /users 200', async (t) => {
30
31
t . equal ( response . statusCode , 200 )
31
32
t . type ( response . json ( ) , 'object' )
32
33
} )
34
+
35
+ t . test ( 'GET /users 401' , async ( t ) => {
36
+ // Arrange
37
+ const { app } = t . context
38
+
39
+ // Act
40
+ const response = await app . inject ( {
41
+ method : 'GET' ,
42
+ url : '/users' ,
43
+ headers : {
44
+ contentType : 'application/json' ,
45
+ } ,
46
+ } )
47
+
48
+ // Assert
49
+ t . equal ( response . statusCode , 401 )
50
+ t . type ( response . json ( ) , 'object' )
51
+ } )
52
+
53
+ t . test ( 'GET /users 404' , async ( t ) => {
54
+ // Arrange
55
+ const { app, accessToken, refreshToken } = t . context
56
+
57
+ // Act
58
+ const response = await app . inject ( {
59
+ method : 'GET' ,
60
+ url : '/users/123456' ,
61
+ headers : {
62
+ contentType : 'application/json' ,
63
+ } ,
64
+ cookies : {
65
+ accessToken : accessToken ,
66
+ refreshToken : refreshToken ,
67
+ } ,
68
+ } )
69
+
70
+ // Assert
71
+ t . equal ( response . statusCode , 404 )
72
+ t . type ( response . json ( ) , 'object' )
73
+ } )
0 commit comments