signal-desktop/test/views/inbox_view_test.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-11-02 11:02:53 -07:00
/* global ConversationController, textsecure, Whisper */
describe('InboxView', () => {
let inboxView;
let conversation;
2018-09-20 18:47:19 -07:00
before(async () => {
2018-11-02 11:02:53 -07:00
ConversationController.reset();
await ConversationController.load();
2019-01-14 13:49:58 -08:00
await textsecure.storage.user.setNumberAndDeviceId(
'18005554444',
1,
'Home Office'
);
2018-09-20 18:47:19 -07:00
await ConversationController.getOrCreateAndWait(
textsecure.storage.user.getNumber(),
'private'
);
inboxView = new Whisper.InboxView({
model: {},
2018-11-02 11:02:53 -07:00
window,
initialLoadComplete() {},
}).render();
conversation = new Whisper.Conversation({
id: '1234',
type: 'private',
});
});
2018-11-02 11:02:53 -07:00
describe('the conversation stack', () => {
it('should be rendered', () => {
2018-04-27 17:25:04 -04:00
assert.ok(inboxView.$('.conversation-stack').length === 1);
});
2018-11-02 11:02:53 -07:00
describe('opening a conversation', () => {
let triggeredOpenedCount = 0;
2018-11-02 11:02:53 -07:00
before(() => {
conversation.on('opened', () => {
triggeredOpenedCount += 1;
2018-04-27 17:25:04 -04:00
});
2018-04-27 17:25:04 -04:00
inboxView.conversation_stack.open(conversation);
});
2018-11-02 11:02:53 -07:00
it('should trigger an opened event', () => {
2018-04-27 17:25:04 -04:00
assert.ok(triggeredOpenedCount === 1);
});
2018-11-02 11:02:53 -07:00
describe('and then opening it again immediately', () => {
before(() => {
2018-04-27 17:25:04 -04:00
inboxView.conversation_stack.open(conversation);
});
2018-11-02 11:02:53 -07:00
it('should trigger the opened event again', () => {
2018-04-27 17:25:04 -04:00
assert.ok(triggeredOpenedCount === 2);
});
2018-04-27 17:25:04 -04:00
});
});
2018-04-27 17:25:04 -04:00
});
});