11'use strict' ;
22
3- const preq = require ( 'preq' ) ;
4-
53const TestServer = require ( '../TestServer' ) ;
64const cluster = require ( 'cluster' ) ;
75const assert = require ( 'assert' ) ;
@@ -109,15 +107,18 @@ describe( 'service-runner tests', () => {
109107 const server = new TestServer ( `${ __dirname } /../utils/simple_config_no_workers.yaml` ) ;
110108 const response = { status : null , body : null } ;
111109 return server . start ( )
112- . then ( ( ) => {
113- preq . get ( { uri : 'http://127.0.0.1:12345' } ) ;
110+ . then ( async ( ) => {
111+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
112+ await fetch ( 'http://127.0.0.1:12345' ) ;
114113 } )
115114 . delay ( 1000 )
116- . then ( ( ) => {
117- preq . get ( { uri : 'http://127.0.0.1:9000' } )
118- . then ( ( res ) => {
115+ . then ( async ( ) => {
116+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
117+ await fetch ( 'http://127.0.0.1:9000' )
118+ . then ( async ( res ) => {
119119 response . status = res . status ;
120- response . body = res . body ;
120+ // This is a ReadableStream of a Uint8Array, but we just want the string
121+ response . body = new TextDecoder ( ) . decode ( await res . arrayBuffer ( ) ) ;
121122 } ) ;
122123 } )
123124 . delay ( 1000 )
@@ -135,15 +136,18 @@ describe( 'service-runner tests', () => {
135136 const server = new TestServer ( `${ __dirname } /../utils/simple_config_one_worker.yaml` ) ;
136137 const response = { status : null , body : null } ;
137138 return server . start ( )
138- . then ( ( ) => {
139- preq . get ( { uri : 'http://127.0.0.1:12345' } ) ;
139+ . then ( async ( ) => {
140+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
141+ await fetch ( 'http://127.0.0.1:12345' ) ;
140142 } )
141143 . delay ( 1000 )
142- . then ( ( ) => {
143- preq . get ( { uri : 'http://127.0.0.1:9000' } )
144- . then ( ( res ) => {
144+ . then ( async ( ) => {
145+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
146+ await fetch ( 'http://127.0.0.1:9000' )
147+ . then ( async ( res ) => {
145148 response . status = res . status ;
146- response . body = res . body ;
149+ // This is a ReadableStream of a Uint8Array, but we just want the string
150+ response . body = new TextDecoder ( ) . decode ( await res . arrayBuffer ( ) ) ;
147151 } ) ;
148152 } )
149153 . delay ( 1000 )
@@ -161,15 +165,18 @@ describe( 'service-runner tests', () => {
161165 const server = new TestServer ( `${ __dirname } /../utils/simple_config_two_workers.yaml` ) ;
162166 const response = { status : null , body : null } ;
163167 return server . start ( )
164- . then ( ( ) => {
165- preq . get ( { uri : 'http://127.0.0.1:12345' } ) ;
168+ . then ( async ( ) => {
169+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
170+ await fetch ( 'http://127.0.0.1:12345' ) ;
166171 } )
167172 . delay ( 1000 )
168- . then ( ( ) => {
169- preq . get ( { uri : 'http://127.0.0.1:9000' } )
170- . then ( ( res ) => {
173+ . then ( async ( ) => {
174+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
175+ await fetch ( 'http://127.0.0.1:9000' )
176+ . then ( async ( res ) => {
171177 response . status = res . status ;
172- response . body = res . body ;
178+ // This is a ReadableStream of a Uint8Array, but we just want the string
179+ response . body = new TextDecoder ( ) . decode ( await res . arrayBuffer ( ) ) ;
173180 } ) ;
174181 } )
175182 . delay ( 1000 )
0 commit comments