signal-desktop/test/views/scroll_down_button_view_test.js

36 lines
1 KiB
JavaScript
Raw Normal View History

2018-11-02 18:02:53 +00:00
/* global Whisper */
describe('ScrollDownButtonView', () => {
it('renders with count = 0', () => {
const view = new Whisper.ScrollDownButtonView();
2018-04-27 21:25:04 +00:00
view.render();
assert.equal(view.count, 0);
assert.match(view.$el.html(), /Scroll to bottom/);
});
2018-11-02 18:02:53 +00:00
it('renders with count = 1', () => {
const view = new Whisper.ScrollDownButtonView({ count: 1 });
2018-04-27 21:25:04 +00:00
view.render();
assert.equal(view.count, 1);
assert.match(view.$el.html(), /New message below/);
});
2018-11-02 18:02:53 +00:00
it('renders with count = 2', () => {
const view = new Whisper.ScrollDownButtonView({ count: 2 });
2018-04-27 21:25:04 +00:00
view.render();
assert.equal(view.count, 2);
2018-04-27 21:25:04 +00:00
assert.match(view.$el.html(), /New messages below/);
});
2018-11-02 18:02:53 +00:00
it('increments count and re-renders', () => {
const view = new Whisper.ScrollDownButtonView();
2018-04-27 21:25:04 +00:00
view.render();
assert.equal(view.count, 0);
assert.notMatch(view.$el.html(), /New message below/);
2018-04-27 21:25:04 +00:00
view.increment(1);
assert.equal(view.count, 1);
assert.match(view.$el.html(), /New message below/);
2018-04-27 21:25:04 +00:00
});
});