Skip to content

Commit

Permalink
test: remove airplane dependency from "tests/test_back.js#L261" (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbad0la authored and gr2m committed Mar 6, 2018
1 parent 41a583d commit 8bc706b
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions tests/test_back.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,26 +321,45 @@ tap.test('nockBack record tests', function (nw) {

//Adding this test because there was an issue when not calling
//nock.activate() after calling nock.restore()
nw.test('it can record twice', {skip: process.env.AIRPLANE}, function (t) {
nw.test('it can record twice', function (t) {
t.plan(4)

nockBack.fixtures = __dirname + '/fixtures';

var options = {
host: 'www.google.com', method: 'GET', path: '/', port: 80
};
var fixture = 'someFixture2.json';
var fixtureLoc = nockBack.fixtures + '/' + fixture;
const fixture = 'someFixture2.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()
})
});
});

nw.test('it shouldn\'t allow outside calls', function (t) {
Expand Down

0 comments on commit 8bc706b

Please sign in to comment.