diff --git a/src/containers/NotificationsBanner/NotificationsBanner.test.jsx b/src/containers/NotificationsBanner/NotificationsBanner.test.jsx index d111c5f..eb3a368 100644 --- a/src/containers/NotificationsBanner/NotificationsBanner.test.jsx +++ b/src/containers/NotificationsBanner/NotificationsBanner.test.jsx @@ -1,10 +1,30 @@ import React from 'react'; import { shallow } from '@edx/react-unit-test-utils'; +import { getConfig } from '@edx/frontend-platform'; import { NotificationsBanner } from '.'; +jest.mock('@edx/frontend-platform', () => ({ + getConfig: jest.fn(), +})); + describe('NotificationsBanner component', () => { - test('snapshots', () => { + afterEach(() => { + jest.clearAllMocks(); + }); + + test('snapshots with empty ACCOUNT_SETTINGS_URL', () => { + getConfig.mockReturnValue({ + ACCOUNT_SETTINGS_URL: '', + }); + const el = shallow(); + expect(el.snapshot).toMatchSnapshot(); + }); + + test('snapshots with ACCOUNT_SETTINGS_URL', () => { + getConfig.mockReturnValue({ + ACCOUNT_SETTINGS_URL: 'http://localhost:1997', + }); const el = shallow(); expect(el.snapshot).toMatchSnapshot(); }); diff --git a/src/containers/NotificationsBanner/__snapshots__/NotificationsBanner.test.jsx.snap b/src/containers/NotificationsBanner/__snapshots__/NotificationsBanner.test.jsx.snap index ba208b0..87c8ee3 100644 --- a/src/containers/NotificationsBanner/__snapshots__/NotificationsBanner.test.jsx.snap +++ b/src/containers/NotificationsBanner/__snapshots__/NotificationsBanner.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`NotificationsBanner component snapshots 1`] = ` +exports[`NotificationsBanner component snapshots with ACCOUNT_SETTINGS_URL 1`] = ` @@ -27,3 +27,22 @@ exports[`NotificationsBanner component snapshots 1`] = ` `; + +exports[`NotificationsBanner component snapshots with empty ACCOUNT_SETTINGS_URL 1`] = ` + + + + + + +`; diff --git a/src/containers/NotificationsBanner/index.jsx b/src/containers/NotificationsBanner/index.jsx index 4c334e7..64ad410 100644 --- a/src/containers/NotificationsBanner/index.jsx +++ b/src/containers/NotificationsBanner/index.jsx @@ -10,16 +10,26 @@ export const NotificationsBanner = () => ( - - - + { + ( + getConfig().ACCOUNT_SETTINGS_URL === null + || getConfig().ACCOUNT_SETTINGS_URL === undefined + || getConfig().ACCOUNT_SETTINGS_URL.trim().length === 0 + ) ? ( + + ) : ( + + + + ) + } ); diff --git a/src/containers/NotificationsBanner/messages.js b/src/containers/NotificationsBanner/messages.js index 8a831ed..e92f4f4 100644 --- a/src/containers/NotificationsBanner/messages.js +++ b/src/containers/NotificationsBanner/messages.js @@ -8,7 +8,7 @@ const messages = defineMessages({ defaultMessage: 'You can now enable notifications for ORA assignments that require staff grading, from the ', description: 'user info message that user can enable notifications for ORA assignments', }, - notificationsBannerLinkMessage: { + notificationsBannerPreferencesCenterMessage: { id: 'ora-grading.NotificationsBanner.linkMessage', defaultMessage: 'preferences center.', description: 'placeholder for the preferences center link',