mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Refactor: Adds Redux Toolkit package * Refactor: Uses configureStore from Redux Toolkit * Refactor: Migrates applicationReducer * Refactor: Migrates appNotificationsReducer * Refactor: Migrates locationReducer * Refactor: Migrates navModelReducer * Refactor: Migrates teamsReducer and teamReducer * Refactor: Migrates cleanUpAction * Refactor: Migrates alertRulesReducer * Refactor: Cleans up recursiveCleanState * Refactor: Switched to Angular compatible reducers * Refactor: Migrates folderReducer * Refactor: Migrates dashboardReducer * Migrates panelEditorReducer * Refactor: Migrates dataSourcesReducer * Refactor: Migrates usersReducer * Refactor: Migrates organizationReducer * Refactor: Migrates pluginsReducer * Refactor: Migrates ldapReducer and ldapUserReducer * Refactor: Migrates apiKeysReducer * Refactor: Migrates exploreReducer and itemReducer * Refactor: Removes actionCreatorFactory and reducerFactory * Refactor: Moves mocks to test section * Docs: Removes sections about home grown framework * Update contribute/style-guides/redux.md Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Refactor: Cleans up some code * Refactor: Adds state typings * Refactor: Cleans up typings * Refactor: Adds comment about ImmerJs autoFreeze Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
120 lines
3.0 KiB
TypeScript
120 lines
3.0 KiB
TypeScript
import { appNotificationsReducer, clearAppNotification, notifyApp } from './appNotification';
|
|
import { AppNotificationSeverity, AppNotificationTimeout } from 'app/types/';
|
|
|
|
describe('clear alert', () => {
|
|
it('should filter alert', () => {
|
|
const id1 = 1540301236048;
|
|
const id2 = 1540301248293;
|
|
|
|
const initialState = {
|
|
appNotifications: [
|
|
{
|
|
id: id1,
|
|
severity: AppNotificationSeverity.Success,
|
|
icon: 'success',
|
|
title: 'test',
|
|
text: 'test alert',
|
|
timeout: AppNotificationTimeout.Success,
|
|
},
|
|
{
|
|
id: id2,
|
|
severity: AppNotificationSeverity.Warning,
|
|
icon: 'warning',
|
|
title: 'test2',
|
|
text: 'test alert fail 2',
|
|
timeout: AppNotificationTimeout.Warning,
|
|
},
|
|
],
|
|
};
|
|
|
|
const result = appNotificationsReducer(initialState, clearAppNotification(id2));
|
|
|
|
const expectedResult = {
|
|
appNotifications: [
|
|
{
|
|
id: id1,
|
|
severity: AppNotificationSeverity.Success,
|
|
icon: 'success',
|
|
title: 'test',
|
|
text: 'test alert',
|
|
timeout: AppNotificationTimeout.Success,
|
|
},
|
|
],
|
|
};
|
|
|
|
expect(result).toEqual(expectedResult);
|
|
});
|
|
});
|
|
|
|
describe('notify', () => {
|
|
it('create notify message', () => {
|
|
const id1 = 1540301236048;
|
|
const id2 = 1540301248293;
|
|
const id3 = 1540301248203;
|
|
|
|
const initialState = {
|
|
appNotifications: [
|
|
{
|
|
id: id1,
|
|
severity: AppNotificationSeverity.Success,
|
|
icon: 'success',
|
|
title: 'test',
|
|
text: 'test alert',
|
|
timeout: AppNotificationTimeout.Success,
|
|
},
|
|
{
|
|
id: id2,
|
|
severity: AppNotificationSeverity.Warning,
|
|
icon: 'warning',
|
|
title: 'test2',
|
|
text: 'test alert fail 2',
|
|
timeout: AppNotificationTimeout.Warning,
|
|
},
|
|
],
|
|
};
|
|
|
|
const result = appNotificationsReducer(
|
|
initialState,
|
|
notifyApp({
|
|
id: id3,
|
|
severity: AppNotificationSeverity.Info,
|
|
icon: 'info',
|
|
title: 'test3',
|
|
text: 'test alert info 3',
|
|
timeout: AppNotificationTimeout.Success,
|
|
})
|
|
);
|
|
|
|
const expectedResult = {
|
|
appNotifications: [
|
|
{
|
|
id: id1,
|
|
severity: AppNotificationSeverity.Success,
|
|
icon: 'success',
|
|
title: 'test',
|
|
text: 'test alert',
|
|
timeout: AppNotificationTimeout.Success,
|
|
},
|
|
{
|
|
id: id2,
|
|
severity: AppNotificationSeverity.Warning,
|
|
icon: 'warning',
|
|
title: 'test2',
|
|
text: 'test alert fail 2',
|
|
timeout: AppNotificationTimeout.Warning,
|
|
},
|
|
{
|
|
id: id3,
|
|
severity: AppNotificationSeverity.Info,
|
|
icon: 'info',
|
|
title: 'test3',
|
|
text: 'test alert info 3',
|
|
timeout: AppNotificationTimeout.Success,
|
|
},
|
|
],
|
|
};
|
|
|
|
expect(result).toEqual(expectedResult);
|
|
});
|
|
});
|