UNPKG

@unibeautify/beautifier-js-beautify

Version:
38 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const unibeautify_1 = require("unibeautify"); const src_1 = require("../../src"); // testWithIndentSize(0, true); testWithIndentSize(1, true); // testWithIndentSize(2, true); // testWithIndentSize(0, false); testWithIndentSize(2, false); testWithIndentSize(4, false); function testWithIndentSize(indentSize, useTabs = false) { test(`should successfully beautify JavaScript text with indent_size=${indentSize} using ${useTabs ? "tabs" : "spaces"}`, () => { const unibeautify = unibeautify_1.newUnibeautify(); unibeautify.loadBeautifier(src_1.default); const indentChar = useTabs ? "\t" : " "; const indentStyle = useTabs ? "tab" : "space"; const indentation = useTabs ? "\t" : indentChar.repeat(indentSize); const text = `function test(n){return n+1;}`; const beautifierResult = `function test(n) { ${indentation}return n + 1; }`; return unibeautify .beautify({ languageName: "JavaScript", options: { JavaScript: { indent_style: indentStyle, indent_size: indentSize, } }, text }) .then(results => { expect(results).toBe(beautifierResult); }); }); } //# sourceMappingURL=indentSize.spec.js.map