2018-02-03 18:11:49 -07:00
|
|
|
describe('InboxView', function() {
|
2018-07-25 15:02:37 -07:00
|
|
|
let inboxView;
|
|
|
|
let conversation;
|
|
|
|
|
2018-09-20 18:47:19 -07:00
|
|
|
before(async () => {
|
|
|
|
try {
|
|
|
|
await ConversationController.load();
|
|
|
|
} catch (error) {
|
|
|
|
console.log(
|
|
|
|
'InboxView before:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
await ConversationController.getOrCreateAndWait(
|
|
|
|
textsecure.storage.user.getNumber(),
|
|
|
|
'private'
|
|
|
|
);
|
2018-07-25 15:02:37 -07:00
|
|
|
inboxView = new Whisper.InboxView({
|
|
|
|
model: {},
|
|
|
|
window: window,
|
|
|
|
initialLoadComplete: function() {},
|
|
|
|
}).render();
|
|
|
|
|
|
|
|
conversation = new Whisper.Conversation({
|
|
|
|
id: '1234',
|
|
|
|
type: 'private',
|
|
|
|
});
|
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
describe('the conversation stack', function() {
|
|
|
|
it('should be rendered', function() {
|
|
|
|
assert.ok(inboxView.$('.conversation-stack').length === 1);
|
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
describe('opening a conversation', function() {
|
|
|
|
var triggeredOpenedCount = 0;
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
before(function() {
|
|
|
|
conversation.on('opened', function() {
|
|
|
|
triggeredOpenedCount++;
|
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
inboxView.conversation_stack.open(conversation);
|
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
it('should trigger an opened event', function() {
|
|
|
|
assert.ok(triggeredOpenedCount === 1);
|
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
describe('and then opening it again immediately', function() {
|
|
|
|
before(function() {
|
|
|
|
inboxView.conversation_stack.open(conversation);
|
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
it('should trigger the opened event again', function() {
|
|
|
|
assert.ok(triggeredOpenedCount === 2);
|
2018-02-03 18:11:49 -07:00
|
|
|
});
|
2018-04-27 17:25:04 -04:00
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
});
|
2018-04-27 17:25:04 -04:00
|
|
|
});
|
2018-02-03 18:11:49 -07:00
|
|
|
});
|