forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_path.js
More file actions
45 lines (41 loc) · 1.78 KB
/
Copy pathtest_path.js
File metadata and controls
45 lines (41 loc) · 1.78 KB
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
module('pc.path');
test("path.getDirectory ", function() {
equal("folder", pc.path.getDirectory("folder/file.txt"));
equal("folder", pc.path.getDirectory("folder/another"));
equal("folder/another", pc.path.getDirectory("folder/another/"));
equal("", pc.path.getDirectory(""));
equal("", pc.path.getDirectory("/"));
});
test("path.join", function() {
equal("a/b", pc.path.join("a", "b"));
equal("/b", pc.path.join("a", "/b"));
equal("/a/b", pc.path.join("/a", "b"));
equal("a/b/c", pc.path.join("a", "b/c"));
equal("a/b/c", pc.path.join("a/b", "c"));
equal("a/b/", pc.path.join("a", "b/"));
equal("/b/", pc.path.join("a", "/b/"));
equal("a/b/", pc.path.join("a", "b/"));
equal("http://a.com/b", pc.path.join("http://a.com", "b"));
equal("a/b", pc.path.join("", "a/b"));
equal("a/b", pc.path.join("a/b", ""));
});
test("path.join, more than two path sections", function () {
equal("a/b/c", pc.path.join("a", "b", "c"));
equal("/b/c", pc.path.join("a", "/b", "c"));
equal("/a/b/c", pc.path.join("/a", "b", "c"));
equal("a/b/c/d", pc.path.join("a/b", "c", "d"));
equal("a/b/c/d", pc.path.join("a", "b/c", "d"));
equal("a/b/c/d", pc.path.join("a", "b", "c/d"));
equal("a/b/c/", pc.path.join("a", "b", "c/"));
equal("/b/c/", pc.path.join("a", "/b", "c/"));
equal("http://a.com/b/c", pc.path.join("http://a.com", "b", "c"));
equal("b/c/", pc.path.join("", "b", "c/"));
equal("b/c/", pc.path.join("b", "c/", ""));
equal("/", pc.path.join("b", "c/", "/"));
equal("a/b/c/d", pc.path.join("a", "b", "c", "d"));
});
test("path.join, invalid values", function () {
raises(function(){
pc.path.join("a", undefined);
}, "pc.path.join should raise an exception if there is an undefined argument" );
});