-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
29 lines (24 loc) · 968 Bytes
/
test.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
const recast = require('ember-template-recast');
const { transform: _transform } = require('./index');
function transform(code) {
let root = recast.parse(code);
_transform(root);
return recast.print(root);
}
describe('transform', () => {
test('simple mustache', () => {
let input = `{{some-component data-test-foo}}`;
let expected = `{{some-component data-test-foo=true}}`;
expect(transform(input)).toEqual(expected);
});
test('mustache with existing args', () => {
let input = `{{some-component foo data-test-foo 42 @bar baz=qux bla="42"}}`;
let expected = `{{some-component foo 42 @bar baz=qux bla="42" data-test-foo=true}}`;
expect(transform(input)).toEqual(expected);
});
test('block mustache', () => {
let input = `{{#some-component data-test-foo}}FOO{{/some-component}}`;
let expected = `{{#some-component data-test-foo=true}}FOO{{/some-component}}`;
expect(transform(input)).toEqual(expected);
});
});