Skip to content

Commit

Permalink
Add QUnitAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Trent Willis committed Aug 17, 2016
1 parent 8deb4ed commit 3b5c985
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ember-qunit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import moduleFor from 'ember-qunit/module-for';
import moduleForComponent from 'ember-qunit/module-for-component';
import moduleForModel from 'ember-qunit/module-for-model';
import QUnitAdapter from 'ember-qunit/adapter';
import { setResolver } from 'ember-test-helpers';
export { test, skip, only } from 'qunit';

export {
moduleFor,
moduleForComponent,
moduleForModel,
setResolver
setResolver,
QUnitAdapter
};
20 changes: 20 additions & 0 deletions lib/ember-qunit/adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Ember from 'ember';
import QUnit from 'qunit';

export default Ember.Test.Adapter.extend({
init() {
this.doneCallbacks = [];
},

asyncStart() {
this.doneCallbacks.push(QUnit.config.current.assert.async());
},

asyncEnd() {
this.doneCallbacks.pop()();
},

exception(error) {
QUnit.config.current.assert.ok(false, Ember.inspect(error));
}
});
29 changes: 29 additions & 0 deletions tests/adapter-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* global setTimeout */

import { module, test } from 'qunit';
import { QUnitAdapter } from 'ember-qunit';

module('QUnitAdapter');

test('asyncStart waits for asyncEnd to finish a test', function(assert) {
const adapter = QUnitAdapter.create();

adapter.asyncStart();
setTimeout(function() {
assert.ok(true);
adapter.asyncEnd();
}, 50);
});

test('asyncStart waits for equal numbers of asyncEnd to finish a test', function(assert) {
const adapter = QUnitAdapter.create();

adapter.asyncStart();
adapter.asyncStart();
adapter.asyncEnd();

setTimeout(function() {
assert.ok(true);
adapter.asyncEnd();
}, 50);
});

0 comments on commit 3b5c985

Please sign in to comment.