|
1 | 1 | module Test.Main where
|
2 | 2 |
|
3 | 3 | import Prelude
|
| 4 | + |
4 | 5 | import Effect (Effect)
|
5 |
| -import Node.Path (parse, delimiter, normalize, sep, extname, basenameWithoutExt, basename, dirname, relative, concat) |
6 |
| -import Test.Assert (assert) |
| 6 | +import Node.Path (basename, basenameWithoutExt, concat, delimiter, dirname, extname, normalize, parse, relative, sep) |
| 7 | +import Test.Assert (assert, assertEqual) |
7 | 8 |
|
8 | 9 | main :: Effect Unit
|
9 | 10 | main = do
|
10 |
| - assert $ normalize "/foo/bar//baz/asdf/quux/.." == normalize "/foo/bar/baz/asdf" |
11 |
| - assert $ concat ["/foo", "bar"] == normalize "/foo/bar" |
12 |
| - assert $ relative "/data/orandea/test/aaa" "/data/orandea/impl/bbb" == normalize "../../impl/bbb" |
13 |
| - assert $ dirname "/foo/bar/baz/asdf/quux" == normalize "/foo/bar/baz/asdf" |
14 |
| - assert $ basename "/foo/bar/baz/asdf/quux.html" == "quux.html" |
15 |
| - assert $ basenameWithoutExt "/foo/bar/baz/asdf/quux.html" ".html" == "quux" |
16 |
| - assert $ basenameWithoutExt "/foo/bar/baz/asdf/quux.txt" ".html" == "quux.txt" |
17 |
| - assert $ extname "index.html" == ".html" |
18 |
| - assert $ extname "index.coffee.md" == ".md" |
19 |
| - assert $ extname "index." == "." |
20 |
| - assert $ extname "index" == "" |
21 |
| - assert $ sep == normalize "/" |
| 11 | + assertEqual |
| 12 | + { actual: normalize "/foo/bar//baz/asdf/quux/.." |
| 13 | + , expected: normalize "/foo/bar/baz/asdf" |
| 14 | + } |
| 15 | + assertEqual |
| 16 | + { actual: concat ["/foo", "bar"] |
| 17 | + , expected: normalize "/foo/bar" |
| 18 | + } |
| 19 | + assertEqual |
| 20 | + { actual: relative "/data/orandea/test/aaa" "/data/orandea/impl/bbb" |
| 21 | + , expected: normalize "../../impl/bbb" |
| 22 | + } |
| 23 | + assertEqual |
| 24 | + { actual: dirname "/foo/bar/baz/asdf/quux" |
| 25 | + , expected: normalize "/foo/bar/baz/asdf" |
| 26 | + } |
| 27 | + assertEqual |
| 28 | + { actual: basename "/foo/bar/baz/asdf/quux.html" |
| 29 | + , expected: "quux.html" |
| 30 | + } |
| 31 | + assertEqual |
| 32 | + { actual: basenameWithoutExt "/foo/bar/baz/asdf/quux.html" ".html" |
| 33 | + , expected: "quux" |
| 34 | + } |
| 35 | + assertEqual |
| 36 | + { actual: basenameWithoutExt "/foo/bar/baz/asdf/quux.txt" ".html" |
| 37 | + , expected: "quux.txt" |
| 38 | + } |
| 39 | + assertEqual |
| 40 | + { actual: extname "index.html" |
| 41 | + , expected: ".html" |
| 42 | + } |
| 43 | + assertEqual |
| 44 | + { actual: extname "index.coffee.md" |
| 45 | + , expected: ".md" |
| 46 | + } |
| 47 | + assertEqual |
| 48 | + { actual: extname "index." |
| 49 | + , expected: "." |
| 50 | + } |
| 51 | + assertEqual |
| 52 | + { actual: extname "index" |
| 53 | + , expected: "" |
| 54 | + } |
| 55 | + assertEqual |
| 56 | + { actual: sep |
| 57 | + , expected: normalize "/" |
| 58 | + } |
22 | 59 | assert $ delimiter == ";" || delimiter == ":"
|
23 | 60 |
|
24 | 61 | let path = parse "/home/user/file.js"
|
25 |
| - assert $ path.root == "/" |
26 |
| - assert $ path.dir == "/home/user" |
27 |
| - assert $ path.base == "file.js" |
28 |
| - assert $ path.ext == ".js" |
29 |
| - assert $ path.name == "file" |
| 62 | + assertEqual |
| 63 | + { actual: path.root |
| 64 | + , expected: "/" |
| 65 | + } |
| 66 | + assertEqual |
| 67 | + { actual: path.dir |
| 68 | + , expected: "/home/user" |
| 69 | + } |
| 70 | + assertEqual |
| 71 | + { actual: path.base |
| 72 | + , expected: "file.js" |
| 73 | + } |
| 74 | + assertEqual |
| 75 | + { actual: path.ext |
| 76 | + , expected: ".js" |
| 77 | + } |
| 78 | + assertEqual |
| 79 | + { actual: path.name |
| 80 | + , expected: "file" |
| 81 | + } |
0 commit comments