UNPKG

@unibeautify/beautifier-js-beautify

Version:
73 lines 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const unibeautify_1 = require("unibeautify"); const src_1 = require("../../src"); test("should successfully beautify JSX text", () => { const unibeautify = unibeautify_1.newUnibeautify(); unibeautify.loadBeautifier(src_1.default); const text = `export default class TestCase extends React.Component { render() { return ( <div className={this.props.className} someAttr> <div>Smth</div> </div> ); } }`; const beautifierResult = `export default class TestCase extends React.Component { render() { return (<div className={this.props.className} someAttr> <div>Smth</div> </div>); } }`; return unibeautify .beautify({ languageName: "JSX", options: { JSX: { indent_char: " ", indent_size: 2 } }, text }) .then(results => { expect(results).toBe(beautifierResult); }); }); test("should successfully beautify JSX text with wrap_line_length", () => { const unibeautify = unibeautify_1.newUnibeautify(); unibeautify.loadBeautifier(src_1.default); const text = `export default class TestCase extends React.Component { render() { return ( <div className={this.props.className} someAttr> <div>Smth</div> </div> ); } }`; const beautifierResult = `export default class TestCase extends React .Component { render() { return ( <div className={this.props.className} someAttr> <div>Smth</div> </div> ); } }`; return unibeautify .beautify({ languageName: "JSX", options: { JSX: { indent_char: " ", indent_size: 2, wrap_line_length: 40 } }, text }) .then(results => { expect(results).toBe(beautifierResult); }); }); //# sourceMappingURL=JSX.spec.js.map