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

Fix node tests. #12440

Merged
merged 1 commit into from
Oct 5, 2015
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
2 changes: 1 addition & 1 deletion bin/run-node-tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

require('qunitjs');
global.QUnit = require('qunitjs');

// adds test reporting
var qe = require('qunit-extras');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"github": "^0.2.3",
"glob": "~4.3.2",
"htmlbars": "0.14.6",
"qunit-extras": "^1.3.0",
"qunitjs": "^1.16.0",
"qunit-extras": "^1.4.0",
"qunitjs": "^1.19.0",
"route-recognizer": "0.1.5",
"rsvp": "~3.0.6",
"serve-static": "^1.10.0",
Expand Down
21 changes: 11 additions & 10 deletions tests/node/app-boot-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*jshint multistr:true*/
var QUnit = require('qunitjs');
var appModule = require('./helpers/app-module');

function assertHTMLMatches(assert, actualHTML, expectedHTML) {
Expand Down Expand Up @@ -87,40 +88,40 @@ if (appModule.canRunTests) {
});

QUnit.test("lifecycle hooks disabled", function(assert) {
expect(2);
assert.expect(2);

this.template('application', "{{my-component}}{{outlet}}");

this.component('my-component', {
willRender: function() {
ok(true, "should trigger component willRender hook");
assert.ok(true, "should trigger component willRender hook");
},
didRender: function() {
ok(false, "should not trigger didRender hook");
assert.ok(false, "should not trigger didRender hook");
},
willInsertElement: function() {
ok(false, "should not trigger willInsertElement hook");
assert.ok(false, "should not trigger willInsertElement hook");
},
didInsertElement: function() {
ok(false, "should not trigger didInsertElement hook");
assert.ok(false, "should not trigger didInsertElement hook");
}
});

this.view('index', {
_willRender: function() {
ok(true, "should trigger view _willRender hook");
assert.ok(true, "should trigger view _willRender hook");
},
didRender: function() {
ok(false, "should not trigger didRender hook");
assert.ok(false, "should not trigger didRender hook");
},
willInsertElement: function() {
ok(false, "should not trigger willInsertElement hook");
assert.ok(false, "should not trigger willInsertElement hook");
},
didCreateElement: function() {
ok(false, "should not trigger didCreateElement hook");
assert.ok(false, "should not trigger didCreateElement hook");
},
didInsertElement: function() {
ok(false, "should not trigger didInsertElement hook");
assert.ok(false, "should not trigger didInsertElement hook");
}
});

Expand Down
1 change: 1 addition & 0 deletions tests/node/component-rendering-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*globals global,__dirname*/

var QUnit = require('qunitjs');
var SimpleDOM = require('simple-dom');
var path = require('path');

Expand Down
2 changes: 2 additions & 0 deletions tests/node/helpers/app-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/*globals global,__dirname*/

var path = require('path');
var QUnit = require('qunitjs');

var distPath = path.join(__dirname, '../../../dist');
var emberPath = path.join(distPath, 'ember.debug.cjs');
var templateCompilerPath = path.join(distPath, 'ember-template-compiler');
Expand Down
17 changes: 7 additions & 10 deletions tests/node/runtime-test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
/*globals __dirname*/

var path = require('path');

var module = QUnit.module;
var ok = QUnit.ok;
var equal = QUnit.equal;
var QUnit = require('qunitjs');

var distPath = path.join(__dirname, '../../dist');

module('ember-runtime.js');
QUnit.module('ember-runtime.js');

test('can be required', function() {
test('can be required', function(assert) {
var Ember = require(path.join(distPath, 'ember-runtime'));

ok(Ember.Object, 'Ember.Object is present');
assert.ok(Ember.Object, 'Ember.Object is present');
});

test('basic object system functions properly', function() {
test('basic object system functions properly', function(assert) {
var Ember = require(path.join(distPath, 'ember-runtime'));

var Person = Ember.Object.extend({
Expand All @@ -30,9 +27,9 @@ test('basic object system functions properly', function() {
lastName: 'Jackson'
});

equal(person.get('name'), 'Max Jackson');
assert.equal(person.get('name'), 'Max Jackson');

person.set('firstName', 'James');

equal(person.get('name'), 'James Jackson');
assert.equal(person.get('name'), 'James Jackson');
});
19 changes: 9 additions & 10 deletions tests/node/template-compiler-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*globals __dirname*/

var path = require('path');
var QUnit = require('qunitjs');

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

var module = QUnit.module;
var ok = QUnit.ok;
var equal = QUnit.equal;
var test = QUnit.test;

var distPath = path.join(__dirname, '../../dist');
Expand All @@ -25,14 +25,13 @@ module('ember-template-compiler.js', {
}
});

test('can be required', function() {

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

test('allows enabling of features', function() {
test('allows enabling of features', function(assert) {
var templateOutput;
var templateCompiler = require(path.join(distPath, 'ember-template-compiler'));

Expand All @@ -42,8 +41,8 @@ test('allows enabling of features', function() {
templateCompiler._Ember.FEATURES['ember-htmlbars-component-generation'] = true;

templateOutput = templateCompiler.precompile('<some-thing></some-thing>');
ok(templateOutput.indexOf('["component","@<some-thing>",[],0]') > -1, 'component generation can be enabled');
assert.ok(templateOutput.indexOf('["component","@<some-thing>",[],0]') > -1, 'component generation can be enabled');
} else {
ok(true, 'cannot test features in feature stripped build');
assert.ok(true, 'cannot test features in feature stripped build');
}
});