-
-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathaddon-test.js
More file actions
99 lines (83 loc) · 2.37 KB
/
addon-test.js
File metadata and controls
99 lines (83 loc) · 2.37 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'use strict';
const co = require('co');
const expect = require('chai').expect;
const MockUI = require('console-ui/mock');
const CoreObject = require('core-object');
const AddonMixin = require('../lib/ember-addon-main');
const BroccoliTestHelper = require('broccoli-test-helper');
const createBuilder = BroccoliTestHelper.createBuilder;
const createTempDir = BroccoliTestHelper.createTempDir;
let Addon = CoreObject.extend(AddonMixin);
describe('ember-cli-htmlbars addon', function () {
const ORIGINAL_EMBER_ENV = process.env.EMBER_ENV;
beforeEach(function () {
this.ui = new MockUI();
let project = {
isEmberCLIProject: () => true,
_addonsInitialized: true,
root: __dirname,
emberCLIVersion: () => '2.16.2',
dependencies() {
return {};
},
addons: [],
targets: {
browsers: ['ie 11'],
},
};
this.addon = new Addon({
project,
parent: project,
ui: this.ui,
_requiresModuleApiPolyfill: true,
});
project.addons.push(this.addon);
});
afterEach(function () {
if (ORIGINAL_EMBER_ENV === undefined) {
delete process.env.EMBER_ENV;
} else {
process.env.EMBER_ENV = ORIGINAL_EMBER_ENV;
}
});
describe('transpileTree', function () {
this.timeout(0);
let input;
let output;
let subject;
beforeEach(
co.wrap(function* () {
input = yield createTempDir();
})
);
afterEach(
co.wrap(function* () {
yield input.dispose();
yield output.dispose();
})
);
it(
'should build',
co.wrap(function* () {
input.write({
'hello.hbs': `<div>Hello, World!</div>`,
});
let htmlbarsOptions = {
isHTMLBars: true,
templateCompiler: require('ember-source/dist/ember-template-compiler.js'),
templateCompilerPath: require.resolve('ember-source/dist/ember-template-compiler.js'),
};
subject = this.addon.transpileTree(input.path(), htmlbarsOptions);
output = createBuilder(subject);
yield output.build();
expect(output.read()).to.deep.equal({
'hello.js': [
`import { hbs } from 'ember-cli-htmlbars';`,
`export default hbs('<div>Hello, World!</div>', { moduleName: 'hello.hbs' });`,
'',
].join('\n'),
});
})
);
});
});