-
Notifications
You must be signed in to change notification settings - Fork 47
/
tagged-template.js
39 lines (29 loc) · 1.2 KB
/
tagged-template.js
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
import { html } from '../../../lib/util/tagged-template';
import { cleanMemory } from '../../../lib/util/memory';
import validateMemory from '../../util/validateMemory';
describe('Unit: Tagged template', function() {
afterEach(function() {
cleanMemory();
validateMemory();
});
it('can interpolate a single string value in an attribute', function() {
const foo = 'foo';
const multipleValues = html`<span class="${foo}" />`;
assert.equal(multipleValues.attributes[0].name, 'class');
assert.equal(multipleValues.attributes[0].value, 'foo');
});
it('can interpolate multiple string values in an attribute', function() {
const foo = 'foo';
const bar = 'bar';
const multipleValues = html`<span class="${foo} ${bar}" />`;
assert.equal(multipleValues.attributes[0].name, 'class');
assert.equal(multipleValues.attributes[0].value, 'foo bar');
});
it('can interpolate multiple type values in an attribute', function() {
const foo = 'foo';
const bar = {};
const multipleValues = html`<span class="${foo} ${bar}" />`;
assert.equal(multipleValues.attributes[0].name, 'class');
assert.equal(multipleValues.attributes[0].value, 'foo __DIFFHTML__');
});
});