Skip to content

Commit

Permalink
test: remove airplane dependency from "tests/test_back.js#L235"
Browse files Browse the repository at this point in the history
  • Loading branch information
mbad0la authored and gr2m committed Mar 4, 2018
1 parent 8c9b71e commit 41a583d
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 @@ -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()
})
});

});
Expand Down

0 comments on commit 41a583d

Please sign in to comment.