Move message.getPropsForBubble and friends to selectors

This commit is contained in:
Scott Nonnenberg 2021-06-17 10:15:10 -07:00 committed by GitHub
parent 03a187097f
commit 68f1023946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 3394 additions and 2576 deletions

View file

@ -5,6 +5,12 @@ import { assert } from 'chai';
import * as sinon from 'sinon';
import { setup as setupI18n } from '../../../js/modules/i18n';
import enMessages from '../../../_locales/en/messages.json';
import {
isEndSession,
isGroupUpdate,
isIncoming,
isOutgoing,
} from '../../state/selectors/message';
describe('Message', () => {
const i18n = setupI18n('en', enMessages);
@ -122,9 +128,9 @@ describe('Message', () => {
it('checks if is incoming message', () => {
const messages = new window.Whisper.MessageCollection();
let message = messages.add(attributes);
assert.notOk(message.isIncoming());
assert.notOk(isIncoming(message.attributes));
message = messages.add({ type: 'incoming' });
assert.ok(message.isIncoming());
assert.ok(isIncoming(message.attributes));
});
});
@ -132,9 +138,9 @@ describe('Message', () => {
it('checks if is outgoing message', () => {
const messages = new window.Whisper.MessageCollection();
let message = messages.add(attributes);
assert.ok(message.isOutgoing());
assert.ok(isOutgoing(message.attributes));
message = messages.add({ type: 'incoming' });
assert.notOk(message.isOutgoing());
assert.notOk(isOutgoing(message.attributes));
});
});
@ -142,10 +148,10 @@ describe('Message', () => {
it('checks if is group update', () => {
const messages = new window.Whisper.MessageCollection();
let message = messages.add(attributes);
assert.notOk(message.isGroupUpdate());
assert.notOk(isGroupUpdate(message.attributes));
message = messages.add({ group_update: true });
assert.ok(message.isGroupUpdate());
assert.ok(isGroupUpdate(message.attributes));
});
});
@ -553,10 +559,10 @@ describe('Message', () => {
it('checks if it is end of the session', () => {
const messages = new window.Whisper.MessageCollection();
let message = messages.add(attributes);
assert.notOk(message.isEndSession());
assert.notOk(isEndSession(message.attributes));
message = messages.add({ type: 'incoming', source, flags: true });
assert.ok(message.isEndSession());
assert.ok(isEndSession(message.attributes));
});
});
});