mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix: added reducer test
This commit is contained in:
@@ -1,17 +1,42 @@
|
|||||||
import { Action, ActionTypes } from './actions';
|
import { Action, ActionTypes } from './actions';
|
||||||
|
import { FolderDTO } from 'app/types';
|
||||||
import { inititalState, folderReducer } from './reducers';
|
import { inititalState, folderReducer } from './reducers';
|
||||||
|
|
||||||
|
function getTestFolder(): FolderDTO {
|
||||||
|
return {
|
||||||
|
id: 1,
|
||||||
|
title: 'test folder',
|
||||||
|
uid: 'asd',
|
||||||
|
url: 'url',
|
||||||
|
canSave: true,
|
||||||
|
version: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe('folder reducer', () => {
|
describe('folder reducer', () => {
|
||||||
it('should set teams', () => {
|
it('should load folder and set hasChanged to false', () => {
|
||||||
const payload = [getMockTeam()];
|
const folder = getTestFolder();
|
||||||
|
|
||||||
const action: Action = {
|
const action: Action = {
|
||||||
type: ActionTypes.LoadTeams,
|
type: ActionTypes.LoadFolder,
|
||||||
payload,
|
payload: folder,
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = teamsReducer(initialTeamsState, action);
|
const state = folderReducer(inititalState, action);
|
||||||
|
|
||||||
expect(result.teams).toEqual(payload);
|
expect(state.hasChanged).toEqual(false);
|
||||||
|
expect(state.title).toEqual('test folder');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set title', () => {
|
||||||
|
const action: Action = {
|
||||||
|
type: ActionTypes.SetFolderTitle,
|
||||||
|
payload: 'new title',
|
||||||
|
};
|
||||||
|
|
||||||
|
const state = folderReducer(inititalState, action);
|
||||||
|
|
||||||
|
expect(state.hasChanged).toEqual(true);
|
||||||
|
expect(state.title).toEqual('new title');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user