pull/1381/head
Audric Ackermann 4 years ago
parent a58a1a4fba
commit 0eb730f1ba

@ -2,170 +2,151 @@
// 'use strict'; // 'use strict';
// FIXME audric enable back those test // FIXME audric enable back those test
// describe('ConversationCollection', () => { describe('ConversationCollection', () => {
// textsecure.messaging = new textsecure.MessageSender(); // textsecure.messaging = new textsecure.MessageSender();
// before(clearDatabase);
// before(clearDatabase); // after(clearDatabase);
// after(clearDatabase); // it('should be ordered newest to oldest', () => {
// const conversations = new Whisper.ConversationCollection();
// it('should be ordered newest to oldest', () => { // // Timestamps
// const conversations = new Whisper.ConversationCollection(); // const today = new Date();
// // Timestamps // const tomorrow = new Date();
// const today = new Date(); // tomorrow.setDate(today.getDate() + 1);
// const tomorrow = new Date(); // // Add convos
// tomorrow.setDate(today.getDate() + 1); // conversations.add({ timestamp: today });
// conversations.add({ timestamp: tomorrow });
// // Add convos // const { models } = conversations;
// conversations.add({ timestamp: today }); // const firstTimestamp = models[0].get('timestamp').getTime();
// conversations.add({ timestamp: tomorrow }); // const secondTimestamp = models[1].get('timestamp').getTime();
// // Compare timestamps
// const { models } = conversations; // assert(firstTimestamp > secondTimestamp);
// const firstTimestamp = models[0].get('timestamp').getTime(); // });
// const secondTimestamp = models[1].get('timestamp').getTime(); // });
// describe('Conversation', () => {
// // Compare timestamps // const attributes = {
// assert(firstTimestamp > secondTimestamp); // type: 'private',
// }); // id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// }); // };
// before(async () => {
// describe('Conversation', () => { // const convo = new Whisper.ConversationCollection().add(attributes);
// const attributes = { // await window.Signal.Data.saveConversation(convo.attributes, {
// type: 'private', // Conversation: Whisper.Conversation,
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // });
// }; // // const message = convo.messageCollection.add({
// before(async () => { // // body: 'hello world',
// const convo = new Whisper.ConversationCollection().add(attributes); // // conversationId: convo.id,
// await window.Signal.Data.saveConversation(convo.attributes, { // // type: 'outgoing',
// Conversation: Whisper.Conversation, // // sent_at: Date.now(),
// }); // // received_at: Date.now(),
// // });
// // const message = convo.messageCollection.add({ // // await message.commit(false);
// // body: 'hello world', // });
// // conversationId: convo.id, // after(clearDatabase);
// // type: 'outgoing', // it('sorts its contacts in an intl-friendly way', () => {
// // sent_at: Date.now(), // const convo = new Whisper.Conversation({
// // received_at: Date.now(), // id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// // }); // });
// // await message.commit(false); // convo.contactCollection.add(
// }); // new Whisper.Conversation({
// after(clearDatabase); // name: 'C',
// })
// it('sorts its contacts in an intl-friendly way', () => { // );
// const convo = new Whisper.Conversation({ // convo.contactCollection.add(
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // new Whisper.Conversation({
// }); // name: 'B',
// convo.contactCollection.add( // })
// new Whisper.Conversation({ // );
// name: 'C', // convo.contactCollection.add(
// }) // new Whisper.Conversation({
// ); // name: 'Á',
// convo.contactCollection.add( // })
// new Whisper.Conversation({ // );
// name: 'B', // assert.strictEqual(convo.contactCollection.at('0').get('name'), 'Á');
// }) // assert.strictEqual(convo.contactCollection.at('1').get('name'), 'B');
// ); // assert.strictEqual(convo.contactCollection.at('2').get('name'), 'C');
// convo.contactCollection.add( // });
// new Whisper.Conversation({ // it('contains its own messages', async () => {
// name: 'Á', // const convo = new Whisper.ConversationCollection().add({
// }) // id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// ); // });
// await convo.fetchMessages();
// assert.strictEqual(convo.contactCollection.at('0').get('name'), 'Á'); // assert.notEqual(convo.messageCollection.length, 0);
// assert.strictEqual(convo.contactCollection.at('1').get('name'), 'B'); // });
// assert.strictEqual(convo.contactCollection.at('2').get('name'), 'C'); // it('contains only its own messages', async () => {
// }); // const convo = new Whisper.ConversationCollection().add({
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// it('contains its own messages', async () => { // });
// const convo = new Whisper.ConversationCollection().add({ // await convo.fetchMessages();
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // assert.strictEqual(convo.messageCollection.length, 0);
// }); // });
// await convo.fetchMessages(); // it('adds conversation to message collection upon leaving group', async () => {
// assert.notEqual(convo.messageCollection.length, 0); // const convo = new Whisper.ConversationCollection().add({
// }); // type: 'group',
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// it('contains only its own messages', async () => { // });
// const convo = new Whisper.ConversationCollection().add({ // await convo.leaveGroup();
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // assert.notEqual(convo.messageCollection.length, 0);
// }); // });
// await convo.fetchMessages(); // it('has a title', () => {
// assert.strictEqual(convo.messageCollection.length, 0); // const convos = new Whisper.ConversationCollection();
// }); // let convo = convos.add(attributes);
// assert.equal(
// it('adds conversation to message collection upon leaving group', async () => { // convo.getTitle(),
// const convo = new Whisper.ConversationCollection().add({ // '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab'
// type: 'group', // );
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // convo = convos.add({ type: '' });
// }); // assert.equal(convo.getTitle(), 'Unknown group');
// await convo.leaveGroup(); // convo = convos.add({ name: 'name' });
// assert.notEqual(convo.messageCollection.length, 0); // assert.equal(convo.getTitle(), 'name');
// }); // });
// it('returns the number', () => {
// it('has a title', () => { // const convos = new Whisper.ConversationCollection();
// const convos = new Whisper.ConversationCollection(); // let convo = convos.add(attributes);
// let convo = convos.add(attributes); // assert.equal(
// assert.equal( // convo.getNumber(),
// convo.getTitle(), // '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab'
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab' // );
// ); // convo = convos.add({ type: '' });
// assert.equal(convo.getNumber(), '');
// convo = convos.add({ type: '' }); // });
// assert.equal(convo.getTitle(), 'Unknown group'); // describe('when set to private', () => {
// it('correctly validates hex numbers', () => {
// convo = convos.add({ name: 'name' }); // const regularId = new Whisper.Conversation({
// assert.equal(convo.getTitle(), 'name'); // type: 'private',
// }); // id:
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// it('returns the number', () => { // });
// const convos = new Whisper.ConversationCollection(); // const invalidId = new Whisper.Conversation({
// let convo = convos.add(attributes); // type: 'private',
// assert.equal( // id:
// convo.getNumber(), // 'j71d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab' // });
// ); // assert.ok(regularId.isValid());
// assert.notOk(invalidId.isValid());
// convo = convos.add({ type: '' }); // });
// assert.equal(convo.getNumber(), ''); // it('correctly validates length', () => {
// }); // const regularId33 = new Whisper.Conversation({
// type: 'private',
// describe('when set to private', () => { // id:
// it('correctly validates hex numbers', () => { // '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// const regularId = new Whisper.Conversation({ // });
// type: 'private', // const regularId32 = new Whisper.Conversation({
// id: // type: 'private',
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // id: '1d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// }); // });
// const invalidId = new Whisper.Conversation({ // const shortId = new Whisper.Conversation({
// type: 'private', // type: 'private',
// id: // id: '771d11d',
// 'j71d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // });
// }); // const longId = new Whisper.Conversation({
// assert.ok(regularId.isValid()); // type: 'private',
// assert.notOk(invalidId.isValid()); // id:
// }); // '771d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94abaa',
// });
// it('correctly validates length', () => { // assert.ok(regularId33.isValid());
// const regularId33 = new Whisper.Conversation({ // assert.ok(regularId32.isValid());
// type: 'private', // assert.notOk(shortId.isValid());
// id: // assert.notOk(longId.isValid());
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // });
// }); // });
// const regularId32 = new Whisper.Conversation({ });
// type: 'private',
// id: '1d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// const shortId = new Whisper.Conversation({
// type: 'private',
// id: '771d11d',
// });
// const longId = new Whisper.Conversation({
// type: 'private',
// id:
// '771d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94abaa',
// });
// assert.ok(regularId33.isValid());
// assert.ok(regularId32.isValid());
// assert.notOk(shortId.isValid());
// assert.notOk(longId.isValid());
// });
// });
// });

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save