mapping-entry.test.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var mapping_entry_1 = require("../mapping-entry");
  4. var path_1 = require("path");
  5. describe("mapping-entry", function () {
  6. it("should change to absolute paths and sort in longest prefix order", function () {
  7. var result = (0, mapping_entry_1.getAbsoluteMappingEntries)("/absolute/base/url", {
  8. "*": ["/foo1", "/foo2"],
  9. "longest/pre/fix/*": ["/foo2/bar"],
  10. "pre/fix/*": ["/foo3"],
  11. }, true);
  12. // assert.deepEqual(result, [
  13. // {
  14. // pattern: "longest/pre/fix/*",
  15. // paths: [join("/absolute", "base", "url", "foo2", "bar")],
  16. // },
  17. // {
  18. // pattern: "pre/fix/*",
  19. // paths: [join("/absolute", "base", "url", "foo3")],
  20. // },
  21. // {
  22. // pattern: "*",
  23. // paths: [
  24. // join("/absolute", "base", "url", "foo1"),
  25. // join("/absolute", "base", "url", "foo2"),
  26. // ],
  27. // },
  28. // ]);
  29. expect(result).toEqual([
  30. {
  31. pattern: "longest/pre/fix/*",
  32. paths: [(0, path_1.join)("/absolute", "base", "url", "foo2", "bar")],
  33. },
  34. {
  35. pattern: "pre/fix/*",
  36. paths: [(0, path_1.join)("/absolute", "base", "url", "foo3")],
  37. },
  38. {
  39. pattern: "*",
  40. paths: [
  41. (0, path_1.join)("/absolute", "base", "url", "foo1"),
  42. (0, path_1.join)("/absolute", "base", "url", "foo2"),
  43. ],
  44. },
  45. ]);
  46. });
  47. it("should should add a match-all pattern when requested", function () {
  48. var result = (0, mapping_entry_1.getAbsoluteMappingEntries)("/absolute/base/url", {}, true);
  49. // assert.deepEqual(result, [
  50. // {
  51. // pattern: "*",
  52. // paths: [join("/absolute", "base", "url", "*")],
  53. // },
  54. // ]);
  55. expect(result).toEqual([
  56. {
  57. pattern: "*",
  58. paths: [(0, path_1.join)("/absolute", "base", "url", "*")],
  59. },
  60. ]);
  61. result = (0, mapping_entry_1.getAbsoluteMappingEntries)("/absolute/base/url", {}, false);
  62. // assert.deepEqual(result, []);
  63. expect(result).toEqual([]);
  64. });
  65. });
  66. //# sourceMappingURL=mapping-entry.test.js.map