You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
948 B

4 years ago
  1. // Copyright 2014 Simon Lydell
  2. // X11 (“MIT”) Licensed. (See LICENSE.)
  3. var path = require("path")
  4. var assert = require("assert")
  5. var urix = require("../")
  6. "use stict"
  7. function test(testPath, expected) {
  8. path.sep = "\\"
  9. assert.equal(urix(testPath), expected)
  10. path.sep = "/"
  11. assert.equal(urix(testPath), testPath)
  12. }
  13. describe("urix", function() {
  14. it("is a function", function() {
  15. assert.equal(typeof urix, "function")
  16. })
  17. it("converts backslashes to slashes", function() {
  18. test("a\\b\\c", "a/b/c")
  19. test("\\a\\b\\c", "/a/b/c")
  20. test("a/b\\c", "a/b/c")
  21. test("\\\\a\\\\\\b///c", "//a///b///c")
  22. })
  23. it("changes the drive letter to a slash", function() {
  24. test("c:\\a", "/a")
  25. test("C:\\a", "/a")
  26. test("z:\\a", "/a")
  27. test("c:a", "/a")
  28. test("c:/a", "/a")
  29. test("c:\\\\a", "//a")
  30. test("c://a", "//a")
  31. test("c:\\//a", "///a")
  32. })
  33. })