Skip to content

Commit

Permalink
Upgrade QUnit to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trentmwillis authored and Trent Willis committed Aug 17, 2016
1 parent 819560f commit 2e9e181
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 190 deletions.
23 changes: 1 addition & 22 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
{
"predef": [
"document",
"window",
"location",
"setTimeout",
"Ember",
"Em",
"DS",
"$",
"ok",
"moduleFor",
"moduleForModel",
"moduleForComponent",
"expect",
"equal",
"strictEqual",
"deepEqual",
"test",
"emq",
"setResolver",
"QUnit"
],
"node" : false,
"browser" : false,
"boss" : true,
Expand All @@ -41,6 +19,7 @@
"plusplus": false,
"regexp": false,
"undef": true,
"unused": true,
"sub": true,
"strict": false,
"white": false,
Expand Down
5 changes: 1 addition & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
"ember": "^1.13.13"
},
"devDependencies": {
"qunit": "^1.23.1",
"qunit": "^2.0.1",
"loader": "ember-cli/loader.js#1.0.1",
"ember-cli-shims": "0.0.3",
"ember-cli-test-loader": "0.0.4",
"jquery": "~2.1.4",
"ember-data": "~1.0.0-beta.10"
},
"resolutions": {
"ember-data": "~1.0.0-beta.10"
}
}
15 changes: 5 additions & 10 deletions lib/ember-qunit.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import moduleFor from 'ember-qunit/module-for';
import moduleForComponent from 'ember-qunit/module-for-component';
import moduleForModel from 'ember-qunit/module-for-model';
import test from 'ember-qunit/test';
import only from 'ember-qunit/only';
import skip from 'ember-qunit/skip';
import { setResolver } from 'ember-test-helpers';
import moduleFor from 'ember-qunit/module-for';
import moduleForComponent from 'ember-qunit/module-for-component';
import moduleForModel from 'ember-qunit/module-for-model';
import { setResolver } from 'ember-test-helpers';
export { test, skip, only } from 'qunit';

export {
moduleFor,
moduleForComponent,
moduleForModel,
test,
only,
skip,
setResolver
};
7 changes: 0 additions & 7 deletions lib/ember-qunit/only.js

This file was deleted.

28 changes: 8 additions & 20 deletions lib/ember-qunit/qunit-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ function beforeEachCallback(callbacks) {

var beforeEach;

if (callbacks.setup) {
beforeEach = callbacks.setup;
delete callbacks.setup;
}

if (callbacks.beforeEach) {
beforeEach = callbacks.beforeEach;
delete callbacks.beforeEach;
Expand All @@ -25,11 +20,6 @@ function afterEachCallback(callbacks) {

var afterEach;

if (callbacks.teardown) {
afterEach = callbacks.teardown;
delete callbacks.teardown;
}

if (callbacks.afterEach) {
afterEach = callbacks.afterEach;
delete callbacks.afterEach;
Expand All @@ -45,25 +35,23 @@ export function createModule(Constructor, name, description, callbacks) {
var module = new Constructor(name, description, callbacks);

qunitModule(module.name, {
setup: function(assert) {
var done = assert.async();

beforeEach() {
// provide the test context to the underlying module
module.setContext(this);

return module.setup().then(function() {
return module.setup(...arguments).then(() => {
if (beforeEach) {
beforeEach.call(module.context, assert);
beforeEach.apply(this, arguments);
}
})['finally'](done);
});
},

teardown: function(assert) {
afterEach() {
if (afterEach) {
afterEach.call(module.context, assert);
afterEach.apply(this, arguments);
}
var done = assert.async();
return module.teardown()['finally'](done);

return module.teardown(...arguments);
}
});
}
7 changes: 0 additions & 7 deletions lib/ember-qunit/skip.js

This file was deleted.

43 changes: 0 additions & 43 deletions lib/ember-qunit/test-wrapper.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/ember-qunit/test.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/qunit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals test:true */
/* globals QUnit */

export var module = QUnit.module;
export var test = QUnit.test;
Expand Down
57 changes: 29 additions & 28 deletions tests/module-for-component-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import $ from 'jquery';
import { moduleForComponent, test } from 'ember-qunit';
import { setResolverRegistry } from 'tests/test-support/resolver';

Expand Down Expand Up @@ -26,50 +27,50 @@ moduleForComponent('x-foo', {
}
});

test('renders', function() {
expect(2);
test('renders', function(assert) {
assert.expect(2);
var component = this.subject();
equal(component._state, 'preRender');
assert.equal(component._state, 'preRender');
this.render();
equal(component._state, 'inDOM');
assert.equal(component._state, 'inDOM');
});

test('append', function() {
expect(2);
test('append', function(assert) {
assert.expect(2);
var component = this.subject();
equal(component._state, 'preRender');
assert.equal(component._state, 'preRender');
this.append();
equal(component._state, 'inDOM');
assert.equal(component._state, 'inDOM');
// TODO - is there still a way to check deprecationWarnings?
// ok(Ember.A(Ember.deprecationWarnings).contains('this.append() is deprecated. Please use this.render() instead.'));
// assert.ok(Ember.A(Ember.deprecationWarnings).contains('this.append() is deprecated. Please use this.render() instead.'));
});

test('yields', function() {
expect(2);
test('yields', function(assert) {
assert.expect(2);
var component = this.subject({
layout: Ember.Handlebars.compile("yield me")
});
equal(component._state, 'preRender');
assert.equal(component._state, 'preRender');
this.render();
equal(component._state, 'inDOM');
assert.equal(component._state, 'inDOM');
});

test('can lookup components in its layout', function() {
expect(1);
test('can lookup components in its layout', function(assert) {
assert.expect(1);
var component = this.subject({
layout: Ember.Handlebars.compile("{{x-foo id='yodawg-i-heard-you-liked-x-foo-in-ur-x-foo'}}")
});
this.render();
equal(component._state, 'inDOM');
assert.equal(component._state, 'inDOM');
});

test('clears out views from test to test', function() {
expect(1);
test('clears out views from test to test', function(assert) {
assert.expect(1);
this.subject({
layout: Ember.Handlebars.compile("{{x-foo id='yodawg-i-heard-you-liked-x-foo-in-ur-x-foo'}}")
});
this.render();
ok(true, 'rendered without id already being used from another test');
assert.ok(true, 'rendered without id already being used from another test');
});

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -80,25 +81,25 @@ moduleForComponent('pretty-color', {
}
});

test("className", function(){
test("className", function(assert){
// first call to this.$() renders the component.
ok(this.$().is('.pretty-color'));
assert.ok(this.$().is('.pretty-color'));
});

test("template", function(){
test("template", function(assert){
var component = this.subject();

equal($.trim(this.$().text()), 'Pretty Color:');
assert.equal($.trim(this.$().text()), 'Pretty Color:');

Ember.run(function(){
component.set('name', 'green');
});

equal($.trim(this.$().text()), 'Pretty Color: green');
assert.equal($.trim(this.$().text()), 'Pretty Color: green');
});

test("$", function(){
var component = this.subject({name: 'green'});
equal($.trim(this.$('.color-name').text()), 'green');
equal($.trim(this.$().text()), 'Pretty Color: green');
test("$", function(assert){
this.subject({ name: 'green' });
assert.equal($.trim(this.$('.color-name').text()), 'green');
assert.equal($.trim(this.$().text()), 'Pretty Color: green');
});
Loading

0 comments on commit 2e9e181

Please sign in to comment.