Skip to content

Commit

Permalink
Improved tests
Browse files Browse the repository at this point in the history
Still work to be done but at least tests pass now. I’ve added a few
commented out tests that I intend to complete when time allows.
  • Loading branch information
Panman82 committed Mar 11, 2016
1 parent 5fba9a6 commit 2eb55c6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
6 changes: 1 addition & 5 deletions tests/integration/components/froala-content-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ test('.fr-view class is applied', function(assert) {

this.render(hbs`{{froala-content}}`);

// Ug! This isn't working properly,
// .attr('class') revels _only_ the ember-view class,
// but inspecting in the dummy app shows the fr-view class...
// TODO: Fix!
assert.ok(this.$().hasClass('fr-view'));
assert.ok(this.$().find('.fr-view').length);

});

Expand Down
56 changes: 54 additions & 2 deletions tests/integration/components/froala-editor-test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,69 @@
import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('froala-editor', 'Integration | Component | froala editor', {
integration: true
});



test('.fr-box class is applied', function(assert) {

this.set('runAsserts', () => {
// TODO: For some reason this.$() is not reflecting changes made by froala...
assert.ok(this.$().hasClass('fr-box'));
assert.ok(this.$().find('.fr-box').length);
});

this.render(hbs`{{froala-editor on-initialized=runAsserts}}`);

});



test('content attribute is set as editor content', function(assert) {

let foobar = '<p>Foobar</p>';

this.set('runAsserts', (event, component) => {
assert.equal(component.get('editor').html.get(), foobar);
});

this.set('foobar', foobar);

this.render(hbs`{{froala-editor content=foobar on-initialized=runAsserts}}`);

});



// test('content attribute binding is working', function(assert) {});
// test('updating content attribute updates editor content', function(assert) {});
// test('changing defaultContent works', function(assert) {});
// test('options and defaultOptions are merged, with options taking priority', function(assert) {});
// test('SafeString in, SafeString out', function(assert) {});



test('SafeString in, SafeString out (via *-getHtml event handler)', function(assert) {

this.set('runAsserts', html => {
assert.ok(html instanceof Ember.Handlebars.SafeString);
});

this.set('safestring', Ember.String.htmlSafe('<p>This is safe!</p>'));

this.render(hbs`{{froala-editor content=safestring on-initialized-getHtml=runAsserts}}`);

});



test('*-getHtml event handler should return a string as the first param', function(assert) {

this.set('runAsserts', html => {
assert.ok(typeof html === 'string');
});

this.render(hbs`{{froala-editor on-initialized-getHtml=runAsserts}}`);

});

0 comments on commit 2eb55c6

Please sign in to comment.