Skip to content

Commit

Permalink
Fix New Style testing helpers usage to support integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Astapov committed Feb 27, 2018
1 parent 3f05c80 commit af0cd86
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -152,7 +152,7 @@ module('Acceptance | Awesome page', function(hooks) {
setupApplicationTest(hooks);

test('links go to the new homepage', async function (assert) {
enableFeature(this.owner, 'new-homepage');
enableFeature('new-homepage');

await visit('/');
await click('a.home');
Expand Down
4 changes: 4 additions & 0 deletions addon-test-support/-private/enable-feature.js
@@ -0,0 +1,4 @@
export function _enableFeature(owner, featureName) {
let featuresService = owner.lookup('service:features');
featuresService.enable(featureName);
}
4 changes: 2 additions & 2 deletions addon-test-support/helpers/with-feature.js
@@ -1,6 +1,6 @@
import { registerHelper } from '@ember/test';
import { enableFeature } from '../index';
import { _enableFeature } from '../-private/enable-feature';

registerHelper('withFeature', function withFeature(app, featureName) {
enableFeature(app.__container__, featureName);
_enableFeature(app.__deprecatedInstance__, featureName);
});
9 changes: 6 additions & 3 deletions addon-test-support/index.js
@@ -1,4 +1,7 @@
export function enableFeature(owner, featureName) {
let featuresService = owner.lookup('service:features');
featuresService.enable(featureName);
import { getContext } from '@ember/test-helpers';
import { _enableFeature } from './-private/enable-feature';

export function enableFeature(featureName) {
let { owner } = getContext();
_enableFeature(owner, featureName);
}
2 changes: 1 addition & 1 deletion tests/acceptance/feature-flags-new-style-test.js
Expand Up @@ -7,7 +7,7 @@ module('Acceptance | feature flags with new-style acceptance tests', function(ho
setupApplicationTest(hooks);

test('visiting / with acceptance-feature on', async function(assert) {
enableFeature(this.owner, 'acceptance-feature');
enableFeature('acceptance-feature');

await visit('/');

Expand Down

0 comments on commit af0cd86

Please sign in to comment.