source: frontend/node_modules/tsconfig-paths/src/__tests__/mapping-entry.test.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.9 KB
Line 
1import { getAbsoluteMappingEntries } from "../mapping-entry";
2import { join } from "path";
3
4describe("mapping-entry", () => {
5 it("should change to absolute paths and sort in longest prefix order", () => {
6 const result = getAbsoluteMappingEntries(
7 "/absolute/base/url",
8 {
9 "*": ["/foo1", "/foo2"],
10 "longest/pre/fix/*": ["/foo2/bar"],
11 "pre/fix/*": ["/foo3"],
12 },
13 true
14 );
15 // assert.deepEqual(result, [
16 // {
17 // pattern: "longest/pre/fix/*",
18 // paths: [join("/absolute", "base", "url", "foo2", "bar")],
19 // },
20 // {
21 // pattern: "pre/fix/*",
22 // paths: [join("/absolute", "base", "url", "foo3")],
23 // },
24 // {
25 // pattern: "*",
26 // paths: [
27 // join("/absolute", "base", "url", "foo1"),
28 // join("/absolute", "base", "url", "foo2"),
29 // ],
30 // },
31 // ]);
32 expect(result).toEqual([
33 {
34 pattern: "longest/pre/fix/*",
35 paths: [join("/absolute", "base", "url", "foo2", "bar")],
36 },
37 {
38 pattern: "pre/fix/*",
39 paths: [join("/absolute", "base", "url", "foo3")],
40 },
41 {
42 pattern: "*",
43 paths: [
44 join("/absolute", "base", "url", "foo1"),
45 join("/absolute", "base", "url", "foo2"),
46 ],
47 },
48 ]);
49 });
50
51 it("should should add a match-all pattern when requested", () => {
52 let result = getAbsoluteMappingEntries("/absolute/base/url", {}, true);
53 // assert.deepEqual(result, [
54 // {
55 // pattern: "*",
56 // paths: [join("/absolute", "base", "url", "*")],
57 // },
58 // ]);
59 expect(result).toEqual([
60 {
61 pattern: "*",
62 paths: [join("/absolute", "base", "url", "*")],
63 },
64 ]);
65
66 result = getAbsoluteMappingEntries("/absolute/base/url", {}, false);
67 // assert.deepEqual(result, []);
68 expect(result).toEqual([]);
69 });
70});
Note: See TracBrowser for help on using the repository browser.