Skip to content

Commit

Permalink
Merge pull request #62 from yapplabs/improve-testing
Browse files Browse the repository at this point in the history
Respect MODAL_DIALOG_USE_TETHER application property
  • Loading branch information
chrislopresto committed Jul 27, 2015
2 parents 64c47fa + 5ce019e commit 9f5890f
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 137 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ cache:
- node_modules

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=1.10.0
- EMBER_TRY_SCENARIO=1.11.3
- EMBER_TRY_SCENARIO=ember-1.10
- EMBER_TRY_SCENARIO=ember-1.11
- EMBER_TRY_SCENARIO=ember-1.12
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=1.10.0
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary

Expand Down
5 changes: 2 additions & 3 deletions addon/components/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export default Ember.Component.extend({
layout: template,
modalService: injectService('modal-dialog'),
destinationElementId: reads('modalService.destinationElementId'),
hasEmberTether: reads('modalService.hasEmberTether'),

useEmberTether: computed('hasEmberTether', 'alignment', 'renderInPlace', function() {
return this.get('hasEmberTether') && (this.get('alignment') !== 'none') && !this.get('renderInPlace');
useEmberTether: computed('modalService.useEmberTether', 'alignment', 'renderInPlace', function() {
return this.get('modalService.useEmberTether') && (this.get('alignment') !== 'none') && !this.get('renderInPlace');
}),

'container-class': null, // set this from templates
Expand Down
13 changes: 8 additions & 5 deletions addon/initializers/add-modals-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ export default function(container, application){
'destinationElementId',
'config:modals-container-id');

const hasEmberTether = Ember.isPresent(container.resolve('component:ember-tether'));
application.register('config:has-ember-tether',
hasEmberTether,
var useEmberTether = application.MODAL_DIALOG_USE_TETHER;
if (useEmberTether === undefined) {
useEmberTether = Ember.isPresent(container.resolve('component:ember-tether'));
}
application.register('config:use-ember-tether',
useEmberTether,
{ instantiate: false });

application.inject('service:modal-dialog',
'hasEmberTether',
'config:has-ember-tether');
'useEmberTether',
'config:use-ember-tether');

appendContainerElement(application.rootElement, modalContainerElId);
}
2 changes: 1 addition & 1 deletion addon/services/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import Ember from 'ember';

export default Ember.Service.extend({
destinationElementId: null, // injected
hasEmberTether: null // injected
useEmberTether: null // injected
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"ember-disable-prototype-extensions": "^1.0.0",
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "^1.0.2",
"ember-legacy-views": "0.2.0",
"ember-tether": "^0.1.3",
"ember-try": "0.0.6",
"glob": "4.4.0"
Expand Down
10 changes: 2 additions & 8 deletions tests/acceptance/modal-dialogs-test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
import { stubResolver } from '../helpers/container';

var application;
const modalRootElementSelector = '#modal-overlays';
const overlaySelector = '.ember-modal-overlay';
const dialogSelector = '.ember-modal-dialog';
const dialogCloseButton = [dialogSelector, 'button'].join(' ');

var modalDialogService = Ember.Service.extend({
destinationElementId: 'modal-overlays',
hasEmberTether: true
});

module('Acceptance: Display Modal Dialogs With Tether', {
beforeEach: function() {
application = startApp({}, function(app) {
stubResolver(app, 'service:modal-dialog', modalDialogService);
application = startApp({
MODAL_DIALOG_USE_TETHER: true
});
},

Expand Down
10 changes: 2 additions & 8 deletions tests/acceptance/modal-dialogs-without-tether-test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
import { stubResolver } from '../helpers/container';

var application;
const modalRootElementSelector = '#modal-overlays';
const overlaySelector = '.ember-modal-overlay';
const dialogSelector = '.ember-modal-dialog';
const dialogCloseButton = [dialogSelector, 'button'].join(' ');

var modalDialogService = Ember.Service.extend({
destinationElementId: 'modal-overlays',
hasEmberTether: false
});

module('Acceptance: Display Modal Dialogs Without Tether', {
beforeEach: function() {
application = startApp({}, function(app) {
stubResolver(app, 'service:modal-dialog', modalDialogService);
application = startApp({
MODAL_DIALOG_USE_TETHER: false
});
},

Expand Down
48 changes: 0 additions & 48 deletions tests/dummy/app/initializers/add-modals-container.js

This file was deleted.

9 changes: 0 additions & 9 deletions tests/helpers/container.js

This file was deleted.

8 changes: 1 addition & 7 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ export default function startApp(attrs, cb) {
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;

Ember.run(function() {
application = Application.extend({
init() {
this._super(...arguments);
if (typeof cb === 'function') { cb(this); }
}
}).create(attributes);

application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
registerAssertHelpers();
Expand Down
44 changes: 0 additions & 44 deletions tests/unit/components/component-that-uses-modal-dialog-test.js

This file was deleted.

0 comments on commit 9f5890f

Please sign in to comment.