From 41a583d78ed0ffb9bc7305f5a6caf2549ef490c9 Mon Sep 17 00:00:00 2001 From: Mayank Badola Date: Sun, 4 Mar 2018 08:09:27 +0530 Subject: [PATCH] test: remove airplane dependency from "tests/test_back.js#L235" --- tests/test_back.js | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/tests/test_back.js b/tests/test_back.js index 7ff00bef5..bbc0cc26c 100644 --- a/tests/test_back.js +++ b/tests/test_back.js @@ -276,26 +276,45 @@ tap.test('nockBack dryrun tests', function (nw) { tap.test('nockBack record tests', function (nw) { nockBack.setMode('record'); - nw.test('it records when configured correctly', {skip: process.env.AIRPLANE}, function (t) { - nockBack.fixtures = __dirname + '/fixtures'; + nw.test('it records when configured correctly', function (t) { - var options = { - host: 'www.google.com', method: 'GET', path: '/', port: 80 - }; + t.plan(4) - var fixture = 'someFixture.json'; - var fixtureLoc = nockBack.fixtures + '/' + fixture; + nockBack.fixtures = __dirname + '/fixtures'; + + const fixture = 'someFixture.txt' + const fixtureLoc = nockBack.fixtures + '/' + fixture t.false(exists(fixtureLoc)); nockBack(fixture, function (done) { - http.request(options).end(); - done(); + const server = http.createServer((request, response) => { + t.pass('server received a request') - t.true(exists(fixtureLoc)); + response.writeHead(200) + response.write('server served a response') + response.end() + }) - fs.unlinkSync(fixtureLoc); - t.end(); + server.listen(() => { + const request = http.request({ + host: 'localhost', + path: '/', + port: server.address().port + }, (response) => { + done() + + t.is(200, response.statusCode) + t.true(exists(fixtureLoc)) + + fs.unlinkSync(fixtureLoc) + + server.close(t.end) + }) + + request.on('error', t.error) + request.end() + }) }); });