signal-desktop/test/views/whisper_view_test.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

describe('Whisper.View', function() {
it('renders a template with render_attributes', function() {
var viewClass = Whisper.View.extend({
template: '<div>{{ variable }}</div>',
render_attributes: {
2018-04-27 21:25:04 +00:00
variable: 'value',
},
});
var view = new viewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
it('renders a template with no render_attributes', function() {
var viewClass = Whisper.View.extend({
2018-04-27 21:25:04 +00:00
template: '<div>static text</div>',
});
var view = new viewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>static text</div>');
});
it('renders a template function with render_attributes function', function() {
var viewClass = Whisper.View.extend({
2018-04-27 21:25:04 +00:00
template: function() {
return '<div>{{ variable }}</div>';
},
render_attributes: function() {
return { variable: 'value' };
2018-04-27 21:25:04 +00:00
},
});
var view = new viewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
});