Skip to content

Commit a52ddfd

Browse files
refactor: changed api url
1 parent 8175ba8 commit a52ddfd

3 files changed

Lines changed: 7 additions & 19 deletions

File tree

src/Notifications/data/api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
44
export const getNotificationsCountApiUrl = () => `${getConfig().LMS_BASE_URL}/api/notifications/count/`;
55
export const getNotificationsApiUrl = () => `${getConfig().LMS_BASE_URL}/api/notifications/`;
66
export const markNotificationsSeenApiUrl = (appName) => `${getConfig().LMS_BASE_URL}/api/notifications/mark-notifications-unseen/${appName}/`;
7-
export const markAllNotificationsAsReadpiUrl = () => `${getConfig().LMS_BASE_URL}/api/notifications/read/`;
7+
export const markNotificationAsReadApiUrl = () => `${getConfig().LMS_BASE_URL}/api/notifications/read/`;
88

99
export async function getNotifications(appName, page, pageSize) {
1010
const params = snakeCaseObject({ page, pageSize });
@@ -31,14 +31,14 @@ export async function markNotificationSeen(appName) {
3131

3232
export async function markAllNotificationRead(appName) {
3333
const params = snakeCaseObject({ appName });
34-
const { data } = await getAuthenticatedHttpClient().put(markAllNotificationsAsReadpiUrl(), { params });
34+
const { data } = await getAuthenticatedHttpClient().put(markNotificationAsReadApiUrl(), { params });
3535

3636
return data;
3737
}
3838

3939
export async function markNotificationRead(notificationId) {
4040
const params = snakeCaseObject({ notificationId });
41-
const { data } = await getAuthenticatedHttpClient().put(markAllNotificationsAsReadpiUrl(), { params });
41+
const { data } = await getAuthenticatedHttpClient().put(markNotificationAsReadApiUrl(), { params });
4242

4343
return { data, id: notificationId };
4444
}

src/Notifications/data/api.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
55
import { initializeMockApp } from '@edx/frontend-platform/testing';
66

77
import {
8-
getNotificationsApiUrl, getNotificationsCountApiUrl, markAllNotificationsAsReadpiUrl, markNotificationsSeenApiUrl,
8+
getNotificationsApiUrl, getNotificationsCountApiUrl, markNotificationAsReadApiUrl, markNotificationsSeenApiUrl,
99
getNotificationCounts, getNotifications, markNotificationSeen, markAllNotificationRead, markNotificationRead,
1010
} from './api';
1111

@@ -14,7 +14,7 @@ import './__factories__';
1414
const notificationCountsApiUrl = getNotificationsCountApiUrl();
1515
const notificationsApiUrl = getNotificationsApiUrl();
1616
const markedAllNotificationsAsSeenApiUrl = markNotificationsSeenApiUrl('discussions');
17-
const markedAllNotificationsAsReadApiUrl = markAllNotificationsAsReadpiUrl();
17+
const markedAllNotificationsAsReadApiUrl = markNotificationAsReadApiUrl();
1818

1919
let axiosMock = null;
2020

src/Notifications/data/redux.test.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { initializeMockApp } from '@edx/frontend-platform/testing';
77
import { initializeStore } from '../../store';
88
import executeThunk from '../../test-utils';
99
import {
10-
getNotificationsApiUrl, getNotificationsCountApiUrl, markAllNotificationsAsReadpiUrl, markNotificationsSeenApiUrl,
10+
getNotificationsApiUrl, getNotificationsCountApiUrl, markNotificationAsReadApiUrl, markNotificationsSeenApiUrl,
1111
} from './api';
1212
import {
1313
fetchAppsNotificationCount, fetchNotificationList, markNotificationsAsRead, markAllNotificationsAsRead,
@@ -18,7 +18,7 @@ import './__factories__';
1818

1919
const notificationCountsApiUrl = getNotificationsCountApiUrl();
2020
const notificationsApiUrl = getNotificationsApiUrl();
21-
const markedAllNotificationsAsReadApiUrl = markAllNotificationsAsReadpiUrl();
21+
const markedAllNotificationsAsReadApiUrl = markNotificationAsReadApiUrl();
2222
const markedAllNotificationsAsSeenApiUrl = markNotificationsSeenApiUrl('discussions');
2323

2424
let axiosMock;
@@ -139,18 +139,6 @@ describe('Notification Redux', () => {
139139
expect(firstNotification.lastRead).not.toBeNull();
140140
});
141141

142-
it.each([
143-
{ statusCode: 404, status: 'failed' },
144-
{ statusCode: 403, status: 'denied' },
145-
])('%s to mark all notifications as read for selected app in the redux.', async ({ statusCode, status }) => {
146-
axiosMock.onPut(markedAllNotificationsAsReadApiUrl).reply(statusCode);
147-
await executeThunk(markAllNotificationsAsRead('discussions'), store.dispatch, store.getState);
148-
149-
const { notifications: { notificationStatus } } = store.getState();
150-
151-
expect(notificationStatus).toEqual(status);
152-
});
153-
154142
it('Successfully marked notification as read in the redux.', async () => {
155143
axiosMock.onPut(markedAllNotificationsAsReadApiUrl).reply(200);
156144
await executeThunk(markNotificationsAsRead(1), store.dispatch, store.getState);

0 commit comments

Comments
 (0)