diff --git a/tests/fixtures/root-paths-cases.json b/tests/fixtures/root-paths-cases.json new file mode 100644 index 000000000..d3127a24d --- /dev/null +++ b/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" + } +] diff --git a/tests/test_scope.js b/tests/test_scope.js new file mode 100644 index 000000000..705b05465 --- /dev/null +++ b/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(); + }); +});