Skip to content

Commit

Permalink
enhance template-tab-test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcpk committed Jan 10, 2018
1 parent 7068c20 commit e93a44f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/instance-initializers/create-default-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function initialize(appInstance) {
// Check if templates are available, if not create one
store.findAll('template').then((templates) => {
if (templates.length === 0) {
store.createRecord('template', defaultTemplate);
store.createRecord('template', defaultTemplate).save();
}
})
}
Expand Down
34 changes: 22 additions & 12 deletions tests/integration/components/template-tab-test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

const testTemplate = {
title: 'Test Template',
markup: '<markup>'
}

moduleForComponent('template-tab', 'Integration | Component | template tab', {
integration: true
});

test('it renders', function(assert) {
test('it renders title and markup properly', function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });

this.render(hbs`{{template-tab}}`);

assert.equal(this.$().text().trim(), '');

// Template block usage:
this.render(hbs`
{{#template-tab}}
template block text
{{/template-tab}}
`);
this.set('template', testTemplate);
this.set('saveTemplate', () => { /* do nothing */});
this.set('rollbackTemplate', () => { /* do nothing */});
this.set('deleteTemplate', () => { /* do nothing */});

assert.equal(this.$().text().trim(), 'template block text');

this.render(hbs`{{template-tab
isOpen=true
template=template
saveTemplate=(action saveTemplate)
rollbackTemplate=(action rollbackTemplate)
deleteTemplate=(action deleteTemplate)}}`);

// rendered title matches expected title
assert.equal(this.$().find('.panel-title').text().trim(), testTemplate.title);
// rendered code matches expected code
assert.equal(this.$().find('.CodeMirror-code pre').text(), testTemplate.markup);
});

0 comments on commit e93a44f

Please sign in to comment.