Projekt

Obecné

Profil

Stáhnout (948 Bajtů) Statistiky
| Větev: | Revize:
1
// Copyright 2014 Simon Lydell
2
// X11 (“MIT”) Licensed. (See LICENSE.)
3

    
4
var path   = require("path")
5
var assert = require("assert")
6
var urix   = require("../")
7

    
8
"use stict"
9

    
10
function test(testPath, expected) {
11
  path.sep = "\\"
12
  assert.equal(urix(testPath), expected)
13
  path.sep = "/"
14
  assert.equal(urix(testPath), testPath)
15
}
16

    
17
describe("urix", function() {
18

    
19
  it("is a function", function() {
20
    assert.equal(typeof urix, "function")
21
  })
22

    
23

    
24
  it("converts backslashes to slashes", function() {
25
    test("a\\b\\c", "a/b/c")
26
    test("\\a\\b\\c", "/a/b/c")
27
    test("a/b\\c", "a/b/c")
28
    test("\\\\a\\\\\\b///c", "//a///b///c")
29
  })
30

    
31

    
32
  it("changes the drive letter to a slash", function() {
33
    test("c:\\a", "/a")
34
    test("C:\\a", "/a")
35
    test("z:\\a", "/a")
36
    test("c:a", "/a")
37
    test("c:/a", "/a")
38
    test("c:\\\\a", "//a")
39
    test("c://a", "//a")
40
    test("c:\\//a", "///a")
41
  })
42

    
43
})
    (1-1/1)