Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Ensure legacy build of template compiler can be loaded. #17403

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ function buildBundles(packagesES, dependenciesES, templateCompilerDependenciesES
'@ember/polyfills/index.js',
'@ember/polyfills/lib/**',
'ember/version.js',
'ember-babel.js',
'ember-template-compiler/**',
],
}),
Expand Down
80 changes: 49 additions & 31 deletions tests/node/template-compiler-test.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,67 @@
var path = require('path');

var distPath = path.join(__dirname, '../../dist');
var templateCompilerPath = path.join(distPath, 'ember-template-compiler');

var module = QUnit.module;
var test = QUnit.test;

var templateCompiler;

module('ember-template-compiler.js', function(hooks) {
hooks.beforeEach(function() {
templateCompiler = require(templateCompilerPath);
});
module('ember-template-compiler.js', function() {
['', 'legacy'].forEach(type => {
module(`${type || 'modern'}`, function(hooks) {
hooks.beforeEach(function() {
this.templateCompilerPath = path.resolve(
path.join(distPath, type, 'ember-template-compiler.js')
);
templateCompiler = require(this.templateCompilerPath);
});

hooks.afterEach(function() {
// clear the previously cached version of this module
delete require.cache[templateCompilerPath + '.js'];
});
hooks.afterEach(function() {
// clear the previously cached version of this module
delete require.cache[this.templateCompilerPath];
});

test('can be required', function(assert) {
assert.strictEqual(
typeof templateCompiler.precompile,
'function',
'precompile function is present'
);
assert.strictEqual(typeof templateCompiler.compile, 'function', 'compile function is present');
});
test('can be required', function(assert) {
assert.strictEqual(
typeof templateCompiler.precompile,
'function',
'precompile function is present'
);
assert.strictEqual(
typeof templateCompiler.compile,
'function',
'compile function is present'
);
});

test('can access _Ember.ENV (private API used by ember-cli-htmlbars)', function(assert) {
assert.equal(typeof templateCompiler._Ember.ENV, 'object', '_Ember.ENV is present');
assert.notEqual(typeof templateCompiler._Ember.ENV, null, '_Ember.ENV is not null');
});
test('can access _Ember.ENV (private API used by ember-cli-htmlbars)', function(assert) {
assert.equal(typeof templateCompiler._Ember.ENV, 'object', '_Ember.ENV is present');
assert.notEqual(typeof templateCompiler._Ember.ENV, null, '_Ember.ENV is not null');
});

test('can access _Ember.FEATURES (private API used by ember-cli-htmlbars)', function(assert) {
assert.equal(typeof templateCompiler._Ember.FEATURES, 'object', '_Ember.FEATURES is present');
assert.notEqual(typeof templateCompiler._Ember.FEATURES, null, '_Ember.FEATURES is not null');
});
test('can access _Ember.FEATURES (private API used by ember-cli-htmlbars)', function(assert) {
assert.equal(
typeof templateCompiler._Ember.FEATURES,
'object',
'_Ember.FEATURES is present'
);
assert.notEqual(
typeof templateCompiler._Ember.FEATURES,
null,
'_Ember.FEATURES is not null'
);
});

test('can access _Ember.VERSION (private API used by ember-cli-htmlbars)', function(assert) {
assert.equal(typeof templateCompiler._Ember.VERSION, 'string', '_Ember.VERSION is present');
});
test('can access _Ember.VERSION (private API used by ember-cli-htmlbars)', function(assert) {
assert.equal(typeof templateCompiler._Ember.VERSION, 'string', '_Ember.VERSION is present');
});

test('can generate a template with a server side generated `id`', function(assert) {
var TemplateJSON = JSON.parse(templateCompiler.precompile('<div>simple text</div>'));
test('can generate a template with a server side generated `id`', function(assert) {
var TemplateJSON = JSON.parse(templateCompiler.precompile('<div>simple text</div>'));

assert.ok(TemplateJSON.id, 'an `id` was generated');
assert.ok(TemplateJSON.id, 'an `id` was generated');
});
});
});
});