-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
55 lines (52 loc) · 1.01 KB
/
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
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
/**
* @file test
* @author Cuttle Cong
* @date 2018/3/31
* @description
*/
const { Compiler } = require('edam')
const compiler = new Compiler()
compiler.assets = {
'test.js': {
value: `
var a = '{{{ v }}}'
if (a === '123') {
console.log(1)
}
`.trim()
}
}
it('should passed options works', async function() {
compiler.mappers = [
{
test: '*',
loader: [[require('./'), { semi: true, tabWidth: 4, singleQuote: true }]]
}
]
const tree = await compiler.run()
expect(tree['test.js'].output).toBe(
`var a = '{{{ v }}}';
if (a === '123') {
console.log(1);
}\n`.trimLeft()
)
})
it('should passed filePath works', async function() {
compiler.mappers = [
{
test: '*.js',
loader: [
'hbs',
[require('./'), { filePath: __dirname, semi: true }]
]
}
]
compiler.variables.set('v', '123')
const tree = await compiler.run()
expect(tree['test.js'].output).toBe(
`var a = '123';
if (a === '123') {
console.log(1);
}\n`.trimLeft()
)
})