-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathurl.test.js
68 lines (57 loc) · 2.26 KB
/
url.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import url from "./url";
describe("Core / url / UrlArgumentParser", function () {
describe("_decodeQS", function () {
it("Basic string", function () {
var parser = new url.UrlArgumentParser();
expect(parser._decodeQS("Foo")).toBe("Foo");
});
it("String with whitespace", function () {
var parser = new url.UrlArgumentParser();
expect(parser._decodeQS("Aap+Noot+Mies")).toBe("Aap Noot Mies");
});
it("String with encoded characters", function () {
var parser = new url.UrlArgumentParser();
expect(parser._decodeQS("Jip%26Janneke")).toBe("Jip&Janneke");
});
});
describe("_parse", function () {
it("No query string", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("")).toEqual({});
});
it("No parameter specified", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("?")).toEqual({});
});
it("Parameter without value", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("?key")).toEqual({ key: [null] });
});
it("Parameter with empty value", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("?key=")).toEqual({ key: [""] });
});
it("Parameter with plain value", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("?key=value")).toEqual({ key: ["value"] });
});
it("Multiple parameters", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("?one=en&two=to")).toEqual({
one: ["en"],
two: ["to"],
});
});
it("Parameter with multiple values", function () {
var parser = new url.UrlArgumentParser();
expect(parser._parse("?key=value&key=other")).toEqual({
key: ["value", "other"],
});
});
});
});
describe("Core / url / parameters", function () {
it("Bound to working parser", function () {
expect(url.parameters()).not.toBe(undefined);
});
});