ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
25 lines (23 loc) • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const utils_1 = require("./../../utils");
const errors = require("./../../errors");
const testHelpers = require("./../testHelpers");
describe("getCompilerOptionsFromTsConfig", () => {
it("should throw an error when the path doesn't exist", () => {
const host = testHelpers.getFileSystemHostWithFiles([]);
chai_1.expect(() => utils_1.getCompilerOptionsFromTsConfig("tsconfig.json", host))
.to.throw(errors.FileNotFoundError, `File not found: ${utils_1.FileUtils.getStandardizedAbsolutePath("tsconfig.json")}`);
});
it("should throw an error when the file doesn't parse", () => {
const host = testHelpers.getFileSystemHostWithFiles([{ filePath: "tsconfig.json", text: "*&($%0583$#@%" }]);
chai_1.expect(() => utils_1.getCompilerOptionsFromTsConfig("tsconfig.json", host)).to.throw(Error);
});
it("should get the compiler options plus the defaults when providing some", () => {
const host = testHelpers.getFileSystemHostWithFiles([{ filePath: "tsconfig.json", text: `{ "compilerOptions": { "rootDir": "test", "target": "ES5" } }` }]);
const compilerOptions = utils_1.getCompilerOptionsFromTsConfig("tsconfig.json", host);
chai_1.expect(compilerOptions).to.deep.equal({ rootDir: "test", target: 1 });
});
});
//# sourceMappingURL=getCompilerOptionsFromTsConfigTests.js.map