1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<?php
use Termwind\Exceptions\InvalidChild;
use function Termwind\parse;
it('accepts multiple elements', function () {
$dl = parse(<<<'HTML'
<dl>
<dt>term</dt>
<dd>details</dd>
<dt>another term</dt>
<dd>more details</dd>
</dl>
HTML
);
expect($dl)->toBe("<options=bold>term</>\n details\n<options=bold>another term</>\n more details");
});
it('renders only "dt" and "dd" as children', function () {
expect(fn () => parse('<dl><h1></h1></dl>'))
->toThrow(InvalidChild::class);
});
it('renders "dt" and "dd" elements and ignore empty spaces', function () {
$html = parse(<<<'HTML'
<dl>
<dt>term</dt>
<dd>details</dd>
<dt>another term</dt>
<dd>more details</dd>
</dl>
HTML
);
expect($html)->toBe("<options=bold>term</>\n details\n<options=bold>another term</>\n more details");
});
it('renders "dt" and "dd" in a single row', function () {
$html = parse(<<<'HTML'
<dl> <dt>term</dt> <dd>details</dd> </dl>
HTML
);
expect($html)->toBe("<options=bold>term</> \n details ");
});
|