source: frontend/node_modules/tsconfig-paths/lib/__tests__/config-loader.test.js

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

Fix frontend appearance

  • Property mode set to 100644
File size: 3.9 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var config_loader_1 = require("../config-loader");
4var path_1 = require("path");
5describe("config-loader", function () {
6 it("should use explicitParams when set", function () {
7 var result = (0, config_loader_1.configLoader)({
8 explicitParams: {
9 baseUrl: "/foo/bar",
10 paths: {
11 asd: ["asd"],
12 },
13 },
14 cwd: "/baz",
15 });
16 var successResult = result;
17 // assert.equal(successResult.resultType, "success");
18 // assert.equal(successResult.absoluteBaseUrl, "/foo/bar");
19 // assert.equal(successResult.paths["asd"][0], "asd");
20 expect(successResult.resultType).toBe("success");
21 expect(successResult.absoluteBaseUrl).toBe("/foo/bar");
22 expect(successResult.paths["asd"][0]).toBe("asd");
23 });
24 it("should use explicitParams when set and add cwd when path is relative", function () {
25 var result = (0, config_loader_1.configLoader)({
26 explicitParams: {
27 baseUrl: "bar/",
28 paths: {
29 asd: ["asd"],
30 },
31 },
32 cwd: "/baz",
33 });
34 var successResult = result;
35 // assert.equal(successResult.resultType, "success");
36 // assert.equal(successResult.absoluteBaseUrl, join("/baz", "bar/"));
37 expect(successResult.resultType).toBe("success");
38 expect(successResult.absoluteBaseUrl).toBe((0, path_1.join)("/baz", "bar/"));
39 });
40 it("should fallback to tsConfigLoader when explicitParams is not set", function () {
41 var result = (0, config_loader_1.configLoader)({
42 explicitParams: undefined,
43 cwd: "/baz",
44 // tslint:disable-next-line:no-any
45 tsConfigLoader: function (_) { return ({
46 tsConfigPath: "/baz/tsconfig.json",
47 baseUrl: "./src",
48 paths: {},
49 }); },
50 });
51 var successResult = result;
52 // assert.equal(successResult.resultType, "success");
53 // assert.equal(successResult.absoluteBaseUrl, join("/baz", "src"));
54 expect(successResult.resultType).toBe("success");
55 expect(successResult.absoluteBaseUrl).toBe((0, path_1.join)("/baz", "src"));
56 });
57 it("should show an error message when baseUrl is missing", function () {
58 var result = (0, config_loader_1.configLoader)({
59 explicitParams: undefined,
60 cwd: "/baz",
61 // tslint:disable-next-line:no-any
62 tsConfigLoader: function (_) { return ({
63 tsConfigPath: "/baz/tsconfig.json",
64 baseUrl: undefined,
65 paths: {},
66 }); },
67 });
68 var failResult = result;
69 // assert.equal(failResult.resultType, "failed");
70 // assert.isTrue(failResult.message.indexOf("baseUrl") > -1);
71 expect(failResult.resultType).toBe("failed");
72 expect(failResult.message.indexOf("baseUrl") > -1).toBeTruthy();
73 });
74 it("should presume cwd to be a tsconfig file when loadConfig is called with absolute path to tsconfig.json", function () {
75 // using tsconfig-named.json to ensure that future changes to fix
76 // https://github.com/dividab/tsconfig-paths/issues/31
77 // do not pass this test case just because of a directory walk looking
78 // for tsconfig.json
79 var configFile = (0, path_1.join)(__dirname, "tsconfig-named.json");
80 var result = (0, config_loader_1.loadConfig)(configFile);
81 var successResult = result;
82 // assert.equal(successResult.resultType, "success");
83 // assert.equal(successResult.configFileAbsolutePath, configFile);
84 expect(successResult.resultType).toBe("success");
85 expect(successResult.configFileAbsolutePath).toBe(configFile);
86 });
87});
88//# sourceMappingURL=config-loader.test.js.map
Note: See TracBrowser for help on using the repository browser.