-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjsonml.spec.ts
26 lines (24 loc) · 937 Bytes
/
jsonml.spec.ts
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
import { describe, expect, it} from 'vitest';
import JsonML from '../src/JsonML';
describe('JsonML', () => {
it('should return span with empty values after construction', () => {
expect(new JsonML('span').toJSONML()).to.deep.equal(['span', {}]);
});
it('should return span with style attributes', () => {
expect(
new JsonML('span').withStyle('color: red;').toJSONML()
).to.deep.equal(['span', { style: 'color: red;' }]);
});
it('should return div with text child node', () => {
expect(new JsonML('div').withText('child').toJSONML()).to.deep.equal([
'div',
{},
'child',
]);
});
it('should return div with two child nodes', () => {
const child = new JsonML('span');
const parent = new JsonML('div').withChild(child);
expect(parent.toJSONML()).to.deep.equal(['div', {}, ['span', {}]]);
});
});