Skip to content

Commit

Permalink
test(beta): Fix beta tests, update to wormhole ^0.4.1 (#108)
Browse files Browse the repository at this point in the history
Fixes #99
  • Loading branch information
bantic authored Sep 13, 2016
1 parent 2a3e9a0 commit d24182b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"broccoli-merge-trees": "^1.1.1",
"ember-cli-babel": "^5.1.6",
"ember-cli-htmlbars": "^1.0.0",
"ember-wormhole": "^0.4.0",
"ember-wormhole": "^0.4.1",
"mobiledoc-kit": "^0.10.9"
},
"ember-addon": {
Expand Down
24 changes: 16 additions & 8 deletions tests/integration/components/mobiledoc-editor/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
simpleMobileDoc, blankMobiledoc, linkMobileDoc, mobiledocWithCard
} from '../../../helpers/create-mobiledoc';
import wait from 'ember-test-helpers/wait';

let { Component } = Ember;

Expand Down Expand Up @@ -479,21 +480,23 @@ test('it adds a card and focuses the cursor at the end of the card', function(as
assert.expect(7);

let card = this.registerCardComponent('demo-card', hbs`
<div id="demo-card"><button id='edit-card' {{action editCard}}>ADD CARD</button></div>
<div id="demo-card"><button id='edit-card' {{action editCard}}>DEMO CARD</button></div>
`);
this.set('cards', [card]);
let editor;
this.on('didCreateEditor', (_editor) => editor = _editor);
this.set('mobiledoc', simpleMobileDoc());
this.render(hbs`
{{#mobiledoc-editor autofocus=false did-create-editor=(action 'didCreateEditor') mobiledoc=mobiledoc cards=cards as |editor|}}
<button id='add-card' {{action editor.addCard 'demo-card'}}></button>
<button id='add-card' {{action editor.addCard 'demo-card'}}>ADD CARD</button>
{{/mobiledoc-editor}}
`);

return selectRangeWithEditor(editor, editor.post.tailPosition()).then(() => {
assert.ok(editor && !editor.range.isBlank, 'range is not blank');
this.$('button#add-card').click();
return wait();
}).then(() => {
assert.equal(this.$('#demo-card').length, 1, 'card section exists');

let cardWrapper = this.$('#demo-card').parents('.__mobiledoc-card');
Expand Down Expand Up @@ -526,7 +529,8 @@ test('can add a card to a blank post', function(assert) {
return selectRange(editorEl, 0, editorEl, 0).then(() => {
assert.ok(editor.hasCursor(), 'precond - editor has cursor');
assert.ok(!this.$('#demo-card').length, 'precond - no card inserted');
return Ember.run(() => editor.insertCard('demo-card'));
Ember.run(() => editor.insertCard('demo-card'));
return wait();
}).then(() => {
assert.ok(this.$('#demo-card').length, 'inserts card');
});
Expand Down Expand Up @@ -855,6 +859,8 @@ test('exposes `addAtom` action to add an atom', function(assert) {
assert.ok(button.length, 'precond - has button');
assert.ok(!this.$('span:contains(I AM AN ATOM)').length, 'precond - no atom');
button.click();
return wait();
}).then(() => {

assert.ok(this.$('span:contains(I AM AN ATOM)').length, 'atom is added after clicking');

Expand Down Expand Up @@ -982,15 +988,17 @@ test('does not rerender atoms when updating text in section', function(assert) {
this.render(hbs`
{{#mobiledoc-editor mobiledoc=mobiledoc
atoms=atoms
did-create-editor=(action 'didCreateEditor')as |editor|}}
did-create-editor=(action 'didCreateEditor') as |editor|}}
{{/mobiledoc-editor}}
`);

assert.equal(renderCount, 1, 'precond - initially renders atom');

return selectRangeWithEditor(editor, editor.post.tailPosition()).then(() => {
return wait().then(() => {
renderCount = 0;
return selectRangeWithEditor(editor, editor.post.tailPosition());
}).then(() => {
Ember.run(() => editor.insertText('abc'));
return wait();
}).then(() => {
assert.equal(renderCount, 1, 'still only 1 render of the atom');
assert.equal(renderCount, 0, 'does not rerender atom when inserting text');
});
});

0 comments on commit d24182b

Please sign in to comment.