-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from ebenoist/adds-qunit-only
[RFC] Adds a wrapped QUnit.only
- Loading branch information
Showing
8 changed files
with
51 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ bower_components | |
tmp | ||
dist | ||
build | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import testWrapper from 'ember-qunit/test-wrapper'; | ||
import { only as qunitOnly } from 'qunit'; | ||
|
||
export default function only(testName, callback) { | ||
testWrapper(testName, callback, qunitOnly); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Ember from 'ember'; | ||
import { getContext } from 'ember-test-helpers'; | ||
|
||
export default function testWrapper(testName, callback, qunit) { | ||
function wrapper(assert) { | ||
var context = getContext(); | ||
|
||
var result = callback.call(context, assert); | ||
|
||
function failTestOnPromiseRejection(reason) { | ||
var message; | ||
if (reason instanceof Error) { | ||
message = reason.stack; | ||
if (reason.message && message.indexOf(reason.message) < 0) { | ||
// PhantomJS has a `stack` that does not contain the actual | ||
// exception message. | ||
message = Ember.inspect(reason) + "\n" + message; | ||
} | ||
} else { | ||
message = Ember.inspect(reason); | ||
} | ||
ok(false, message); | ||
} | ||
|
||
Ember.run(function(){ | ||
QUnit.stop(); | ||
Ember.RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start); | ||
}); | ||
} | ||
|
||
qunit(testName, wrapper); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,6 @@ | ||
import Ember from 'ember'; | ||
import { getContext } from 'ember-test-helpers'; | ||
import testWrapper from 'ember-qunit/test-wrapper'; | ||
import { test as qunitTest } from 'qunit'; | ||
|
||
export default function test(testName, callback) { | ||
function wrapper(assert) { | ||
var context = getContext(); | ||
|
||
var result = callback.call(context, assert); | ||
|
||
function failTestOnPromiseRejection(reason) { | ||
var message; | ||
if (reason instanceof Error) { | ||
message = reason.stack; | ||
if (reason.message && message.indexOf(reason.message) < 0) { | ||
// PhantomJS has a `stack` that does not contain the actual | ||
// exception message. | ||
message = Ember.inspect(reason) + "\n" + message; | ||
} | ||
} else { | ||
message = Ember.inspect(reason); | ||
} | ||
ok(false, message); | ||
} | ||
|
||
Ember.run(function(){ | ||
QUnit.stop(); | ||
Ember.RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start); | ||
}); | ||
} | ||
|
||
qunitTest(testName, wrapper); | ||
testWrapper(testName, callback, qunitTest); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters