--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
185
node_modules/js-beautify/test/data/css.js
generated
vendored
Normal file
185
node_modules/js-beautify/test/data/css.js
generated
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
exports.test_data = {
|
||||
default_options: [
|
||||
{ name: "indent_size", value: "1" },
|
||||
{ name: "indent_char", value: "'\\t'" },
|
||||
{ name: "selector_separator_newline", value: "true" },
|
||||
{ name: "end_with_newline", value: "false" },
|
||||
{ name: "newline_between_rules", value: "false"},
|
||||
],
|
||||
groups: [{
|
||||
name: "End With Newline",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "end_with_newline", value: "true" }
|
||||
],
|
||||
eof: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "end_with_newline", value: "false" }
|
||||
],
|
||||
eof: ''
|
||||
}
|
||||
],
|
||||
tests: [
|
||||
{ fragment: true, input: '', output: '{{eof}}' },
|
||||
{ fragment: true, input: ' .tabs{}', output: ' .tabs {}{{eof}}' },
|
||||
{ fragment: true, input: ' \n\n.tabs{}\n\n\n\n', output: ' .tabs {}{{eof}}' },
|
||||
{ fragment: true, input: '\n', output: '{{eof}}' }
|
||||
],
|
||||
}, {
|
||||
name: "Empty braces",
|
||||
description: "",
|
||||
tests: [
|
||||
{ input: '.tabs{}', output: '.tabs {}' },
|
||||
{ input: '.tabs { }', output: '.tabs {}' },
|
||||
{ input: '.tabs { }', output: '.tabs {}' },
|
||||
// When we support preserving newlines this will need to change
|
||||
{ input: '.tabs \n{\n \n }', output: '.tabs {}' }
|
||||
],
|
||||
}, {
|
||||
name: "",
|
||||
description: "",
|
||||
tests: [
|
||||
{
|
||||
input: '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity = 90);\n}',
|
||||
output: '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity=90);\n}'
|
||||
},
|
||||
],
|
||||
}, {
|
||||
name: 'Selector Separator',
|
||||
description: '',
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: 'selector_separator_newline', value: 'false' },
|
||||
{ name: 'selector_separator', value: '" "' }
|
||||
],
|
||||
separator: ' ',
|
||||
separator1: ' '
|
||||
}, {
|
||||
options: [
|
||||
{ name: 'selector_separator_newline', value: 'false' },
|
||||
{ name: 'selector_separator', value: '" "' }
|
||||
],
|
||||
// BUG: #713
|
||||
separator: ' ',
|
||||
separator1: ' '
|
||||
}, {
|
||||
options: [
|
||||
{ name: 'selector_separator_newline', value: 'true' },
|
||||
{ name: 'selector_separator', value: '" "' }
|
||||
],
|
||||
separator: '\\n',
|
||||
separator1: '\\n\\t'
|
||||
}, {
|
||||
options: [
|
||||
{ name: 'selector_separator_newline', value: 'true' },
|
||||
{ name: 'selector_separator', value: '" "' }
|
||||
],
|
||||
separator: '\\n',
|
||||
separator1: '\\n\\t'
|
||||
}
|
||||
],
|
||||
tests: [
|
||||
{ input: '#bla, #foo{color:green}', output: '#bla,{{separator}}#foo {\n\tcolor: green\n}'},
|
||||
{ input: '@media print {.tab{}}', output: '@media print {\n\t.tab {}\n}'},
|
||||
{ input: '@media print {.tab,.bat{}}', output: '@media print {\n\t.tab,{{separator1}}.bat {}\n}'},
|
||||
{ input: '#bla, #foo{color:black}', output: '#bla,{{separator}}#foo {\n\tcolor: black\n}'},
|
||||
{ input: 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}',
|
||||
output: 'a:first-child,{{separator}}a:first-child {\n\tcolor: red;\n\tdiv:first-child,{{separator1}}div:hover {\n\t\tcolor: black;\n\t}\n}'}
|
||||
]
|
||||
}, {
|
||||
name: "Newline Between Rules",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "newline_between_rules", value: "true" }
|
||||
],
|
||||
separator: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "newline_between_rules", value: "false" }
|
||||
],
|
||||
separator: ''
|
||||
}
|
||||
],
|
||||
tests: [
|
||||
{ input: '.div {}\n.span {}', output: '.div {}\n{{separator}}.span {}'},
|
||||
{ input: '.div{}\n \n.span{}', output: '.div {}\n{{separator}}.span {}'},
|
||||
{ input: '.div {} \n \n.span { } \n', output: '.div {}\n{{separator}}.span {}'},
|
||||
{ input: '.div {\n \n} \n .span {\n } ', output: '.div {}\n{{separator}}.span {}'},
|
||||
{ input: '.selector1 {\n\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n}\n.div{height:15px;}', output: '.selector1 {\n\tmargin: 0;\n\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n}\n{{separator}}.div {\n\theight: 15px;\n}'},
|
||||
{ input: '.tabs{width:10px;//end of line comment\nheight:10px;//another\n}\n.div{height:15px;}', output: '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px; //another\n}\n{{separator}}.div {\n\theight: 15px;\n}'},
|
||||
{ input: '#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div{height:15px;}', output: '#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n{{separator}}.div {\n\theight: 15px;\n}'},
|
||||
{ input: '@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div{height:15px;}', output: '@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n{{separator}}.div {\n\theight: 15px;\n}'},
|
||||
{ input: '@font-face {\n\tfont-family: "Bitstream Vera Serif Bold";\n\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n}\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: "Helvetica Neue"\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}', output: '@font-face {\n\tfont-family: "Bitstream Vera Serif Bold";\n\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n}\n{{separator}}@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: "Helvetica Neue"\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}'},
|
||||
{ input: 'a:first-child{color:red;div:first-child{color:black;}}\n.div{height:15px;}', output: 'a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}\n{{separator}}.div {\n\theight: 15px;\n}'},
|
||||
{ input: 'a:first-child{color:red;div:not(.peq){color:black;}}\n.div{height:15px;}', output: 'a:first-child {\n\tcolor: red;\n\tdiv:not(.peq) {\n\t\tcolor: black;\n\t}\n}\n{{separator}}.div {\n\theight: 15px;\n}'},
|
||||
],
|
||||
}, {
|
||||
name: "Functions braces",
|
||||
description: "",
|
||||
tests: [
|
||||
{ input: '.tabs(){}', output: '.tabs() {}' },
|
||||
{ input: '.tabs (){}', output: '.tabs () {}' },
|
||||
{ input: '.tabs (pa, pa(1,2)), .cols { }', output: '.tabs (pa, pa(1, 2)),\n.cols {}' },
|
||||
{ input: '.tabs(pa, pa(1,2)), .cols { }', output: '.tabs(pa, pa(1, 2)),\n.cols {}' },
|
||||
{ input: '.tabs ( ) { }', output: '.tabs () {}' },
|
||||
{ input: '.tabs( ) { }', output: '.tabs() {}' },
|
||||
{ input: '.tabs (t, t2) \n{\n key: val(p1 ,p2); \n }', output: '.tabs (t, t2) {\n\tkey: val(p1, p2);\n}' },
|
||||
{ input: '.box-shadow(@shadow: 0 1px 3px rgba(0, 0, 0, .25)) {\n\t-webkit-box-shadow: @shadow;\n\t-moz-box-shadow: @shadow;\n\tbox-shadow: @shadow;\n}' }
|
||||
],
|
||||
}, {
|
||||
name: "Comments",
|
||||
description: "",
|
||||
tests: [
|
||||
{ unchanged: '/* test */' },
|
||||
{ input: '.tabs{/* test */}', output: '.tabs {\n\t/* test */\n}' },
|
||||
{ input: '.tabs{/* test */}', output: '.tabs {\n\t/* test */\n}' },
|
||||
{ input: '/* header */.tabs {}', output: '/* header */\n\n.tabs {}' },
|
||||
{ input: '.tabs {\n/* non-header */\nwidth:10px;}', output: '.tabs {\n\t/* non-header */\n\twidth: 10px;\n}' },
|
||||
{ unchanged: '/* header' },
|
||||
{ unchanged: '// comment' },
|
||||
{ input: '.selector1 {\n\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n}',
|
||||
output: '.selector1 {\n\tmargin: 0;\n\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n}'},
|
||||
|
||||
{ comment: "single line comment support (less/sass)",
|
||||
input:'.tabs{\n// comment\nwidth:10px;\n}', output: '.tabs {\n\t// comment\n\twidth: 10px;\n}' },
|
||||
{ input: '.tabs{// comment\nwidth:10px;\n}', output: '.tabs {\n\t// comment\n\twidth: 10px;\n}' },
|
||||
{ input: '//comment\n.tabs{width:10px;}', output: '//comment\n.tabs {\n\twidth: 10px;\n}' },
|
||||
{ input: '.tabs{//comment\n//2nd single line comment\nwidth:10px;}', output: '.tabs {\n\t//comment\n\t//2nd single line comment\n\twidth: 10px;\n}' },
|
||||
{ input: '.tabs{width:10px;//end of line comment\n}', output: '.tabs {\n\twidth: 10px; //end of line comment\n}' },
|
||||
{ input: '.tabs{width:10px;//end of line comment\nheight:10px;}', output: '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px;\n}' },
|
||||
{ input: '.tabs{width:10px;//end of line comment\nheight:10px;//another\n}', output: '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px; //another\n}' }
|
||||
],
|
||||
}, {
|
||||
name: "Psuedo-classes vs Variables",
|
||||
description: "",
|
||||
tests: [
|
||||
{ unchanged: '@page :first {}' },
|
||||
{ comment: "Assume the colon goes with the @name. If we're in LESS, this is required regardless of the at-string.",
|
||||
input: '@page:first {}',
|
||||
output: '@page: first {}' },
|
||||
{ unchanged: '@page: first {}' }
|
||||
],
|
||||
}, {
|
||||
name: "SASS/SCSS",
|
||||
description: "",
|
||||
tests: [
|
||||
{ comment: "Basic Interpolation",
|
||||
unchanged: 'p {\n\t$font-size: 12px;\n\t$line-height: 30px;\n\tfont: #{$font-size}/#{$line-height};\n}'},
|
||||
{ unchanged: 'p.#{$name} {}' },
|
||||
{ unchanged: [
|
||||
'@mixin itemPropertiesCoverItem($items, $margin) {',
|
||||
'\twidth: calc((100% - ((#{$items} - 1) * #{$margin}rem)) / #{$items});',
|
||||
'\tmargin: 1.6rem #{$margin}rem 1.6rem 0;',
|
||||
'}'
|
||||
]}
|
||||
],
|
||||
}, {
|
||||
|
||||
}]
|
||||
}
|
||||
473
node_modules/js-beautify/test/data/html.js
generated
vendored
Normal file
473
node_modules/js-beautify/test/data/html.js
generated
vendored
Normal file
|
|
@ -0,0 +1,473 @@
|
|||
exports.test_data = {
|
||||
default_options: [
|
||||
{ name: "indent_size", value: "4" },
|
||||
{ name: "indent_char", value: "' '" },
|
||||
{ name: "indent_with_tabs", value: "false" },
|
||||
{ name: "preserve_newlines", value: "true" },
|
||||
{ name: "jslint_happy", value: "false" },
|
||||
{ name: "keep_array_indentation", value: "false" },
|
||||
{ name: "brace_style", value: "'collapse'" },
|
||||
{ name: "extra_liners", value: "['html', 'head', '/html']" }
|
||||
],
|
||||
groups: [{
|
||||
name: "End With Newline",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "end_with_newline", value: "true" }
|
||||
],
|
||||
eof: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "end_with_newline", value: "false" }
|
||||
],
|
||||
eof: ''
|
||||
}
|
||||
|
||||
],
|
||||
tests: [
|
||||
{ fragment: true, input: '', output: '{{eof}}' },
|
||||
{ fragment: true, input: '<div></div>', output: '<div></div>{{eof}}' },
|
||||
// { fragment: true, input: ' \n\n<div></div>\n\n\n\n', output: ' <div></div>{{eof}}' },
|
||||
{ fragment: true, input: '\n', output: '{{eof}}' }
|
||||
],
|
||||
}, {
|
||||
name: "Custom Extra Liners (empty)",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "extra_liners", value: "[]" }
|
||||
]
|
||||
},
|
||||
|
||||
],
|
||||
tests: [
|
||||
{
|
||||
fragment: true,
|
||||
input: '<html><head><meta></head><body><div><p>x</p></div></body></html>',
|
||||
output: '<html>\n<head>\n <meta>\n</head>\n<body>\n <div>\n <p>x</p>\n </div>\n</body>\n</html>'
|
||||
}
|
||||
],
|
||||
}, {
|
||||
name: "Custom Extra Liners (default)",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "extra_liners", value: "null" }
|
||||
]
|
||||
},
|
||||
|
||||
],
|
||||
tests: [
|
||||
{
|
||||
fragment: true,
|
||||
input: '<html><head></head><body></body></html>',
|
||||
output: '<html>\n\n<head></head>\n\n<body></body>\n\n</html>'
|
||||
}
|
||||
],
|
||||
}, {
|
||||
name: "Custom Extra Liners (p, string)",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "extra_liners", value: "'p,/p'" }
|
||||
]
|
||||
},
|
||||
|
||||
],
|
||||
tests: [
|
||||
{
|
||||
fragment: true,
|
||||
input: '<html><head><meta></head><body><div><p>x</p></div></body></html>',
|
||||
output: '<html>\n<head>\n <meta>\n</head>\n<body>\n <div>\n\n <p>x\n\n </p>\n </div>\n</body>\n</html>'
|
||||
}
|
||||
],
|
||||
}, {
|
||||
name: "Custom Extra Liners (p)",
|
||||
description: "",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "extra_liners", value: "['p', '/p']" }
|
||||
]
|
||||
},
|
||||
|
||||
],
|
||||
tests: [
|
||||
{
|
||||
fragment: true,
|
||||
input: '<html><head><meta></head><body><div><p>x</p></div></body></html>',
|
||||
output: '<html>\n<head>\n <meta>\n</head>\n<body>\n <div>\n\n <p>x\n\n </p>\n </div>\n</body>\n</html>'
|
||||
}
|
||||
],
|
||||
}, {
|
||||
name: "Attribute Wrap",
|
||||
description: "Wraps attributes inside of html tags",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "wrap_attributes", value: "'force'" }
|
||||
],
|
||||
eof: '\\n',
|
||||
indent_attr: ' ',
|
||||
over80: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "wrap_attributes", value: "'force'" },
|
||||
{ name: "wrap_line_length", value: "80" }
|
||||
],
|
||||
eof: '\\n',
|
||||
indent_attr: ' ',
|
||||
over80: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "wrap_attributes", value: "'force'" },
|
||||
{ name: "wrap_attributes_indent_size", value: "8" },
|
||||
],
|
||||
eof: '\\n',
|
||||
indent_attr: ' ',
|
||||
over80: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "wrap_attributes", value: "'auto'" },
|
||||
{ name: "wrap_line_length", value: "80" }
|
||||
],
|
||||
eof: ' ',
|
||||
indent_attr: '',
|
||||
over80: '\\n'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "wrap_attributes", value: "'auto'" },
|
||||
{ name: "wrap_line_length", value: "0" }
|
||||
],
|
||||
eof: ' ',
|
||||
indent_attr: '',
|
||||
over80: ' '
|
||||
}
|
||||
],
|
||||
tests: [
|
||||
{
|
||||
fragment: true,
|
||||
input: '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
|
||||
output: '<div attr0{{eof}}{{indent_attr}}attr1="123"{{eof}}{{indent_attr}}data-attr2="hello t here">This is some text</div>'
|
||||
},
|
||||
{
|
||||
fragment: true,
|
||||
input: '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
|
||||
output: '<div lookatthissuperduperlongattributenamewhoahcrazy0="true"{{eof}}{{indent_attr}}attr0{{eof}}{{indent_attr}}attr1="123"{{eof}}{{indent_attr}}data-attr2="hello t here"{{over80}}{{indent_attr}}heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>'
|
||||
},
|
||||
{
|
||||
fragment: true,
|
||||
input: '<img attr0 attr1="123" data-attr2="hello t here"/>',
|
||||
output: '<img attr0{{eof}}{{indent_attr}}attr1="123"{{eof}}{{indent_attr}}data-attr2="hello t here" />'
|
||||
}
|
||||
]
|
||||
}, {
|
||||
name: "Handlebars Indenting Off",
|
||||
description: "Test handlebar behavior when indenting is off",
|
||||
template: "^^^ $$$",
|
||||
options: [
|
||||
{ name: "indent_handlebars", value: "false" }
|
||||
],
|
||||
tests: [
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'{{#if 0}}\n' +
|
||||
' <div>\n' +
|
||||
' </div>\n' +
|
||||
'{{/if}}',
|
||||
output:
|
||||
'{{#if 0}}\n' +
|
||||
'<div>\n' +
|
||||
'</div>\n' +
|
||||
'{{/if}}' },
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'<div>\n' +
|
||||
'{{#each thing}}\n' +
|
||||
' {{name}}\n' +
|
||||
'{{/each}}\n' +
|
||||
'</div>',
|
||||
output:
|
||||
'<div>\n' +
|
||||
' {{#each thing}} {{name}} {{/each}}\n' +
|
||||
'</div>'}
|
||||
|
||||
]
|
||||
}, {
|
||||
name: "Handlebars Indenting On",
|
||||
description: "Test handlebar formatting",
|
||||
template: "^^^ $$$",
|
||||
matrix: [
|
||||
{
|
||||
options: [
|
||||
{ name: "indent_handlebars", value: "true" }
|
||||
],
|
||||
content: '{{field}}'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "indent_handlebars", value: "true" }
|
||||
],
|
||||
content: '{{! comment}}'
|
||||
}, {
|
||||
options: [
|
||||
{ name: "indent_handlebars", value: "true" }
|
||||
],
|
||||
content: '{pre{{field1}} {{field2}} {{field3}}post'
|
||||
}
|
||||
, {
|
||||
options: [
|
||||
{ name: "indent_handlebars", value: "true" }
|
||||
],
|
||||
content: '{{! \\n mult-line\\ncomment \\n with spacing\\n}}'
|
||||
}
|
||||
],
|
||||
tests: [
|
||||
{ fragment: true, unchanged: '{{page-title}}' },
|
||||
{ fragment: true, unchanged: '{{#if 0}}{{/if}}' },
|
||||
{ fragment: true, unchanged: '{{#if 0}}^^^content$$${{/if}}' },
|
||||
{ fragment: true, unchanged: '{{#if 0}}\n{{/if}}' },
|
||||
{ fragment: true,
|
||||
input_: '{{#if words}}{{/if}}',
|
||||
output: '{{#if words}}{{/if}}' },
|
||||
{ fragment: true,
|
||||
input_: '{{#if words}}^^^content$$${{/if}}',
|
||||
output: '{{#if words}}^^^content$$${{/if}}' },
|
||||
{ fragment: true,
|
||||
input_: '{{#if words}}^^^content$$${{/if}}',
|
||||
output: '{{#if words}}^^^content$$${{/if}}' },
|
||||
{ fragment: true,
|
||||
unchanged:
|
||||
'{{#if 1}}\n' +
|
||||
' <div>\n' +
|
||||
' </div>\n' +
|
||||
'{{/if}}' },
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'{{#if 1}}\n' +
|
||||
'<div>\n' +
|
||||
'</div>\n' +
|
||||
'{{/if}}',
|
||||
output:
|
||||
'{{#if 1}}\n' +
|
||||
' <div>\n' +
|
||||
' </div>\n' +
|
||||
'{{/if}}' },
|
||||
{ fragment: true,
|
||||
unchanged:
|
||||
'<div>\n' +
|
||||
' {{#if 1}}\n' +
|
||||
' {{/if}}\n' +
|
||||
'</div>' },
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'<div>\n' +
|
||||
'{{#if 1}}\n' +
|
||||
'{{/if}}\n' +
|
||||
'</div>',
|
||||
output:
|
||||
'<div>\n' +
|
||||
' {{#if 1}}\n' +
|
||||
' {{/if}}\n' +
|
||||
'</div>' },
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'{{#if}}\n' +
|
||||
'{{#each}}\n' +
|
||||
'{{#if}}\n' +
|
||||
'^^^content$$$\n' +
|
||||
'{{/if}}\n' +
|
||||
'{{#if}}\n' +
|
||||
'^^^content$$$\n' +
|
||||
'{{/if}}\n' +
|
||||
'{{/each}}\n' +
|
||||
'{{/if}}',
|
||||
output:
|
||||
'{{#if}}\n' +
|
||||
' {{#each}}\n' +
|
||||
' {{#if}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
' {{/if}}\n' +
|
||||
' {{#if}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
' {{/if}}\n' +
|
||||
' {{/each}}\n' +
|
||||
'{{/if}}' },
|
||||
{ fragment: true, unchanged: '{{#if 1}}\n' +
|
||||
' <div>\n' +
|
||||
' </div>\n' +
|
||||
'{{/if}}' },
|
||||
|
||||
// Test {{else}} aligned with {{#if}} and {{/if}}
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'{{#if 1}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
' {{else}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
'{{/if}}',
|
||||
output:
|
||||
'{{#if 1}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
'{{else}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
'{{/if}}' },
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'{{#if 1}}\n' +
|
||||
' {{else}}\n' +
|
||||
' {{/if}}',
|
||||
output:
|
||||
'{{#if 1}}\n' +
|
||||
'{{else}}\n' +
|
||||
'{{/if}}' },
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'{{#if thing}}\n' +
|
||||
'{{#if otherthing}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
' {{else}}\n' +
|
||||
'^^^content$$$\n' +
|
||||
' {{/if}}\n' +
|
||||
' {{else}}\n'+
|
||||
'^^^content$$$\n' +
|
||||
'{{/if}}',
|
||||
output:
|
||||
'{{#if thing}}\n' +
|
||||
' {{#if otherthing}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
' {{else}}\n' +
|
||||
' ^^^content$$$\n' +
|
||||
' {{/if}}\n' +
|
||||
'{{else}}\n'+
|
||||
' ^^^content$$$\n' +
|
||||
'{{/if}}' },
|
||||
// Test {{}} inside of <> tags, which should be separated by spaces
|
||||
// for readability, unless they are inside a string.
|
||||
{ fragment: true,
|
||||
input_: '<div{{somestyle}}></div>',
|
||||
output: '<div {{somestyle}}></div>' },
|
||||
{ fragment: true,
|
||||
input_: '<div{{#if test}}class="foo"{{/if}}>^^^content$$$</div>',
|
||||
output: '<div {{#if test}} class="foo" {{/if}}>^^^content$$$</div>' },
|
||||
{ fragment: true,
|
||||
input_: '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>^^^content$$$</div>',
|
||||
output: '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>^^^content$$$</div>' },
|
||||
{ fragment: true,
|
||||
input_: '<span{{#if condition}}class="foo"{{/if}}>^^^content$$$</span>',
|
||||
output: '<span {{#if condition}} class="foo" {{/if}}>^^^content$$$</span>' },
|
||||
{ fragment: true,
|
||||
unchanged: '<div unformatted="{{#if}}^^^content$$${{/if}}">^^^content$$$</div>' },
|
||||
{ fragment: true,
|
||||
unchanged: '<div unformatted="{{#if }} ^^^content$$${{/if}}">^^^content$$$</div>' },
|
||||
|
||||
// Quotes found inside of Handlebars expressions inside of quoted
|
||||
// strings themselves should not be considered string delimiters.
|
||||
{ fragment: true,
|
||||
unchanged: '<div class="{{#if thingIs "value"}}^^^content$$${{/if}}"></div>' },
|
||||
{ fragment: true,
|
||||
unchanged: '<div class="{{#if thingIs \\\'value\\\'}}^^^content$$${{/if}}"></div>' },
|
||||
{ fragment: true,
|
||||
unchanged: '<div class=\\\'{{#if thingIs "value"}}^^^content$$${{/if}}\\\'></div>' },
|
||||
{ fragment: true,
|
||||
unchanged: '<div class=\\\'{{#if thingIs \\\'value\\\'}}^^^content$$${{/if}}\\\'></div>' }
|
||||
],
|
||||
}, {
|
||||
name: "Unclosed html elements",
|
||||
description: "Unclosed elements should not indent",
|
||||
options: [],
|
||||
tests: [
|
||||
{ fragment: true, unchanged: '<source>\n<source>' },
|
||||
{ fragment: true, unchanged: '<br>\n<br>' },
|
||||
{ fragment: true, unchanged: '<input>\n<input>' },
|
||||
{ fragment: true, unchanged: '<meta>\n<meta>' },
|
||||
{ fragment: true, unchanged: '<link>\n<link>' }
|
||||
]
|
||||
}, {
|
||||
name: "Unformatted tags",
|
||||
description: "Unformatted tag behavior",
|
||||
options: [],
|
||||
tests: [
|
||||
{ fragment: true, unchanged: '<ol>\n <li>b<pre>c</pre></li>\n</ol>' },
|
||||
{ fragment: true, unchanged: '<ol>\n <li>b<code>c</code></li>\n</ol>' },
|
||||
]
|
||||
}, {
|
||||
name: "Php formatting",
|
||||
description: "Php (<?php ... ?>) treated as comments.",
|
||||
options: [],
|
||||
tests: [
|
||||
{ fragment: true, unchanged: '<h1 class="content-page-header"><?=$view["name"]; ?></h1>' },
|
||||
{ fragment: true, unchanged:
|
||||
[
|
||||
'<?php',
|
||||
'for($i = 1; $i <= 100; $i++;) {',
|
||||
' #count to 100!',
|
||||
' echo($i . "</br>");',
|
||||
'}',
|
||||
'?>'
|
||||
]
|
||||
},
|
||||
]
|
||||
}, {
|
||||
name: "underscore.js formatting",
|
||||
description: "underscore.js templates (<% ... %>) treated as comments.",
|
||||
options: [],
|
||||
tests: [
|
||||
{ fragment: true, unchanged:
|
||||
[
|
||||
'<div class="col-sm-9">',
|
||||
' <textarea id="notes" class="form-control" rows="3">',
|
||||
' <%= notes %>',
|
||||
' </textarea>',
|
||||
'</div>'
|
||||
]
|
||||
},
|
||||
]
|
||||
}, {
|
||||
name: "Indent with tabs",
|
||||
description: "Use one tab instead of several spaces for indentation",
|
||||
template: "^^^ $$$",
|
||||
options: [
|
||||
{ name: "indent_with_tabs", value: "true" }
|
||||
],
|
||||
tests: [
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'<div>\n' +
|
||||
'<div>\n' +
|
||||
'</div>\n' +
|
||||
'</div>',
|
||||
output:
|
||||
'<div>\n' +
|
||||
'\t<div>\n' +
|
||||
'\t</div>\n' +
|
||||
'</div>' }
|
||||
]
|
||||
}, {
|
||||
name: "Indent without tabs",
|
||||
description: "Use several spaces for indentation",
|
||||
template: "^^^ $$$",
|
||||
options: [
|
||||
{ name: "indent_with_tabs", value: "false" }
|
||||
],
|
||||
tests: [
|
||||
{ fragment: true,
|
||||
input_:
|
||||
'<div>\n' +
|
||||
'<div>\n' +
|
||||
'</div>\n' +
|
||||
'</div>',
|
||||
output:
|
||||
'<div>\n' +
|
||||
' <div>\n' +
|
||||
' </div>\n' +
|
||||
'</div>' }
|
||||
]
|
||||
}, {
|
||||
name: "New Test Suite"
|
||||
}],
|
||||
};
|
||||
1572
node_modules/js-beautify/test/data/javascript.js
generated
vendored
Normal file
1572
node_modules/js-beautify/test/data/javascript.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue