You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			69 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			69 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);
 | |
|         });
 | |
|       });
 | |
|     });
 | |
|   });
 | |
| });
 |