Skip to content

Commit

Permalink
Rename isRfc268Test utility to supportsRfc268
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Oct 26, 2019
1 parent 3440562 commit 9636abd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions addon-test-support/-private/execution_context.js
Expand Up @@ -30,7 +30,7 @@ export function getExecutionContext(pageObjectNode) {
contextName = 'integration';
} else if (isAcceptanceTest()) {
contextName = 'acceptance';
} else if (isRfc268Test()) {
} else if (supportsRfc268()) {
contextName = 'rfc268';
}

Expand All @@ -51,7 +51,7 @@ function isAcceptanceTest() {
/**
* @private
*/
export function isRfc268Test() {
export function supportsRfc268() {
// `getContext()` returns:
// - falsey, if @ember/test-helpers is not available (stubbed in
// compatibility.js)
Expand Down
4 changes: 2 additions & 2 deletions addon-test-support/create.js
Expand Up @@ -3,7 +3,7 @@ import { render, setContext, removeContext } from './-private/context';
import { assign, getPageObjectDefinition, isPageObject, storePageObjectDefinition } from './-private/helpers';
import { visitable } from './properties/visitable';
import dsl from './-private/dsl';
import { isRfc268Test } from './-private/execution_context';
import { supportsRfc268 as supportsRfc268 } from './-private/execution_context';

//
// When running RFC268 tests, we have to play some tricks to support chaining.
Expand Down Expand Up @@ -207,7 +207,7 @@ export function create(definitionOrUrl, definitionOrOptions, optionsOrNothing) {
page.setContext = setContext;
page.removeContext = removeContext;

if (context || !isRfc268Test()) {
if (context || !supportsRfc268()) {
page.setContext(context);
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/helpers/properties/integration-adapter.js
Expand Up @@ -3,6 +3,7 @@ import $ from '-jquery';
export { moduleForComponent as moduleForIntegration, test as testForIntegration } from 'ember-qunit';
import expectEmberError from '../../expect-ember-error';
import hbs from 'htmlbars-inline-precompile';
import { supportsRfc268 } from 'ember-cli-page-object/test-support/-private/execution_context';

export function IntegrationAdapter(context) {
this.context = context;
Expand Down Expand Up @@ -31,7 +32,9 @@ IntegrationAdapter.prototype = {
test.set('raw', template);
}

page.setContext(test);
if (!supportsRfc268()) {
page.setContext(test);
}

this.context.render(hbs`{{html-render html=raw}}`);
},
Expand Down
Expand Up @@ -3,10 +3,10 @@ import { setupTest } from 'ember-qunit';
import require from 'require';

if (require.has('@ember/test-helpers')) {
module('Unit | is rfc268 test', function(hooks) {
function isRfc268Test() {
module('Unit | supports rfc268', function(hooks) {
function supportsRfc268() {
window.require.unsee('ember-cli-page-object/test-support/-private/execution_context');
return require('ember-cli-page-object/test-support/-private/execution_context').isRfc268Test();
return require('ember-cli-page-object/test-support/-private/execution_context').supportsRfc268();
}

hooks.afterEach(function() {
Expand All @@ -30,18 +30,19 @@ if (require.has('@ember/test-helpers')) {
});

test('works', function(assert) {
assert.ok(isRfc268Test());
assert.ok(supportsRfc268());
});

test('throws without visit() present', function(assert) {
compatModule.visit = undefined;
assert.throws(isRfc268Test);

assert.throws(() => supportsRfc268());
});
});

module('without context', function() {
test('works', function(assert) {
assert.notOk(isRfc268Test());
assert.notOk(supportsRfc268());
});
});
});
Expand Down

0 comments on commit 9636abd

Please sign in to comment.