signal-desktop/ts/test-electron/views/whisper_view_test.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

// Copyright 2015-2022 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
2018-11-02 18:02:53 +00:00
describe('Whisper.View', () => {
it('renders a template with render_attributes', () => {
const ViewClass = window.Whisper.View.extend({
template: '<div>{{ variable }}</div>',
render_attributes: {
2018-04-27 21:25:04 +00:00
variable: 'value',
},
});
2018-11-02 18:02:53 +00:00
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
2018-11-02 18:02:53 +00:00
it('renders a template with no render_attributes', () => {
const ViewClass = window.Whisper.View.extend({
2018-04-27 21:25:04 +00:00
template: '<div>static text</div>',
});
2018-11-02 18:02:53 +00:00
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>static text</div>');
});
2018-11-02 18:02:53 +00:00
it('renders a template function with render_attributes function', () => {
const ViewClass = window.Whisper.View.extend({
2018-11-02 18:02:53 +00:00
template() {
2018-04-27 21:25:04 +00:00
return '<div>{{ variable }}</div>';
},
2018-11-02 18:02:53 +00:00
render_attributes() {
return { variable: 'value' };
2018-04-27 21:25:04 +00:00
},
});
2018-11-02 18:02:53 +00:00
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
});