Skip to content

Commit

Permalink
Merge pull request #68 from simonihmig/test-dynamic-content
Browse files Browse the repository at this point in the history
Test for dynamic content in Glimmer2
  • Loading branch information
lukemelia authored Oct 6, 2016
2 parents 5bd5c28 + c294b12 commit 8bc17e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/acceptance/wormhole-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,21 @@ test('document-title example', function(assert) {
assert.equal(document.title, 'ember-wormhole');
});
});

// tests for dynamic content updates inside wormhole, which is failing with Glimmer2, see https://github.com/yapplabs/ember-wormhole/issues/66
test('toggle modal overlay', function(assert) {
visit('/');
andThen(function() {
assert.equal(currentPath(), 'index');
});
click('button:contains(Toggle Modal)');
andThen(function() {
assert.equal($('#modals .overlay').length, 1, 'overlay is visible');
assert.equal($('#modals .dialog').length, 1, 'dialog is visible');
});
click('button:contains(Toggle Overlay)');
andThen(function() {
assert.equal($('#modals .overlay').length, 0, 'overlay is not visible');
assert.equal($('#modals .dialog').length, 1, 'dialog is still visible');
});
});
4 changes: 4 additions & 0 deletions tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default Ember.Controller.extend({
isInPlace: false,
isTestingDocumentTitle: false,
favicon: "http://emberjs.com/images/favicon.png",
isShowingOverlay: true,
actions: {
toggleModal() {
this.toggleProperty('isShowingModal');
Expand All @@ -25,6 +26,9 @@ export default Ember.Controller.extend({
},
toggleTitle() {
this.toggleProperty('isTestingDocumentTitle');
},
toggleOverlay() {
this.toggleProperty('isShowingOverlay');
}
}
});
3 changes: 3 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@
</label>
{{#if isShowingModal}}
{{#ember-wormhole to='modals'}}
{{#if isShowingOverlay}}
<div class="overlay" {{action 'toggleModal'}}></div>
{{/if}}
<div class="dialog">
<h1>Hi, I'm a simple modal dialog</h1>
<p>Here we have some content which is bound from the context
where the wormhole component was used: "{{user.username}}"</p>
<button {{action 'toggleModal'}}>Close</button>
<button {{action 'toggleOverlay'}}>Toggle Overlay</button>
</div>
{{/ember-wormhole}}
{{/if}}
Expand Down

0 comments on commit 8bc17e2

Please sign in to comment.