ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
67 lines (65 loc) • 3.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const ts = require("typescript");
const ManipulationSettings_1 = require("./../ManipulationSettings");
describe("IndentationText", () => {
// ensure this enum is correct. It's hard to read all the spaces since string enums can't use computed values
it("should have a tab when has a tab", () => {
chai_1.expect(ManipulationSettings_1.IndentationText.Tab).to.equal("\t");
});
it("should have two spaces when has two", () => {
chai_1.expect(ManipulationSettings_1.IndentationText.TwoSpaces).to.equal(" ".repeat(2));
});
it("should have four spaces when has four", () => {
chai_1.expect(ManipulationSettings_1.IndentationText.FourSpaces).to.equal(" ".repeat(4));
});
it("should have eight spaces when has eight", () => {
chai_1.expect(ManipulationSettings_1.IndentationText.EightSpaces).to.equal(" ".repeat(8));
});
});
describe("ManipulationSettingsContainer", () => {
function checkSettings(settings, settingsSettings) {
chai_1.expect(settings.getStringChar()).to.equal(settingsSettings.stringChar);
chai_1.expect(settings.getNewLineKind()).to.equal(settingsSettings.newLineKind);
chai_1.expect(settings.getIndentationText()).to.equal(settingsSettings.indentationText);
chai_1.expect(settings.getScriptTarget()).to.equal(settingsSettings.scriptTarget);
}
it("should have the correct defaults", () => {
const settings = new ManipulationSettings_1.ManipulationSettingsContainer();
checkSettings(settings, {
stringChar: ManipulationSettings_1.StringChar.DoubleQuote,
newLineKind: ManipulationSettings_1.NewLineKind.LineFeed,
indentationText: ManipulationSettings_1.IndentationText.FourSpaces,
scriptTarget: ts.ScriptTarget.Latest
});
});
it("should set the settings when partially setting them", () => {
const settings = new ManipulationSettings_1.ManipulationSettingsContainer();
settings.set({
stringChar: ManipulationSettings_1.StringChar.SingleQuote
});
checkSettings(settings, {
stringChar: ManipulationSettings_1.StringChar.SingleQuote,
newLineKind: ManipulationSettings_1.NewLineKind.LineFeed,
indentationText: ManipulationSettings_1.IndentationText.FourSpaces,
scriptTarget: ts.ScriptTarget.Latest
});
});
it("should set the settings when setting all of them", () => {
const settings = new ManipulationSettings_1.ManipulationSettingsContainer();
settings.set({
stringChar: ManipulationSettings_1.StringChar.SingleQuote,
newLineKind: ManipulationSettings_1.NewLineKind.CarriageReturnLineFeed,
indentationText: ManipulationSettings_1.IndentationText.EightSpaces,
scriptTarget: ts.ScriptTarget.ES3
});
checkSettings(settings, {
stringChar: ManipulationSettings_1.StringChar.SingleQuote,
newLineKind: ManipulationSettings_1.NewLineKind.CarriageReturnLineFeed,
indentationText: ManipulationSettings_1.IndentationText.EightSpaces,
scriptTarget: ts.ScriptTarget.ES3
});
});
});
//# sourceMappingURL=manipulationSettingsTests.js.map