diff --git a/src/workbench/notification/__tests__/__snapshots__/localeNotification.test.tsx.snap b/src/workbench/notification/__tests__/__snapshots__/localeNotification.test.tsx.snap new file mode 100644 index 000000000..b7dc1f770 --- /dev/null +++ b/src/workbench/notification/__tests__/__snapshots__/localeNotification.test.tsx.snap @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`The LocaleNotification Component Match Snapshot 1`] = ` +
+

+ The current locale has changed to + chinese + , click the button to reload the Page and applying the changes. +

+

+ Notice: Reload the Page could lose the data, Please confirm you have saved before. +

+ + Confirm Reload + +
+`; diff --git a/src/workbench/notification/__tests__/localeNotification.test.tsx b/src/workbench/notification/__tests__/localeNotification.test.tsx new file mode 100644 index 000000000..4279e2e3a --- /dev/null +++ b/src/workbench/notification/__tests__/localeNotification.test.tsx @@ -0,0 +1,29 @@ +import { fireEvent, render } from '@testing-library/react'; +import React from 'react'; +import { create } from 'react-test-renderer'; +import LocaleNotification from '../notificationPane/localeNotification'; + +describe('The LocaleNotification Component', () => { + test('Match Snapshot', () => { + const component = create(); + expect(component.toJSON()).toMatchSnapshot(); + }); + + test('Should support to reload via button', () => { + const originalFunction = window.location.reload; + const mockFn = jest.fn(); + Reflect.deleteProperty(window, 'location'); + Object.defineProperty(window, 'location', { + writable: true, + value: { reload: mockFn }, + }); + const { getByText } = render(); + + fireEvent.click(getByText('Confirm Reload')); + + expect(jest.isMockFunction(window.location.reload)).toBeTruthy(); + expect(mockFn).toBeCalled(); + + window.location.reload = originalFunction; + }); +});