Skip to content

Commit

Permalink
Implement failing tests of nock#1061
Browse files Browse the repository at this point in the history
  • Loading branch information
Overdrivr authored and gr2m committed Feb 23, 2018
1 parent df04e86 commit 3fb240f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/fixtures/root-paths-cases.json
@@ -0,0 +1,30 @@
[
{
"root": "localhost",
"basePath": "http://localhost:80"
},
{
"root": "127.0.0.1",
"basePath": "http://127.0.0.1:80"
},
{
"root": "localhost:1234",
"basePath": "http://localhost:1234"
},
{
"root": "127.0.0.1:1234",
"basePath": "http://127.0.0.1:1234"
},
{
"root": "localhost:1234/url",
"basePath": "http://localhost:1234/url"
},
{
"root": "127.0.0.1:1234/url",
"basePath": "http://127.0.0.1:1234/url"
},
{
"root": "foo.com/api",
"basePath": "http://foo.com:80/api"
}
]
15 changes: 15 additions & 0 deletions tests/test_scope.js
@@ -0,0 +1,15 @@
'use strict';

var Scope = require('../lib/scope')
, assert = require('assert')
, tap = require('tap')
, testcases = require('./fixtures/root-paths-cases.json')
, _ = require('lodash');

testcases.forEach(function(cas) {
tap.test(`Scope parsing of root url: ${cas.root}`, function (t) {
let s = Scope(cas.root);
assert.equal(s.basePath, cas.basePath);
t.end();
});
});

0 comments on commit 3fb240f

Please sign in to comment.