Skip to content

Commit

Permalink
feat: add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
domw30 committed Aug 21, 2024
1 parent 37b17f7 commit 5741a90
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/components/messenger/feed/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,48 @@ import { StoreBuilder, stubConversation } from '../../../store/test/store';
describe(MessengerFeed, () => {
const subject = (props: Partial<Properties>) => {
const allProps: Properties = {
user: { data: null },
channel: null,
activeConversationId: 'channel-id',
isSocialChannel: false,
isJoiningConversation: false,
sendPost: jest.fn(),
fetchPosts: jest.fn(),
...props,
};

return shallow(<MessengerFeed {...allProps} />);
};

it('renders Messenger Feed when isSocialChannel is true', () => {
const wrapper = subject({ isSocialChannel: true });
expect(wrapper);
const channel = stubConversation({ name: 'convo-1', hasLoadedMessages: true, messages: [] });

const wrapper = subject({ channel: channel as any, isSocialChannel: true });
expect(wrapper).toHaveElement('CreatePost');
});

it('does not render Messenger Feed when isSocialChannel is false', () => {
const wrapper = subject({ isSocialChannel: false });
expect(wrapper).not.toHaveText('Messenger Feed');
const channel = stubConversation({ name: 'convo-1', hasLoadedMessages: true, messages: [] });

const wrapper = subject({ channel: channel as any, isSocialChannel: false });

expect(wrapper).not.toHaveElement('CreatePost');
});

it('does not render Messenger Feed when isJoiningConversation is true', () => {
const channel = stubConversation({ name: 'convo-1', hasLoadedMessages: true, messages: [] });

const wrapper = subject({ channel: channel as any, isSocialChannel: true, isJoiningConversation: true });

expect(wrapper).not.toHaveElement('CreatePost');
});

it('does not render Messenger Feed when no active conversation id', () => {
const channel = stubConversation({ name: 'convo-1', hasLoadedMessages: true, messages: [] });

const wrapper = subject({ channel: channel as any, isSocialChannel: true, activeConversationId: null });

expect(wrapper).not.toHaveElement('CreatePost');
});

describe('mapState', () => {
Expand Down

0 comments on commit 5741a90

Please sign in to comment.