whisper_view_test.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. describe('Whisper.View', function() {
  2. it('renders a template with render_attributes', function() {
  3. var viewClass = Whisper.View.extend({
  4. template: '<div>{{ variable }}</div>',
  5. render_attributes: {
  6. variable: 'value'
  7. }
  8. });
  9. var view = new viewClass();
  10. view.render();
  11. assert.strictEqual(view.$el.html(), '<div>value</div>');
  12. });
  13. it('renders a template with no render_attributes', function() {
  14. var viewClass = Whisper.View.extend({
  15. template: '<div>static text</div>'
  16. });
  17. var view = new viewClass();
  18. view.render();
  19. assert.strictEqual(view.$el.html(), '<div>static text</div>');
  20. });
  21. it('renders a template function with render_attributes function', function() {
  22. var viewClass = Whisper.View.extend({
  23. template: function() { return '<div>{{ variable }}</div>'; },
  24. render_attributes: function() {
  25. return { variable: 'value' };
  26. }
  27. });
  28. var view = new viewClass();
  29. view.render();
  30. assert.strictEqual(view.$el.html(), '<div>value</div>');
  31. });
  32. });