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

Update to QUnit 2.5.0 #306

Merged
merged 2 commits into from Jan 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon-test-support/ember-qunit/adapter.js
Expand Up @@ -15,7 +15,7 @@ function unhandledRejectionAssertion(current, error) {
source = 'unknown source';
}

current.pushResult({
current.assert.pushResult({
result: false,
actual: false,
expected: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -33,7 +33,7 @@
"common-tags": "^1.4.0",
"ember-cli-babel": "^6.3.0",
"ember-cli-test-loader": "^2.2.0",
"qunit": "^2.4.1"
"qunit": "^2.5.0"
},
"devDependencies": {
"ember-cli": "~2.15.1",
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/unhandled-rejection-test.js
@@ -0,0 +1,45 @@
import { Promise as RSVPPromise } from 'rsvp';
import { module, test } from 'qunit';

const HAS_NATIVE_PROMISE = typeof Promise !== 'undefined';
const HAS_UNHANDLED_REJECTION_HANDLER = 'onunhandledrejection' in window;

module('unhandle promise rejections', function(hooks) {
hooks.beforeEach(function(assert) {
let originalPushResult = assert.pushResult;
assert.pushResult = function(resultInfo) {
// Inverts the result so we can test failing assertions
resultInfo.result = !resultInfo.result;
resultInfo.message = `Failed: ${resultInfo.message}`;
originalPushResult(resultInfo);
};
});

test('RSVP promises cause an unhandled rejection', function(assert) {
let done = assert.async();

// ensure we do not exit this test until the assertion has happened
setTimeout(done, 10);

new RSVPPromise(resolve => {
setTimeout(resolve);
}).then(function() {
throw new Error('whoops!');
});
});

if (HAS_NATIVE_PROMISE && HAS_UNHANDLED_REJECTION_HANDLER) {
test('native promises cause an unhandled rejection', function(assert) {
let done = assert.async();

// ensure we do not exit this test until the assertion has happened
setTimeout(done, 10);

new self.Promise(resolve => {
setTimeout(resolve);
}).then(function() {
throw new Error('whoops!');
});
});
}
});