@@ -6,33 +6,27 @@ const supertest = require('supertest');
6
6
const connect = require ( 'connect' ) ;
7
7
const probe = require ( '..' ) ;
8
8
9
- test ( 'test defaults for readiness' , t => {
9
+ test ( 'test defaults for readiness' , async t => {
10
10
const app = connect ( ) ;
11
11
probe ( app ) ;
12
12
13
- supertest ( app )
14
- . get ( '/api/health/readiness' )
15
- . expect ( 200 )
16
- . then ( response => {
17
- t . equal ( response . text , 'OK' , 'should just return OK for the text' ) ;
18
- t . end ( ) ;
19
- } ) ;
13
+ const response = await supertest ( app ) . get ( '/api/health/readiness' ) . expect ( 200 ) ;
14
+
15
+ t . equal ( response . text , 'OK' , 'should just return OK for the text' ) ;
16
+ t . end ( ) ;
20
17
} ) ;
21
18
22
- test ( 'test defaults for liveness' , t => {
19
+ test ( 'test defaults for liveness' , async t => {
23
20
const app = connect ( ) ;
24
21
probe ( app ) ;
25
22
26
- supertest ( app )
27
- . get ( '/api/health/liveness' )
28
- . expect ( 200 )
29
- . then ( response => {
30
- t . equal ( response . text , 'OK' , 'should just return OK for the text' ) ;
31
- t . end ( ) ;
32
- } ) ;
23
+ const response = await supertest ( app ) . get ( '/api/health/liveness' ) . expect ( 200 ) ;
24
+
25
+ t . equal ( response . text , 'OK' , 'should just return OK for the text' ) ;
26
+ t . end ( ) ;
33
27
} ) ;
34
28
35
- test ( 'test different url and callback for readiness' , t => {
29
+ test ( 'test different url and callback for readiness' , async t => {
36
30
const app = connect ( ) ;
37
31
const options = {
38
32
readinessURL : '/different/api/ready' ,
@@ -43,16 +37,13 @@ test('test different url and callback for readiness', t => {
43
37
44
38
probe ( app , options ) ;
45
39
46
- supertest ( app )
47
- . get ( '/different/api/ready' )
48
- . expect ( 200 )
49
- . then ( response => {
50
- t . equal ( response . text , 'Different Callback' , 'Different Callback shold be the new text' ) ;
51
- t . end ( ) ;
52
- } ) ;
40
+ const response = await supertest ( app ) . get ( '/different/api/ready' ) . expect ( 200 ) ;
41
+
42
+ t . equal ( response . text , 'Different Callback' , 'Different Callback shold be the new text' ) ;
43
+ t . end ( ) ;
53
44
} ) ;
54
45
55
- test ( 'test different url and callback for liveness' , t => {
46
+ test ( 'test different url and callback for liveness' , async t => {
56
47
const app = connect ( ) ;
57
48
const options = {
58
49
livenessURL : '/different/api/ready' ,
@@ -63,44 +54,41 @@ test('test different url and callback for liveness', t => {
63
54
64
55
probe ( app , options ) ;
65
56
66
- supertest ( app )
67
- . get ( '/different/api/ready' )
68
- . expect ( 200 )
69
- . then ( response => {
70
- t . equal ( response . text , 'Different Callback' , 'Different Callback shold be the new text' ) ;
71
- t . end ( ) ;
72
- } ) ;
57
+ const response = await supertest ( app ) . get ( '/different/api/ready' ) . expect ( 200 ) ;
58
+
59
+ t . equal ( response . text , 'Different Callback' , 'Different Callback should be the new text' ) ;
60
+ t . end ( ) ;
73
61
} ) ;
74
62
75
- test ( 'default content type for readiness endpoint' , t => {
63
+ test ( 'default content type for readiness endpoint' , async t => {
76
64
t . plan ( 1 ) ;
77
65
const app = connect ( ) ;
78
66
probe ( app ) ;
79
- supertest ( app )
67
+
68
+ const response = await supertest ( app )
80
69
. get ( '/api/health/readiness' )
81
70
. expect ( 200 )
82
- . expect ( 'Content-Type' , / t e x t \/ h t m l / )
83
- . then ( response => {
84
- t . strictEqual ( response . text , 'OK' , 'expected response' ) ;
85
- t . end ( ) ;
86
- } ) ;
71
+ . expect ( 'Content-Type' , / t e x t \/ h t m l / ) ;
72
+
73
+ t . strictEqual ( response . text , 'OK' , 'expected response' ) ;
74
+ t . end ( ) ;
87
75
} ) ;
88
76
89
- test ( 'default content type for liveness endpoint' , t => {
77
+ test ( 'default content type for liveness endpoint' , async t => {
90
78
t . plan ( 1 ) ;
91
79
const app = connect ( ) ;
92
80
probe ( app ) ;
93
- supertest ( app )
81
+
82
+ const response = await supertest ( app )
94
83
. get ( '/api/health/liveness' )
95
84
. expect ( 200 )
96
- . expect ( 'Content-Type' , / t e x t \/ h t m l / )
97
- . then ( response => {
98
- t . strictEqual ( response . text , 'OK' , 'expected response' ) ;
99
- t . end ( ) ;
100
- } ) ;
85
+ . expect ( 'Content-Type' , / t e x t \/ h t m l / ) ;
86
+
87
+ t . strictEqual ( response . text , 'OK' , 'expected response' ) ;
88
+ t . end ( ) ;
101
89
} ) ;
102
90
103
- test ( 'custom content type for liveness endpoint' , t => {
91
+ test ( 'custom content type for liveness endpoint' , async t => {
104
92
t . plan ( 1 ) ;
105
93
const app = connect ( ) ;
106
94
probe ( app , {
@@ -109,12 +97,12 @@ test('custom content type for liveness endpoint', t => {
109
97
response . end ( JSON . stringify ( { status : 'OK' } ) ) ;
110
98
}
111
99
} ) ;
112
- supertest ( app )
100
+
101
+ const response = await supertest ( app )
113
102
. get ( '/api/health/liveness' )
114
103
. expect ( 200 )
115
- . expect ( 'Content-Type' , / j s o n / )
116
- . then ( response => {
117
- t . strictEqual ( response . body . status , 'OK' , 'expected response' ) ;
118
- t . end ( ) ;
119
- } ) ;
104
+ . expect ( 'Content-Type' , / j s o n / ) ;
105
+
106
+ t . strictEqual ( response . body . status , 'OK' , 'expected response' ) ;
107
+ t . end ( ) ;
120
108
} ) ;
0 commit comments