@@ -9,19 +9,24 @@ const app = require('../src/services/app')
9
9
const logger = require ( '../src/services/log' )
10
10
const logHelper = require ( './helpers/log' )
11
11
12
- function request ( ) {
13
- return superagent ( app . koa . listen ( ) )
14
- }
15
-
16
12
describe ( 'Metadata' , function ( ) {
17
13
logHelper ( logger )
18
14
15
+ before ( function ( ) {
16
+ this . server = app . koa . listen ( )
17
+ this . request = ( ) => superagent ( this . server )
18
+ } )
19
+
20
+ after ( function ( ) {
21
+ this . server . close ( )
22
+ } )
23
+
19
24
delete process . env . LEDGER_AMOUNT_PRECISION
20
25
delete process . env . UNIT_TEST_OVERRIDE
21
26
22
27
describe ( 'GET /' , function ( ) {
23
28
it ( 'should return metadata' , async function ( ) {
24
- await request ( )
29
+ await this . request ( )
25
30
. get ( '/' )
26
31
. expect ( 200 )
27
32
. expect ( function ( res ) {
@@ -66,7 +71,8 @@ describe('Metadata', function () {
66
71
timerWorker : require ( '../src/services/timerWorker' ) ,
67
72
notificationBroadcaster : require ( '../src/services/notificationBroadcaster' )
68
73
} )
69
- const agent = superagent ( newApp . koa . listen ( ) )
74
+ const server = newApp . koa . listen ( )
75
+ const agent = superagent ( server )
70
76
71
77
await agent
72
78
. get ( '/' )
@@ -105,6 +111,8 @@ describe('Metadata', function () {
105
111
delete process . env . LEDGER_CURRENCY_CODE
106
112
delete process . env . LEDGER_CURRENCY_SYMBOL
107
113
delete process . env . LEDGER_ILP_PREFIX
114
+
115
+ server . close ( )
108
116
} )
109
117
} )
110
118
} )
0 commit comments