forked from lufrai/spiderable2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spiderable_tests.js
47 lines (45 loc) · 1.17 KB
/
spiderable_tests.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
var url = Npm.require("url");
Tinytest.add("spiderable2 - url generation", function (test, expect) {
var absUrl = "http://example.com";
_.each([
{
requestUrl: "/?_escaped_fragment_=1",
expected: "/"
},
// Test that query strings are preserved
{
requestUrl: "/?_escaped_fragment_=1&foo=bar",
expected: "/?foo=bar"
},
{
requestUrl: "/?foo=bar&_escaped_fragment_=1",
expected: "/?foo=bar"
},
// Test that paths are preserved
{
requestUrl: "/foo/bar?_escaped_fragment_=1",
expected: "/foo/bar"
},
{
requestUrl: "/foo/bar?_escaped_fragment_=1&foo=bar",
expected: "/foo/bar?foo=bar"
},
// Test with a path on the site's absolute url
{
requestUrl: "/foo/bar?_escaped_fragment_=1",
expected: "/foo/bar",
absUrl: "http://example.com/foo"
},
{
requestUrl: "/bar?_escaped_fragment_=1",
expected: "/bar",
absUrl: "http://example.com/foo"
}
], function (testCase) {
testCase.absUrl = testCase.absUrl || absUrl;
test.equal(
Spiderable2._verifyUrl(absUrl, testCase.requestUrl),
absUrl + testCase.expected
);
});
});