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