Skip to content

Commit

Permalink
Rename native-dom to native-events
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Nov 13, 2017
1 parent 9642c13 commit e50127a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 64 deletions.
24 changes: 0 additions & 24 deletions addon/-private/execution_context/acceptance-native-dom.js

This file was deleted.

25 changes: 25 additions & 0 deletions addon/-private/execution_context/acceptance-native-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ExecutionContext from './native-events-context';
import wait from 'ember-test-helpers/wait';

import {
visit
} from 'ember-native-dom-helpers';

export default function AcceptanceNativeEventsExecutionContext(pageObjectNode) {
ExecutionContext.call(this, pageObjectNode);
}

AcceptanceNativeEventsExecutionContext.prototype = Object.create(ExecutionContext.prototype);

AcceptanceNativeEventsExecutionContext.prototype.visit = function() {
return visit(...arguments);
};

AcceptanceNativeEventsExecutionContext.prototype.runAsync = function(cb) {
(window.wait || wait)().then(() => {
cb(this);
});

return this.pageObjectNode;
};

20 changes: 0 additions & 20 deletions addon/-private/execution_context/integration-native-dom.js

This file was deleted.

21 changes: 21 additions & 0 deletions addon/-private/execution_context/integration-native-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ExecutionContext from './native-events-context';

import Ember from 'ember';
const { run } = Ember;

export default function IntegrationNativeEventsExecutionContext(pageObjectNode, testContext) {
ExecutionContext.call(this, pageObjectNode, testContext);
}

IntegrationNativeEventsExecutionContext.prototype = Object.create(ExecutionContext.prototype);

IntegrationNativeEventsExecutionContext.prototype.visit = function() {};

IntegrationNativeEventsExecutionContext.prototype.runAsync = function(cb) {
run(() => {
cb(this);
});

return this.pageObjectNode;
};

12 changes: 6 additions & 6 deletions addon/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ export { findElementWithAssert } from './-private/extend/find-element-with-asser
export { buildSelector, getContext, fullScope } from './-private/helpers';
import { register as registerExecutionContext } from './-private/execution_context';

import IntegrationNativeDOMContext from './-private/execution_context/integration-native-dom';
import AcceptanceNativeDOMContext from './-private/execution_context/acceptance-native-dom';
import IntegrationNativeEventsContext from './-private/execution_context/integration-native-events';
import AcceptanceNativeEventsContext from './-private/execution_context/acceptance-native-events';
import IntegrationEmberContext from './-private/execution_context/integration';
import AcceptanceEmberContext from './-private/execution_context/acceptance';

function useNativeDOMHelpers(flag = true) {
function useNativeEvents(flag = true) {
if (flag) {
registerExecutionContext('integration', IntegrationNativeDOMContext);
registerExecutionContext('acceptance', AcceptanceNativeDOMContext);
registerExecutionContext('integration', IntegrationNativeEventsContext);
registerExecutionContext('acceptance', AcceptanceNativeEventsContext);
} else {
registerExecutionContext('integration', IntegrationEmberContext);
registerExecutionContext('acceptance', AcceptanceEmberContext);
}
}

export { registerExecutionContext, useNativeDOMHelpers };
export { registerExecutionContext, useNativeEvents };
12 changes: 6 additions & 6 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
import { useNativeDOMHelpers } from 'ember-cli-page-object/extend';
import { useNativeEvents } from 'ember-cli-page-object/extend';

const { RSVP: { Promise } } = Ember;

export default function(name, options = {}) {
[false, true].forEach(_useNativeDOMHelpers => {
[false, true].forEach(_useNativeEvents => {
let moduleName = name;
if (_useNativeDOMHelpers) {
moduleName += ' [native-dom-helpers]';
if (_useNativeEvents) {
moduleName += ' [native-events]';
}

module(moduleName, {
beforeEach() {
this.application = startApp();

useNativeDOMHelpers(_useNativeDOMHelpers);
useNativeEvents(_useNativeEvents);

if (options.beforeEach) {
return options.beforeEach.apply(this, arguments);
}
},

afterEach() {
useNativeDOMHelpers(false);
useNativeEvents(false);

let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
Expand Down
16 changes: 8 additions & 8 deletions tests/helpers/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ import { AcceptanceAdapter, moduleForAcceptance, testForAcceptance } from './pro

import { IntegrationAdapter, moduleForIntegration, testForIntegration } from './properties/integration-adapter';

import { useNativeDOMHelpers } from 'ember-cli-page-object/extend';
import { useNativeEvents } from 'ember-cli-page-object/extend';

export function moduleForProperty(name, cbOrOptions, cb) {
let options = cb ? cbOrOptions : {};
cb = cb || cbOrOptions;

[true, false].forEach(_useNativeDOMHelpers => {
[true, false].forEach(_useNativeEvents => {
// Generate acceptance tests

let moduleNamePrefix = 'Acceptance mode ';
if (_useNativeDOMHelpers) {
moduleNamePrefix += ' [native-dom-helpers]';
if (_useNativeEvents) {
moduleNamePrefix += '[native-events]';
}

moduleForAcceptance(`${moduleNamePrefix} | Property | ${name}`, {
beforeEach() {
useNativeDOMHelpers(_useNativeDOMHelpers);
useNativeEvents(_useNativeEvents);

this.adapter = new AcceptanceAdapter();
},

afterEach() {
useNativeDOMHelpers(false);
useNativeEvents(false);
this.adapter.revert();
}
});
Expand All @@ -38,12 +38,12 @@ export function moduleForProperty(name, cbOrOptions, cb) {
moduleForIntegration('html-render', `Integration mode | Property | ${name}`, {
integration: true,
beforeEach() {
useNativeDOMHelpers(_useNativeDOMHelpers);
useNativeEvents(_useNativeEvents);

this.adapter = new IntegrationAdapter();
},
afterEach() {
useNativeDOMHelpers(false);
useNativeEvents(false);
this.adapter.revert();
}
});
Expand Down

0 comments on commit e50127a

Please sign in to comment.