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

Remove hasEmberVersion #1089

Merged
merged 2 commits into from
Jun 12, 2023
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
40 changes: 0 additions & 40 deletions addon-test-support/adapter.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
import Ember from 'ember';
import * as QUnit from 'qunit';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

function unhandledRejectionAssertion(current, error) {
let message, source;

if (typeof error === 'object' && error !== null) {
message = error.message;
source = error.stack;
} else if (typeof error === 'string') {
message = error;
source = 'unknown source';
} else {
message = 'unhandledRejection occurred, but it had no message';
source = 'unknown source';
}

current.assert.pushResult({
result: false,
actual: false,
expected: true,
message: message,
source: source,
});
}

export function nonTestDoneCallback() {}

Expand Down Expand Up @@ -59,22 +35,6 @@ let Adapter = Ember.Test.Adapter.extend({
done();
}
},

// clobber default implementation of `exception` will be added back for Ember
// < 2.17 just below...
exception: null,
});

// Ember 2.17 and higher do not require the test adapter to have an `exception`
// method When `exception` is not present, the unhandled rejection is
// automatically re-thrown and will therefore hit QUnit's own global error
// handler (therefore appropriately causing test failure)
if (!hasEmberVersion(2, 17)) {
Adapter = Adapter.extend({
exception(error) {
unhandledRejectionAssertion(QUnit.config.current, error);
},
});
}

export default Adapter;
5 changes: 0 additions & 5 deletions tests/acceptance/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import {
click,
} from '@ember/test-helpers';
import { setResolverRegistry } from '../helpers/resolver';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

module('setupApplicationTest tests', function (hooks) {
if (!hasEmberVersion(2, 4)) {
return;
}

const Router = EmberRouter.extend({ location: 'none' });
Router.map(function () {
this.route('widgets');
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/setup-rendering-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import { hbs } from 'ember-cli-htmlbars';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { setResolverRegistry } from '../helpers/resolver';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

module('setupRenderingTest tests', function (hooks) {
if (!hasEmberVersion(2, 4)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this code was no-op, because we don't test against ember < v4 now

return;
}

hooks.beforeEach(function () {
setResolverRegistry({});
});
Expand Down
12 changes: 1 addition & 11 deletions tests/integration/setup-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { module, test } from 'qunit';
import Service, { inject as injectService } from '@ember/service';
import Component from '@ember/component';
import { setupTest } from 'ember-qunit';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';
import { setResolverRegistry } from '../helpers/resolver';

module('setupTest tests', function (hooks) {
if (!hasEmberVersion(2, 4)) {
return;
}

hooks.beforeEach(function () {
setResolverRegistry({});
});
Expand Down Expand Up @@ -63,12 +58,7 @@ module('setupTest tests', function (hooks) {
})
);

let subject;
if (hasEmberVersion(2, 12)) {
subject = this.owner.lookup('component:foo-bar');
} else {
subject = this.owner._lookupFactory('component:foo-bar').create();
}
let subject = this.owner.lookup('component:foo-bar');

assert.equal(subject.someMethod(), 'hello thar!');
});
Expand Down