2017-05-19 01:33:35 +00:00
|
|
|
describe('ScrollDownButtonView', function() {
|
2018-04-27 21:25:04 +00:00
|
|
|
it('renders with count = 0', function() {
|
|
|
|
var view = new Whisper.ScrollDownButtonView();
|
|
|
|
view.render();
|
|
|
|
assert.equal(view.count, 0);
|
|
|
|
assert.match(view.$el.html(), /Scroll to bottom/);
|
|
|
|
});
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
it('renders with count = 1', function() {
|
|
|
|
var view = new Whisper.ScrollDownButtonView({ count: 1 });
|
|
|
|
view.render();
|
|
|
|
assert.equal(view.count, 1);
|
|
|
|
assert.match(view.$el.html(), /new-messages/);
|
|
|
|
assert.match(view.$el.html(), /New message below/);
|
|
|
|
});
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
it('renders with count = 2', function() {
|
|
|
|
var view = new Whisper.ScrollDownButtonView({ count: 2 });
|
|
|
|
view.render();
|
|
|
|
assert.equal(view.count, 2);
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
assert.match(view.$el.html(), /new-messages/);
|
|
|
|
assert.match(view.$el.html(), /New messages below/);
|
|
|
|
});
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
it('increments count and re-renders', function() {
|
|
|
|
var view = new Whisper.ScrollDownButtonView();
|
|
|
|
view.render();
|
|
|
|
assert.equal(view.count, 0);
|
|
|
|
assert.notMatch(view.$el.html(), /new-messages/);
|
|
|
|
view.increment(1);
|
|
|
|
assert.equal(view.count, 1);
|
|
|
|
assert.match(view.$el.html(), /new-messages/);
|
|
|
|
});
|
2017-05-19 01:33:35 +00:00
|
|
|
});
|