Improve handling of invalid conversations

This commit is contained in:
trevor-signal 2023-05-19 09:28:59 -04:00 committed by GitHub
parent 4404429ec2
commit 36432b3a3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 6 deletions

View file

@ -372,7 +372,7 @@ describe('both/state/ducks/conversations', () => {
}
describe('showConversation', () => {
it('selects a conversation id', () => {
it('does not select a conversation if it does not exist', () => {
const state = {
...getEmptyState(),
};
@ -385,14 +385,44 @@ describe('both/state/ducks/conversations', () => {
const action = dispatch.getCall(0).args[0];
const nextState = reducer(state, action);
assert.isUndefined(nextState.selectedConversationId);
assert.isUndefined(nextState.targetedMessage);
});
it('selects a conversation id', () => {
const conversation = getDefaultConversation({
id: 'abc123',
});
const state = {
...getEmptyState(),
conversationLookup: {
[conversation.id]: conversation,
},
};
const dispatch = sinon.spy();
showConversation({ conversationId: 'abc123' })(
dispatch,
getEmptyRootState,
null
);
const action = dispatch.getCall(0).args[0];
const nextState = reducer(state, action);
assert.equal(nextState.selectedConversationId, 'abc123');
assert.isUndefined(nextState.targetedMessage);
});
it('selects a conversation and a message', () => {
const conversation = getDefaultConversation({
id: 'abc123',
});
const state = {
...getEmptyState(),
conversationLookup: {
[conversation.id]: conversation,
},
};
const dispatch = sinon.spy();
showConversation({
conversationId: 'abc123',