session-desktop/test/views/whisper_view_test.js

39 lines
1 KiB
JavaScript
Raw Normal View History

2018-11-02 19:02:53 +01:00
/* global Whisper */
describe('Whisper.View', () => {
it('renders a template with render_attributes', () => {
const ViewClass = Whisper.View.extend({
template: '<div>{{ variable }}</div>',
render_attributes: {
2018-04-27 23:25:04 +02:00
variable: 'value',
},
});
2018-11-02 19:02:53 +01:00
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
2018-11-02 19:02:53 +01:00
it('renders a template with no render_attributes', () => {
const ViewClass = Whisper.View.extend({
2018-04-27 23:25:04 +02:00
template: '<div>static text</div>',
});
2018-11-02 19:02:53 +01:00
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>static text</div>');
});
2018-11-02 19:02:53 +01:00
it('renders a template function with render_attributes function', () => {
const ViewClass = Whisper.View.extend({
template() {
2018-04-27 23:25:04 +02:00
return '<div>{{ variable }}</div>';
},
2018-11-02 19:02:53 +01:00
render_attributes() {
return { variable: 'value' };
2018-04-27 23:25:04 +02:00
},
});
2018-11-02 19:02:53 +01:00
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
});