UNPKG

ffbt

Version:

Build a Typescript app without pain

70 lines (69 loc) 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("./index"); describe("Project Config", () => { test("use default profile by default", () => { const projectConfig = new index_1.ProjectConfig(""); expect(projectConfig.env._name).toBe("default"); }); test("applies default values to the config", () => { const aliases = { "key": "value" }; const projectConfig = new index_1.ProjectConfig("", { environments: { default: { aliases } }, }); projectConfig.setCurrentEnvironmentName("default"); expect(projectConfig.env.aliases).toEqual(aliases); }); test("deep merge default and custom settings", () => { const defaultConfig = { environments: { default: { a: { value: 1, value2: 2, }, a1: { value: 3, } } } }; const customConfig = { environments: { default: { a: { value: "newValue", } }, } }; const projectConfig = new index_1.ProjectConfig("", customConfig, defaultConfig); expect(projectConfig.env).toMatchObject({ "a": { "value": "newValue", "value2": 2 }, "a1": { "value": 3 }, }); }); test("converts [], null in noParse to undefined (required by webpack)", () => { const configWithArrayNoParse = new index_1.ProjectConfig("", { noParse: [] }); expect(configWithArrayNoParse.env.noParse).toBeUndefined(); const configWithNullNoParse = new index_1.ProjectConfig("", { noParse: null }); expect(configWithNullNoParse.env.noParse).toBeUndefined(); }); test("shallow override environment settings", () => { const projectConfig = new index_1.ProjectConfig(""); const originalEnvValue = projectConfig.env.buildVersion; projectConfig.overrideEnvironmentSettings({ buildVersion: originalEnvValue + "1", }); expect(projectConfig.env.buildVersion).toBe(originalEnvValue + "1"); }); });