blob: b84b8f3eeb004522cb01ae134ceffbfed2ef7113 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001// Copyright 2014 Simon Lydell
2// X11 (“MIT”) Licensed. (See LICENSE.)
3
4var path = require("path")
5var assert = require("assert")
6var urix = require("../")
7
8"use stict"
9
10function test(testPath, expected) {
11 path.sep = "\\"
12 assert.equal(urix(testPath), expected)
13 path.sep = "/"
14 assert.equal(urix(testPath), testPath)
15}
16
17describe("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})