Skip to content

Commit

Permalink
fix: fixed code nits
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadadeeltajamul committed Nov 15, 2024
1 parent ce15f2d commit bc37582
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/Notification/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ const Notifications = ({ notificationAppData, showLeftMargin }) => {
}, []);

useEffect(() => {
const openTray = searchParams.get('showNotifications') === 'true';
const app = searchParams.get('app') || 'discussion';
if (!openFlag && Object.keys(tabsCount).length > 0) {
setAppName(app);
setEnableNotificationTray(openTray);
setOpenFlag(true);
if (openFlag || Object.keys(tabsCount).length === 0) {
return;
}
setAppName(searchParams.get('app') || 'discussion');
setEnableNotificationTray(searchParams.get('showNotifications') === 'true');
setOpenFlag(true);
}, [tabsCount, openFlag, searchParams]);

useEffect(() => {
Expand Down
9 changes: 3 additions & 6 deletions src/Notification/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ describe('Notification test cases.', () => {
}

it.each(['true', 'false', null])(
'Notification tray opens when showNotifications query param is %s',
'Ensures correct rendering of the notification tray based on the showNotifications query parameter value %s',
async (showNotifications) => {
await setupMockNotificationCountResponse();

let url = '/';
if (showNotifications !== null) {
url = `/?showNotifications=${showNotifications}`;
}
const url = showNotifications ? `/?showNotifications=${showNotifications}` : '/';
await renderComponent(url);
await waitFor(async () => {
await waitFor(() => {
expect(screen.queryByTestId('notification-bell-icon')).toBeInTheDocument();
if (showNotifications === 'true') {
expect(screen.queryByTestId('notification-tray')).toBeInTheDocument();
Expand Down

0 comments on commit bc37582

Please sign in to comment.