+++ /dev/null
-// Copyright 2014 Simon Lydell\r
-// X11 (“MIT”) Licensed. (See LICENSE.)\r
-\r
-var test = require("tape")\r
-\r
-var resolveUrl = require("../")\r
-\r
-"use strict"\r
-\r
-test("resolveUrl", function(t) {\r
-\r
- t.plan(7)\r
-\r
- t.equal(typeof resolveUrl, "function", "is a function")\r
-\r
- t.equal(\r
- resolveUrl("https://example.com/"),\r
- "https://example.com/"\r
- )\r
-\r
- var loc = "https://example.com/articles/resolving-urls/edit"\r
-\r
- t.equal(\r
- resolveUrl(loc, "remove"),\r
- "https://example.com/articles/resolving-urls/remove"\r
- )\r
-\r
- t.equal(\r
- resolveUrl(loc, "/static/scripts/app.js"),\r
- "https://example.com/static/scripts/app.js"\r
- )\r
-\r
- t.equal(\r
- resolveUrl(loc, "/static/scripts/app.js", "../source-maps/app.js.map"),\r
- "https://example.com/static/source-maps/app.js.map"\r
- )\r
-\r
- t.equal(\r
- resolveUrl(loc, "/static/scripts/app.js", "../source-maps/app.js.map", "../coffee/app.coffee"),\r
- "https://example.com/static/coffee/app.coffee"\r
- )\r
-\r
- t.equal(\r
- resolveUrl(loc, "//cdn.example.com/jquery.js"),\r
- "https://cdn.example.com/jquery.js"\r
- )\r
-\r
-})\r
-\r
-test("edge cases", function(t) {\r
-\r
- t.plan(4)\r
-\r
- t["throws"](resolveUrl, /at least one argument/, "throws with no arguments")\r
-\r
- var accidentallyUndefined\r
- var result\r
- t.doesNotThrow(\r
- function() { result = resolveUrl(accidentallyUndefined) },\r
- "undefined is still an argument"\r
- )\r
- t.ok(result.match(/\/undefined$/), "undefined is stringified")\r
-\r
- t.equal(\r
- resolveUrl("http://foo.org/test", undefined, {}, ["a/b"], null),\r
- "http://foo.org/a/null",\r
- "arguments are stringified"\r
- )\r
-\r
-})\r