Skip to content

Commit 4dfa92e

Browse files
committed
test: more tests
1 parent 9fb9368 commit 4dfa92e

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

test/test-core.spec.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,69 @@ test('{Tree} {With empty string}', t => {
279279
t.is(render(tree), html);
280280
});
281281

282+
test('{Tree} {With tag false}', t => {
283+
const tree = [
284+
{
285+
tag: false,
286+
content: []
287+
},
288+
{
289+
tag: 'script',
290+
content: ['window.foo1 = \'foo\';', 'window.foo2 = \'foo\'']
291+
},
292+
'\\n ',
293+
{
294+
tag: 'script',
295+
attrs: {
296+
src: './script-need-foo-variable.js'
297+
}
298+
},
299+
'\\n ',
300+
{
301+
tag: false,
302+
content: []
303+
},
304+
{
305+
tag: 'script',
306+
content: ['window.bar1 = \'foo\';', 'window.bar2 = \'bar\'']
307+
}
308+
];
309+
const html = '<script>window.foo1 = \'foo\';window.foo2 = \'foo\'</script>\\n <script src="./script-need-foo-variable.js"></script>\\n <script>window.bar1 = \'foo\';window.bar2 = \'bar\'</script>';
310+
311+
t.is(render(tree), html);
312+
});
313+
314+
test('{Tree} {With ?}', t => {
315+
const tree = [
316+
{
317+
tag: false,
318+
content: [
319+
{
320+
tag: false,
321+
content: [
322+
{
323+
tag: 'title',
324+
content: ['Title']
325+
}
326+
]
327+
},
328+
{
329+
tag: false,
330+
content: [
331+
{
332+
tag: 'p',
333+
content: ['Hi']
334+
}
335+
]
336+
}
337+
]
338+
}
339+
];
340+
const html = '<title>Title</title><p>Hi</p>';
341+
342+
t.is(render(tree), html);
343+
});
344+
282345
test('{Options} {singleTag} Defaults', t => {
283346
const SINGLE_TAGS_LOWERCASE = [
284347
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'
@@ -478,3 +541,17 @@ test('{Options} {quoteStyle} 0 - smart quote', t => {
478541

479542
t.is(render(fixture, options), expected);
480543
});
544+
545+
test.only('{QuoteStyle}', t => {
546+
const fixture = {
547+
tag: 'img',
548+
attrs: {
549+
src: 'https://example.com/example.png',
550+
width: 20,
551+
height: 20
552+
}
553+
};
554+
const expected = '<img src="https://example.com/example.png" width=\'20\' height=\'20\'>';
555+
556+
t.is(render(fixture), expected);
557+
});

0 commit comments

Comments
 (0)