html: observe insertFinalNewline (#152446)

This commit is contained in:
Martin Aeschlimann
2022-06-17 12:38:36 +02:00
committed by GitHub
parent 223ea2c4b5
commit 630809a1ea
5 changed files with 11 additions and 20 deletions

View File

@@ -85,16 +85,12 @@ suite('HTML Embedded Formatting', () => {
});
test('EndWithNewline', async () => {
const options = {
html: {
format: {
endWithNewline: true
}
}
};
await assertFormat('<html><body><p>Hello</p></body></html>', '<html>\n\n<body>\n <p>Hello</p>\n</body>\n\n</html>\n', options);
await assertFormat('<html>|<body><p>Hello</p></body>|</html>', '<html><body>\n <p>Hello</p>\n</body></html>', options);
await assertFormat('<html><head><script>\nvar x=1;\n</script></head></html>', '<html>\n\n<head>\n <script>\n var x = 1;\n </script>\n</head>\n\n</html>\n', options);
const options : FormattingOptions = FormattingOptions.create(2, true);
options.insertFinalNewline = true;
await assertFormat('<html><body><p>Hello</p></body></html>', '<html>\n\n<body>\n <p>Hello</p>\n</body>\n\n</html>\n', {}, options);
await assertFormat('<html>|<body><p>Hello</p></body>|</html>', '<html><body>\n <p>Hello</p>\n</body></html>', {}, options);
await assertFormat('<html><head><script>\nvar x=1;\n</script></head></html>', '<html>\n\n<head>\n <script>\n var x = 1;\n </script>\n</head>\n\n</html>\n', {}, options);
});
test('Inside script', async () => {