source: trip-planner-front/node_modules/resolve-url/test/resolve-url.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1// Copyright 2014 Simon Lydell
2// X11 (“MIT”) Licensed. (See LICENSE.)
3
4var test = require("tape")
5
6var resolveUrl = require("../")
7
8"use strict"
9
10test("resolveUrl", function(t) {
11
12 t.plan(7)
13
14 t.equal(typeof resolveUrl, "function", "is a function")
15
16 t.equal(
17 resolveUrl("https://example.com/"),
18 "https://example.com/"
19 )
20
21 var loc = "https://example.com/articles/resolving-urls/edit"
22
23 t.equal(
24 resolveUrl(loc, "remove"),
25 "https://example.com/articles/resolving-urls/remove"
26 )
27
28 t.equal(
29 resolveUrl(loc, "/static/scripts/app.js"),
30 "https://example.com/static/scripts/app.js"
31 )
32
33 t.equal(
34 resolveUrl(loc, "/static/scripts/app.js", "../source-maps/app.js.map"),
35 "https://example.com/static/source-maps/app.js.map"
36 )
37
38 t.equal(
39 resolveUrl(loc, "/static/scripts/app.js", "../source-maps/app.js.map", "../coffee/app.coffee"),
40 "https://example.com/static/coffee/app.coffee"
41 )
42
43 t.equal(
44 resolveUrl(loc, "//cdn.example.com/jquery.js"),
45 "https://cdn.example.com/jquery.js"
46 )
47
48})
49
50test("edge cases", function(t) {
51
52 t.plan(4)
53
54 t["throws"](resolveUrl, /at least one argument/, "throws with no arguments")
55
56 var accidentallyUndefined
57 var result
58 t.doesNotThrow(
59 function() { result = resolveUrl(accidentallyUndefined) },
60 "undefined is still an argument"
61 )
62 t.ok(result.match(/\/undefined$/), "undefined is stringified")
63
64 t.equal(
65 resolveUrl("http://foo.org/test", undefined, {}, ["a/b"], null),
66 "http://foo.org/a/null",
67 "arguments are stringified"
68 )
69
70})
Note: See TracBrowser for help on using the repository browser.