/*
The MIT License (MIT)
Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
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: "Handle inline and block elements differently",
description: "",
matrix: [{}],
tests: [{
fragment: true,
input: '
Block ',
output: [
'',
' Block ',
''
]
}, {
fragment: true,
unchanged: 'Inline '
}]
}, {
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: '
', output: '
{{eof}}' },
// { fragment: true, input: ' \n\n
\n\n\n\n', output: '
{{eof}}' },
{ fragment: true, input: '\n', output: '{{eof}}' }
],
}, {
name: "Custom Extra Liners (empty)",
description: "",
matrix: [{
options: [
{ name: "extra_liners", value: "[]" }
]
},
],
tests: [{
fragment: true,
input: ' ',
output: '\n\n \n\n\n \n\n'
}],
}, {
name: "Custom Extra Liners (default)",
description: "",
matrix: [{
options: [
{ name: "extra_liners", value: "null" }
]
},
],
tests: [{
fragment: true,
input: '',
output: '\n\n\n\n\n\n'
}],
}, {
name: "Custom Extra Liners (p, string)",
description: "",
matrix: [{
options: [
{ name: "extra_liners", value: "'p,/p'" }
]
},
],
tests: [{
fragment: true,
input: ' ',
output: '\n\n \n\n\n \n\n'
}],
}, {
name: "Custom Extra Liners (p)",
description: "",
matrix: [{
options: [
{ name: "extra_liners", value: "['p', '/p']" }
]
},
],
tests: [{
fragment: true,
input: ' ',
output: '\n\n \n\n\n \n\n'
}],
}, {
name: "Tests for script and style types (issue 453, 821)",
description: "Only format recognized script types",
tests: [{
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
}, {
input: '',
output: [
''
]
},
],
}, {
name: "Attribute Wrap alignment with spaces",
description: "Ensure attributes are internally aligned with spaces when the indent_character is set to tab",
matrix: [{
options: [
{ name: "wrap_attributes", value: "'force-aligned'" },
{ name: "indent_with_tabs", value: "true" }
]
}],
tests: [{
fragment: true,
input: '',
output: ''
}]
}, {
name: "Attribute Wrap de-indent",
description: "Tags de-indent when attributes are wrapped",
matrix: [{
options: [
{ name: "wrap_attributes", value: "'force-aligned'" },
{ name: "indent_with_tabs", value: "false" }
]
}],
tests: [{
fragment: true,
input: '',
output: ''
},
{
fragment: true,
input: '\n \n
',
output: '\n \n
'
},
{
fragment: true,
input: '\n \n
',
output: '\n \n
'
}
]
}, {
name: "Attribute Wrap",
description: "Wraps attributes inside of html tags",
matrix: [{
options: [
{ name: "wrap_attributes", value: "'force'" }
],
indent_attr: '\n ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force'" },
{ name: "wrap_line_length", value: "80" }
],
indent_attr: '\n ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force'" },
{ name: "wrap_attributes_indent_size", value: "8" }
],
indent_attr: '\n ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'auto'" },
{ name: "wrap_line_length", value: "80" },
{ name: "wrap_attributes_indent_size", value: "0" }
],
indent_attr: ' ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n'
}, {
options: [
{ name: "wrap_attributes", value: "'auto'" },
{ name: "wrap_line_length", value: "80" },
{ name: "wrap_attributes_indent_size", value: "4" }
],
indent_attr: ' ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'auto'" },
{ name: "wrap_line_length", value: "0" }
],
indent_attr: ' ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: ' '
}, {
options: [
{ name: "wrap_attributes", value: "'force-aligned'" }
],
indent_attr: '\n ',
indent_attr_faligned: ' ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force-aligned'" },
{ name: "wrap_line_length", value: "80" }
],
indent_attr: '\n ',
indent_attr_faligned: ' ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force-aligned'" },
{ name: "wrap_attributes_indent_size", value: "8" }
],
indent_attr: '\n ',
indent_attr_faligned: ' ',
indent_attr_first: ' ',
indent_end: '',
indent_end_selfclosing: ' ',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force-expand-multiline'" },
{ name: "wrap_attributes_indent_size", value: "4" }
],
indent_attr: '\n ',
indent_attr_first: '\n ',
indent_end: '\n',
indent_end_selfclosing: '\n',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force-expand-multiline'" },
{ name: "wrap_attributes_indent_size", value: "4" },
{ name: "wrap_line_length", value: "80" }
],
indent_attr: '\n ',
indent_attr_first: '\n ',
indent_end: '\n',
indent_end_selfclosing: '\n',
indent_over80: '\n '
}, {
options: [
{ name: "wrap_attributes", value: "'force-expand-multiline'" },
{ name: "wrap_attributes_indent_size", value: "8" }
],
indent_attr: '\n ',
indent_attr_first: '\n ',
indent_end: '\n',
indent_end_selfclosing: '\n',
indent_over80: '\n '
}],
tests: [{
fragment: true,
input: 'This is some text
',
output: 'This is some text
'
}, {
fragment: true,
input: 'This is some text
',
output: 'This is some text
'
}, {
fragment: true,
input: 'This is some text
',
output: 'This is some text
'
}, {
fragment: true,
input: 'This is some text
',
output: 'This is some text
'
}, {
fragment: true,
input: ' ',
output: ' '
}, {
fragment: true,
input: ' ',
output: '\n '
}, {
fragment: true,
input: ' ',
output: ' '
}]
}, {
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' +
' \n' +
'
\n' +
'{{/if}}',
output: '{{#if 0}}\n' +
'\n' +
'
\n' +
'{{/if}}'
}, {
fragment: true,
input_: '\n' +
'{{#each thing}}\n' +
' {{name}}\n' +
'{{/each}}\n' +
'
',
output: '\n' +
' {{#each thing}} {{name}} {{/each}}\n' +
'
'
}
]
}, {
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: '{{!-- 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}}'
}, {
options: [
{ name: "indent_handlebars", value: "true" }
],
content: '{{!-- \n mult-line\ncomment \n with spacing\n--}}'
}, {
options: [
{ name: "indent_handlebars", value: "true" }
],
content: '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}'
}, {
options: [
{ name: "indent_handlebars", value: "true" },
{ name: "wrap_line_length", value: "80" }
],
content: 'content'
}],
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' +
' \n' +
'
\n' +
'{{/if}}'
}, {
fragment: true,
input_: '{{#if 1}}\n' +
'\n' +
'
\n' +
'{{/if}}',
output: '{{#if 1}}\n' +
' \n' +
'
\n' +
'{{/if}}'
}, {
fragment: true,
unchanged: '\n' +
' {{#if 1}}\n' +
' {{/if}}\n' +
'
'
}, {
fragment: true,
input_: '\n' +
'{{#if 1}}\n' +
'{{/if}}\n' +
'
',
output: '\n' +
' {{#if 1}}\n' +
' {{/if}}\n' +
'
'
}, {
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' +
' \n' +
'
\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_: '
',
output: '
'
}, {
fragment: true,
input_: '^^^&content$$$
',
output: '^^^&content$$$
'
}, {
fragment: true,
input_: '^^^&content$$$
',
output: '^^^&content$$$
'
}, {
fragment: true,
input_: '^^^&content$$$ ',
output: '^^^&content$$$ '
}, {
fragment: true,
unchanged: '^^^&content$$$
'
}, {
fragment: true,
unchanged: '^^^&content$$$
'
},
// Quotes found inside of Handlebars expressions inside of quoted
// strings themselves should not be considered string delimiters.
{
fragment: true,
unchanged: '
'
}, {
fragment: true,
unchanged: '
'
}, {
fragment: true,
unchanged: '
'
}, {
fragment: true,
unchanged: '
'
}, {
fragment: true,
unchanged: '{{condition < 0 ? "result1" : "result2"}} '
}, {
fragment: true,
unchanged: '{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}} '
}
],
}, {
name: "Handlebars Else tag indenting",
description: "Handlebar Else tags should be newlined after formatted tags",
template: "^^^ $$$",
options: [
{ name: "indent_handlebars", value: "true" }
],
tests: [{
fragment: true,
input_: '{{#if test}}
{{else}}
{{/if}}',
output: '{{#if test}}\n' +
'
\n' +
'{{else}}\n' +
'
\n' +
'{{/if}}'
}, {
fragment: true,
unchanged: '{{#if test}} {{else}} {{/if}}'
}]
}, {
name: "Unclosed html elements",
description: "Unclosed elements should not indent",
options: [],
tests: [
{ fragment: true, unchanged: '\n' },
{ fragment: true, unchanged: ' \n ' },
{ fragment: true, unchanged: ' \n ' },
{ fragment: true, unchanged: ' \n ' },
{ fragment: true, unchanged: ' \n ' },
{ fragment: true, unchanged: '\n \n \n ' }
]
}, {
name: "Unformatted tags",
description: "Unformatted tag behavior",
options: [],
tests: [{
fragment: true,
input: '\n bc \n ',
output: [
'',
' b',
' c ',
' ',
' '
]
},
{ fragment: true, unchanged: '\n bc
\n ' },
{ fragment: true, unchanged: '' },
{ fragment: true, unchanged: '
' },
{ fragment: true, unchanged: '
' },
{ fragment: true, unchanged: '\n \n
' },
{ fragment: true, unchanged: '\n \n
' },
{ fragment: true, unchanged: '\n \n
' },
{ fragment: true, unchanged: '\n image: image: \n
' },
{ fragment: true, unchanged: '\n image: image: \n
' },
]
}, {
name: "File starting with comment",
description: "Unformatted tag behavior",
options: [],
tests: [{
fragment: true,
unchanged: [
'',
'',
'',
'',
' a span ',
'',
'',
''
]
}, ]
}, {
name: "Php formatting",
description: "Php () treated as comments.",
options: [],
tests: [{
fragment: true,
input: '',
output: '',
}, {
fragment: true,
unchanged: [
'");',
'}',
'?>'
]
}, {
fragment: true,
unchanged: [
'',
'',
'',
'',
'',
'',
'',
'',
'',
''
]
}]
}, {
name: "Support simple language specific option inheritance/overriding",
description: "Support simple language specific option inheritance/overriding",
matrix: [{
options: [
{ name: "js", value: "{ 'indent_size': 3 }" },
{ name: "css", value: "{ 'indent_size': 5 }" }
],
h: ' ',
c: ' ',
j: ' '
},
{
options: [
{ name: "html", value: "{ 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 } }" }
],
h: ' ',
c: ' ',
j: ' '
},
{
options: [
{ name: "indent_size", value: "9" },
{ name: "html", value: "{ 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 }, 'indent_size': 2}" },
{ name: "js", value: "{ 'indent_size': 5 }" },
{ name: "css", value: "{ 'indent_size': 3 }" }
],
h: ' ',
c: ' ',
j: ' '
}
],
tests: [{
fragment: true,
unchanged: [
'',
'{{h}}',
'{{h}}',
'',
]
}, ]
}, {
name: "underscore.js formatting",
description: "underscore.js templates (<% ... %>) treated as comments.",
options: [],
tests: [{
fragment: true,
unchanged: [
'',
' ',
'
'
]
}, ]
}, {
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_: '',
output: '\n' +
'\t
\n' +
'\t
\n' +
'
'
}]
}, {
name: "Indent without tabs",
description: "Use several spaces for indentation",
template: "^^^ $$$",
options: [
{ name: "indent_with_tabs", value: "false" }
],
tests: [{
fragment: true,
input_: '',
output: ''
}]
}, {
name: "Indent body inner html by default",
description: "",
tests: [{
fragment: true,
input: '\n\n
\n\n\n',
output: '\n\n
\n\n\n'
}]
}, {
name: "indent_body_inner_html set to false prevents indent of body inner html",
description: "",
options: [
{ name: 'indent_body_inner_html', value: "false" }
],
tests: [{
fragment: true,
unchanged: '\n\n
\n\n\n'
}]
}, {
name: "Indent head inner html by default",
description: "",
tests: [{
fragment: true,
input: '\n\n\n \n\n\n',
output: '\n\n\n \n\n\n'
}]
}, {
name: "indent_head_inner_html set to false prevents indent of head inner html",
description: "",
options: [
{ name: 'indent_head_inner_html', value: "false" }
],
tests: [{
fragment: true,
unchanged: '\n\n\n \n\n\n'
}]
}, {
name: "content_unformatted to prevent formatting content",
description: "",
options: [
{ name: 'content_unformatted', value: "['script', 'style', 'p', 'span', 'br']" }
],
tests: [{
fragment: true,
input: 'A ',
output: [
'',
'',
' A ',
' ',
' ',
'',
'',
''
]
}, {
fragment: true,
input: '
But not me
',
output: [
'',
'
But not me
'
]
}, {
fragment: true,
input: '
But not me
',
output: [
'',
'
But not me
'
]
}, {
fragment: true,
unchanged: ''
}, {
fragment: true,
unchanged: '
'
}, {
fragment: true,
input: '',
output: [
'',
'
var a=1; var b=a; ',
'
'
]
}, {
fragment: true,
input: '',
output: [
'',
'
',
' var a=1; var b=a;',
' ',
'
'
]
}]
}, {
name: "default content_unformatted",
description: "",
options: [],
tests: [{
fragment: true,
input: 'A ',
output: [
'',
'',
' A ',
' ',
' ',
'',
'',
''
]
}, {
fragment: true,
input: '
But not me
',
output: [
'',
'',
'
But not me
',
'',
]
}, {
fragment: true,
input: '
But not me
',
output: [
'',
'',
'
But not me
',
''
]
}, {
fragment: true,
unchanged: ''
}, {
fragment: true,
unchanged: '
'
}, {
fragment: true,
input: '',
output: [
'',
'
var a=1;',
'var b=a; ',
'
'
]
}, {
fragment: true,
input: '',
output: [
'',
'
',
'var a=1;',
'var b=a;',
' ',
'
'
]
}]
}, {
name: "New Test Suite"
}],
};