forked from tbranyen/diffhtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathto-string.js
More file actions
79 lines (58 loc) · 2.19 KB
/
Copy pathto-string.js
File metadata and controls
79 lines (58 loc) · 2.19 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { strictEqual, throws } from 'assert';
import { html, toString } from '../lib/index';
import validateMemory from './util/validate-memory';
describe('toString', function() {
afterEach(() => {
validateMemory();
});
it('can render simple div string', () => {
const actual = toString('<div>Hello world</div>');
const expected = `<div>Hello world</div>`;
strictEqual(actual, expected);
});
it('can render pure text, no wrapper element', () => {
const actual = toString('Hello world');
const expected = `Hello world`;
strictEqual(actual, expected);
});
it('can render simple vTree', () => {
const actual = toString(html`<div>Hello world</div>`);
const expected = `<div>Hello world</div>`;
strictEqual(actual, expected);
});
it('can render attributes', () => {
const actual = toString(html`<div data-test="test" />`);
const expected = `<div data-test="test"></div>`;
strictEqual(actual, expected);
});
it('can render dynamic attributes', () => {
const actual = toString(html`<div data-test=${() => {}} />`);
const expected = `<div data-test></div>`;
strictEqual(actual, expected);
});
it('can render a value-less attribute', () => {
const actual = toString(html`<div disabled/>`);
const expected = `<div disabled></div>`;
strictEqual(actual, expected);
});
it('can render top level document fragments', () => {
const actual = toString(html`<div/><p/>`);
const expected = `<div></div><p></p>`;
strictEqual(actual, expected);
});
it('can render top level single adjacent document fragments', () => {
const actual = toString(html`<div/>${html`<div/><p/>`}`);
const expected = `<div></div><div></div><p></p>`;
strictEqual(actual, expected);
});
it('can render top level document fragments adjacent single', () => {
const actual = toString(html`${html`<div/><p/>`}<div/>`);
const expected = `<div></div><p></p><div></div>`;
strictEqual(actual, expected);
});
it('can render nested document fragments', () => {
const actual = toString(html`<div>${html`<div/><p/>`}</div>`);
const expected = `<div><div></div><p></p></div>`;
strictEqual(actual, expected);
});
});