session-desktop/test/views/inbox_view_test.js
Mikunj 12ce0140de Left pane changes.
Merge commit 'b3ac1373fa64117fe2a9ccfddf3712f1826c06d9' into signal-1.23

# Conflicts:
#	_locales/en/messages.json
#	background.html
#	js/background.js
#	js/conversation_controller.js
#	js/models/conversations.js
#	js/models/messages.js
#	js/views/conversation_list_item_view.js
#	js/views/conversation_list_view.js
#	js/views/conversation_search_view.js
#	js/views/inbox_view.js
#	libtextsecure/account_manager.js
#	package.json
#	stylesheets/_global.scss
#	stylesheets/_index.scss
#	stylesheets/_modules.scss
#	test/_test.js
#	test/index.html
#	test/models/conversations_test.js
#	test/views/conversation_search_view_test.js
#	ts/components/ConversationListItem.tsx
#	ts/components/MainHeader.tsx
#	ts/components/conversation/ConversationHeader.tsx
#	ts/components/conversation/ResetSessionNotification.tsx
2019-04-17 16:42:09 +10:00

68 lines
1.7 KiB
JavaScript

/* global storage, libsignal, ConversationController, textsecure, Whisper */
describe('InboxView', () => {
let inboxView;
let conversation;
let identityKey;
before(async () => {
ConversationController.reset();
identityKey = {
pubKey: libsignal.crypto.getRandomBytes(33),
privKey: libsignal.crypto.getRandomBytes(32),
};
storage.put('identityKey', identityKey);
await ConversationController.load();
await textsecure.storage.user.setNumberAndDeviceId(
'18005554444',
1,
'Home Office'
);
await ConversationController.getOrCreateAndWait(
textsecure.storage.user.getNumber(),
'private'
);
inboxView = new Whisper.InboxView({
model: {},
window,
initialLoadComplete() {},
}).render();
conversation = new Whisper.Conversation({
id: '1234',
type: 'private',
});
});
describe('the conversation stack', () => {
it('should be rendered', () => {
assert.ok(inboxView.$('.conversation-stack').length === 1);
});
describe('opening a conversation', () => {
let triggeredOpenedCount = 0;
before(() => {
conversation.on('opened', () => {
triggeredOpenedCount += 1;
});
inboxView.conversation_stack.open(conversation);
});
it('should trigger an opened event', () => {
assert.ok(triggeredOpenedCount === 1);
});
describe('and then opening it again immediately', () => {
before(() => {
inboxView.conversation_stack.open(conversation);
});
it('should trigger the opened event again', () => {
assert.ok(triggeredOpenedCount === 2);
});
});
});
});
});