defaultOptions as a function

This commit is contained in:
Diego Zilioti 2018-10-20 19:01:10 -03:00
parent 7ed4a773be
commit 5e5280010a
4 changed files with 15 additions and 6 deletions

View File

@ -37,4 +37,6 @@ function css_beautify(source_text, options) {
}
module.exports = css_beautify;
module.exports.defaultOptions = new Options();
module.exports.defaultOptions = function() {
return new Options();
};

View File

@ -37,4 +37,6 @@ function style_html(html_source, options, js_beautify, css_beautify) {
}
module.exports = style_html;
module.exports.defaultOptions = new Options();
module.exports.defaultOptions = function() {
return new Options();
};

View File

@ -37,4 +37,6 @@ function js_beautify(js_source_text, options) {
}
module.exports = js_beautify;
module.exports.defaultOptions = new Options();
module.exports.defaultOptions = function() {
return new Options();
};

View File

@ -19,14 +19,17 @@ function test_legacy_names() {
results.expect(typeof beautify.html, 'function');
console.log('Ensure defaultOptions are defined');
results.expect(typeof beautify.js.defaultOptions, 'object');
results.expect(typeof beautify.css.defaultOptions, 'object');
results.expect(typeof beautify.html.defaultOptions, 'object');
results.expect(typeof beautify.js.defaultOptions, 'function');
results.expect(typeof beautify.css.defaultOptions, 'function');
results.expect(typeof beautify.html.defaultOptions, 'function');
console.log('Ensure that legacy import names equal the new ones');
results.expect(beautify.js, beautify.js_beautify);
results.expect(beautify.css, beautify.css_beautify);
results.expect(beautify.html, beautify.html_beautify);
results.expect(beautify.js.defaultOptions, beautify.js_beautify.defaultOptions);
results.expect(beautify.css.defaultOptions, beautify.css_beautify.defaultOptions);
results.expect(beautify.html.defaultOptions, beautify.html_beautify.defaultOptions);
console.log(results.results_raw());
return results.get_exitcode();