Skip to content

Commit c2601f2

Browse files
committed
added more tests
Signed-off-by: Abhinav Kumar <[email protected]>
1 parent 3ecc79d commit c2601f2

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ describe('LayoutWithSidebar - First_Channel_After_Login navigation', () => {
5353
expect(push).toHaveBeenCalledWith({ name: 'general' });
5454
});
5555

56+
it('does NOT redirect if First_Channel_After_Login starts with "?"', () => {
57+
const push = setupChannelRouteMock();
58+
mockedUseCurrentRoutePath.mockReturnValue('/');
59+
60+
render(<LayoutWithSidebar>content</LayoutWithSidebar>, {
61+
wrapper: mockAppRoot().withSetting('First_Channel_After_Login', '?general').build(),
62+
});
63+
64+
expect(push).not.toHaveBeenCalled();
65+
});
66+
67+
it('does NOT redirect if First_Channel_After_Login starts with "@@"', () => {
68+
const push = setupChannelRouteMock();
69+
mockedUseCurrentRoutePath.mockReturnValue('/');
70+
71+
render(<LayoutWithSidebar>content</LayoutWithSidebar>, {
72+
wrapper: mockAppRoot().withSetting('First_Channel_After_Login', '@@general').build(),
73+
});
74+
75+
expect(push).not.toHaveBeenCalled();
76+
});
77+
5678
it('redirects when route is "/home"', () => {
5779
const push = setupChannelRouteMock();
5880
mockedUseCurrentRoutePath.mockReturnValue('/home');

apps/meteor/client/views/root/MainLayout/LayoutWithSidebarV2.spec.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ describe('LayoutWithSidebarV2 - First_Channel_After_Login navigation', () => {
6262
expect(navigate).toHaveBeenCalledWith({ name: '/channel/general' });
6363
});
6464

65+
it('does NOT redirect if First_Channel_After_Login starts with "?"', () => {
66+
const navigate = setupRouterMock();
67+
mockedUseCurrentRoutePath.mockReturnValue('/');
68+
69+
render(<LayoutWithSidebarV2>content</LayoutWithSidebarV2>, {
70+
wrapper: mockAppRoot().withSetting('First_Channel_After_Login', '?general').build(),
71+
});
72+
73+
expect(navigate).not.toHaveBeenCalled();
74+
});
75+
76+
it('does NOT redirect if First_Channel_After_Login starts with "@@"', () => {
77+
const navigate = setupRouterMock();
78+
mockedUseCurrentRoutePath.mockReturnValue('/');
79+
80+
render(<LayoutWithSidebarV2>content</LayoutWithSidebarV2>, {
81+
wrapper: mockAppRoot().withSetting('First_Channel_After_Login', '@@general').build(),
82+
});
83+
84+
expect(navigate).not.toHaveBeenCalled();
85+
});
86+
6587
it('redirects when route is "/home"', () => {
6688
const navigate = setupRouterMock();
6789
mockedUseCurrentRoutePath.mockReturnValue('/home');

0 commit comments

Comments
 (0)