Skip to content

Commit

Permalink
refactor: Remove the last of the real hostnames (#1691)
Browse files Browse the repository at this point in the history
Closes #1351
  • Loading branch information
paulmelnikow authored and gr2m committed Sep 4, 2019
1 parent f00f0f3 commit 21733b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/fixtures/goodRequest.json
@@ -1,6 +1,6 @@
[
{
"scope": "http://www.google.com:80",
"scope": "http://www.example.test:80",
"method": "GET",
"path": "/",
"body": "",
Expand Down
18 changes: 10 additions & 8 deletions tests/test_back.js
Expand Up @@ -20,14 +20,14 @@ const exists = fs.existsSync
function testNock(t) {
let dataCalled = false

const scope = nock('http://example.test')
const scope = nock('http://www.example.test')
.get('/')
.reply(200, 'Hello World!')

http
.request(
{
host: 'example.test',
host: 'www.example.test',
path: '/',
port: 80,
},
Expand All @@ -53,7 +53,7 @@ function nockBackWithFixture(t, scopesLoaded) {

nockBack('goodRequest.json', function(done) {
t.equal(this.scopes.length, scopesLength)
http.get('http://www.google.com').end()
http.get('http://www.example.test/').end()
this.assertScopesFinished()
done()
t.end()
Expand Down Expand Up @@ -343,11 +343,13 @@ test('nockBack record tests', nw => {
const fixture = 'wrongUri.json'
nockBack(fixture, function(done) {
http
.get('http://www.amazon.com', res => t.fail('Should not come here!'))
.get('http://other.example.test', res =>
t.fail('Should not come here!')
)
.on('error', err => {
t.equal(
err.message,
'Nock: Disallowed net connect for "www.amazon.com:80/"'
'Nock: Disallowed net connect for "other.example.test:80/"'
)
done()
t.end()
Expand All @@ -358,7 +360,7 @@ test('nockBack record tests', nw => {
nw.test('it loads your recorded tests', t => {
nockBack('goodRequest.json', function(done) {
t.true(this.scopes.length > 0)
http.get('http://www.google.com').end()
http.get('http://www.example.test/').end()
this.assertScopesFinished()
done()
t.end()
Expand Down Expand Up @@ -465,7 +467,7 @@ test('nockBack lockdown tests', nw => {
nw.test('no unnocked http calls work', t => {
const req = http.request(
{
host: 'google.com',
host: 'other.example.test',
path: '/',
},
res => t.fail('Should not come here!')
Expand All @@ -474,7 +476,7 @@ test('nockBack lockdown tests', nw => {
req.on('error', err => {
t.equal(
err.message.trim(),
'Nock: Disallowed net connect for "google.com:80/"'
'Nock: Disallowed net connect for "other.example.test:80/"'
)
t.end()
})
Expand Down

0 comments on commit 21733b4

Please sign in to comment.