Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test that atoms do not rerender when section changes #105

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/integration/components/mobiledoc-editor/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,3 +951,46 @@ test('calls `unknownAtomHandler` when it renders an unknown atom', function(asse
{{/mobiledoc-editor}}
`);
});

// See https://github.com/bustlelabs/ember-mobiledoc-editor/issues/90
test('does not rerender atoms when updating text in section', function(assert) {
let renderCount = 0;
this.registerAtomComponent('ember-atom', hbs`I AM AN ATOM`, Component.extend({
tagName: 'span',
didRender() {
renderCount++;
}
}));
this.set('atoms', [createComponentAtom('ember-atom')]);
this.set('mobiledoc', {
version: MOBILEDOC_VERSION,
atoms: [
['ember-atom', 'value', {}]
],
markups: [],
cards: [],
sections: [
[1, 'P', [
[1, [], 0, 0]]
]
]
});

let editor;
this.on('didCreateEditor', (_editor) => editor = _editor);

this.render(hbs`
{{#mobiledoc-editor mobiledoc=mobiledoc
atoms=atoms
did-create-editor=(action 'didCreateEditor')as |editor|}}
{{/mobiledoc-editor}}
`);

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

return selectRangeWithEditor(editor, editor.post.tailPosition()).then(() => {
Ember.run(() => editor.insertText('abc'));
}).then(() => {
assert.equal(renderCount, 1, 'still only 1 render of the atom');
});
});