GSI - Employe Self Service Mobile
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.

60 lines
2.0 KiB

2 months ago
  1. var tape = require("tape");
  2. var path = require("..");
  3. tape.test("path", function(test) {
  4. test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");
  5. test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");
  6. test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");
  7. test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");
  8. var paths = [
  9. {
  10. actual: "X:\\some\\..\\.\\path\\\\file.js",
  11. normal: "X:/path/file.js",
  12. resolve: {
  13. origin: "X:/path/origin.js",
  14. expected: "X:/path/file.js"
  15. }
  16. }, {
  17. actual: "some\\..\\.\\path\\\\file.js",
  18. normal: "path/file.js",
  19. resolve: {
  20. origin: "X:/path/origin.js",
  21. expected: "X:/path/path/file.js"
  22. }
  23. }, {
  24. actual: "/some/.././path//file.js",
  25. normal: "/path/file.js",
  26. resolve: {
  27. origin: "/path/origin.js",
  28. expected: "/path/file.js"
  29. }
  30. }, {
  31. actual: "some/.././path//file.js",
  32. normal: "path/file.js",
  33. resolve: {
  34. origin: "",
  35. expected: "path/file.js"
  36. }
  37. }, {
  38. actual: ".././path//file.js",
  39. normal: "../path/file.js"
  40. }, {
  41. actual: "/.././path//file.js",
  42. normal: "/path/file.js"
  43. }
  44. ];
  45. paths.forEach(function(p) {
  46. test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);
  47. if (p.resolve) {
  48. test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);
  49. test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");
  50. }
  51. });
  52. test.end();
  53. });