mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 19:27:34 +00:00
listview reducer tests ip
Signed-off-by: Virginie Ky <virginie.ky@gmail.com> Signed-off-by: Bart Duisters <bartduisters@bartduisters.com>
This commit is contained in:
parent
761ad68392
commit
54522cd48e
@ -0,0 +1,7 @@
|
||||
describe('Admin | containers | Webhooks | ListView | index', () => {
|
||||
describe('Render', () => {
|
||||
it('It should render properly', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,69 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import reducer from '../reducer';
|
||||
|
||||
describe('Admin | containers | Webhooks | ListView | reducer', () => {
|
||||
const initialState = fromJS({
|
||||
webhooks: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'webhook 1',
|
||||
url: 'http://localhost:5000',
|
||||
headers: {},
|
||||
events: ['entry.create', 'entry.update', 'entry.delete'],
|
||||
isEnabled: true,
|
||||
},
|
||||
],
|
||||
webhooksToDelete: [],
|
||||
webhookToDelete: null,
|
||||
});
|
||||
it('It should update webhooks state with received data on GET_DATA_SUCCEEDED', () => {
|
||||
const state = initialState;
|
||||
const receivedData = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'webhook 1',
|
||||
url: 'http://localhost:5000',
|
||||
headers: {},
|
||||
events: ['entry.create', 'entry.update', 'entry.delete'],
|
||||
isEnabled: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'webhook 2',
|
||||
url: 'http://localhost:4000',
|
||||
headers: {},
|
||||
events: ['media.create', 'media.update'],
|
||||
isEnabled: false,
|
||||
},
|
||||
];
|
||||
|
||||
const action = {
|
||||
type: 'GET_DATA_SUCCEEDED',
|
||||
data: receivedData,
|
||||
};
|
||||
|
||||
const expectedState = state.set('webhooks', fromJS(receivedData));
|
||||
|
||||
expect(reducer(state, action)).toEqual(expectedState);
|
||||
});
|
||||
|
||||
it('It should toggle webhook isEnabled state on SET_WEBHOOK_ENABLED', () => {
|
||||
const state = initialState;
|
||||
|
||||
const webhookToUpdate = 1;
|
||||
|
||||
const keys = [webhookToUpdate, 'isEnabled'];
|
||||
|
||||
const action = {
|
||||
type: 'SET_WEBHOOK_ENABLED',
|
||||
keys: keys,
|
||||
value: false,
|
||||
};
|
||||
|
||||
const expectedState = state.setIn(['webhooks', ...keys], action.value);
|
||||
|
||||
expect(reducer(state, action)).toEqual(expectedState);
|
||||
|
||||
//expect(true).toBe(true);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user