Improve handling of invalid conversations
This commit is contained in:
parent
4404429ec2
commit
36432b3a3d
2 changed files with 42 additions and 6 deletions
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue