Skip to content

Commit

Permalink
test: remove airplane dependency from "tests/test_back.js#L188"
Browse files Browse the repository at this point in the history
  • Loading branch information
mbad0la authored and gr2m committed Mar 3, 2018
1 parent 1859a92 commit 8c9b71e
Showing 1 changed file with 41 additions and 33 deletions.
74 changes: 41 additions & 33 deletions tests/test_back.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,44 +221,52 @@ tap.test('nockBack dryrun tests', function (nw) {
nockBackWithFixture(t, true);
});

nw.test('goes to internet, doesn\'t record new fixtures', {skip: process.env.AIRPLANE}, function (t) {
var dataCalled = false;
nw.test('goes to internet, doesn\'t record new fixtures', function (t) {

var fixture = 'someDryrunFixture.json';
var fixtureLoc = nockBack.fixtures + '/' + fixture;
t.plan(5)

t.false(exists(fixtureLoc));
let dataCalled = false

nockBack(fixture, function (done) {
var req = http.request({
host: "amazon.com"
, path: '/'
, port: 80
}, function(res) {

t.ok([200, 301, 302].indexOf(res.statusCode) >= 0);
res.on('end', function() {
t.ok(dataCalled);
t.false(exists(fixtureLoc));
t.end();
});

res.on('data', function(data) {
dataCalled = true;
});

});
const fixture = 'someDryrunFixture.json'
const fixtureLoc = nockBack.fixtures + '/' + fixture

req.once('error', function(err) {
if (err.code !== 'ECONNREFUSED') {
throw err;
}
t.end();
});
t.false(exists(fixtureLoc))

req.end();
});
});
nockBack(fixture, function (done) {
const server = http.createServer((request, response) => {
t.pass('server received a request')

response.writeHead(200)
response.write('server served a response')
response.end()
})

server.listen(() => {
const request = http.request({
host: 'localhost',
path: '/',
port: server.address().port
}, (response) => {
t.is(200, response.statusCode)

response.on('data', (data) => {
dataCalled = true
})

response.on('end', () => {
t.ok(dataCalled)
t.false(exists(fixtureLoc))

server.close(t.end)
})
})

request.on('error', t.error)
request.end()
})
})

})

setOriginalModeOnEnd(nw, nockBack);

Expand Down

0 comments on commit 8c9b71e

Please sign in to comment.