Skip to content

Commit a2a2aa3

Browse files
committed
test: add tests for recognizeNoValueAttribute option
1 parent f9b165d commit a2a2aa3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test-core.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,30 @@ test('should parse with input in button', t => {
370370
];
371371
t.deepEqual(tree, expected);
372372
});
373+
374+
test('should parse no value attribute as `true` when `recognizeNoValueAttribute` is `true` ', t => {
375+
const tree = parser(
376+
'<div class="className" hasClass>Content</div>',
377+
{ recognizeNoValueAttribute: true }
378+
);
379+
const expected = [
380+
{
381+
tag: 'div',
382+
attrs: { class: 'className', hasClass: true },
383+
content: ['Content']
384+
}
385+
];
386+
t.deepEqual(tree, expected);
387+
});
388+
389+
test('should parse no value attribute as empty string when `recognizeNoValueAttribute` is `false` or not set ', t => {
390+
const tree = parser('<div class="className" hasClass>Content</div>');
391+
const expected = [
392+
{
393+
tag: 'div',
394+
attrs: { class: 'className', hasClass: '' },
395+
content: ['Content']
396+
}
397+
];
398+
t.deepEqual(tree, expected);
399+
});

0 commit comments

Comments
 (0)