/* global Whisper */
describe('Whisper.View', () => {
it('renders a template with render_attributes', () => {
const ViewClass = Whisper.View.extend({
template: '
{{ variable }}
',
render_attributes: {
variable: 'value',
},
});
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), 'value
');
});
it('renders a template with no render_attributes', () => {
const ViewClass = Whisper.View.extend({
template: 'static text
',
});
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), 'static text
');
});
it('renders a template function with render_attributes function', () => {
const ViewClass = Whisper.View.extend({
template() {
return '{{ variable }}
';
},
render_attributes() {
return { variable: 'value' };
},
});
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), 'value
');
});
});