Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Nov 22, 2020
1 parent 221c72c commit 1dd475b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions tests/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ import {
// @ts-ignore
import { setAdapter } from 'ember-cli-page-object/test-support/adapters';

const { require } = window;
const hasRfc268 = ( require as any).has('@ember/test-helpers');

export function setupApplicationTest(hooks: NestedHooks) {
if (!hasRfc268) {
throw new Error(`"@ember/test-helpers" not installed.`)
}

const Rfc268Adapter = require('ember-cli-page-object/test-support/adapters/rfc268');
const Rfc268Adapter = requireRfc268Adapter();

upstreamSetupApplicationTest(hooks);

Expand All @@ -24,11 +17,7 @@ export function setupApplicationTest(hooks: NestedHooks) {
}

export function setupRenderingTest(hooks: NestedHooks) {
if (!hasRfc268) {
throw new Error(`"@ember/test-helpers" not installed.`)
}

const Rfc268Adapter = require('ember-cli-page-object/test-support/adapters/rfc268');
const Rfc268Adapter = requireRfc268Adapter();

upstreamSetupRenderingTest(hooks);

Expand All @@ -37,4 +26,15 @@ export function setupRenderingTest(hooks: NestedHooks) {
});
}

function requireRfc268Adapter() {
const { require } = window;
const hasRfc268 = ( require as any).has('@ember/test-helpers');

if (!hasRfc268) {
throw new Error(`"@ember/test-helpers" not installed.`)
}

return require('ember-cli-page-object/test-support/adapters/rfc268').default;
}

export { setupTest } from 'ember-qunit';
2 changes: 1 addition & 1 deletion tests/helpers/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function moduleForProperty(name, cbOrOptions, cb) {
if (require.has('@ember/test-helpers')) {
// Generate rfc268 tests

const Rfc268Adapter = require('ember-cli-page-object/test-support/adapters/rfc268');
const Rfc268Adapter = require('ember-cli-page-object/test-support/adapters/rfc268').default;

module(`Application mode | Property | ${name}`, function(hooks) {
setupApplicationTest(hooks);
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/-private/action-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ PageObject: 'page.run("1")'

assert.rejects(p.run(1), new Error(`bed time
PageObject: 'page.run("1")'
Selector: '.Scope .Selector'`));
PageObject: 'page.run("1")'
Selector: '.Scope .Selector'`));
} else {
assert.expect(0);
}
Expand Down Expand Up @@ -334,8 +334,8 @@ PageObject: 'page.run("1")'

assert.rejects(p.emptyRun().child.run(1), new Error(`bed time
PageObject: 'page.child.run("1")'
Selector: '.root .child .Selector2'`));
PageObject: 'page.child.run("1")'
Selector: '.root .child .Selector2'`));
} else {
assert.expect(0);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/extend/find-element-with-assert-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupRenderingTest } from '../../helpers';
import { create } from 'ember-cli-page-object';
import { findElementWithAssert } from 'ember-cli-page-object/extend';
import hbs from 'htmlbars-inline-precompile';
Expand Down

0 comments on commit 1dd475b

Please sign in to comment.