describe('RELOAD_PLUGIN', () => { it('Should return the initial state constant', () => { expect( reducer(initialState.setIn(['components', 'foo'], {}), { type: 'RELOAD_PLUGIN', }) ).toEqual(initialState); }); });
describe('RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO', () => { it('Should reset the state and update the modifiedData object with the component field basic schema', () => { const action = { type: 'RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO', }; const state = initialState.setIn(['modifiedData'], 'test'); const expected = state.setIn( ['modifiedData'], fromJS({ type: 'component', repeatable: true }) ); expect(reducer(state, action)).toEqual(expected); }); });
describe('DELETE_NOT_SAVED_TYPE', () => { it('Should reset the components and and contentTypes object', () => { const state = initialState .setIn(['components'], fromJS({ foo: {}, bar: {} })) .setIn(['initialComponents'], fromJS({ foo: {} })) .setIn(['contentTypes'], fromJS({ baz: {}, bat: {} })) .setIn(['initialContentTypes'], fromJS({ baz: {} })); const expected = initialState .setIn(['components'], fromJS({ foo: {} })) .setIn(['initialComponents'], fromJS({ foo: {} })) .setIn(['contentTypes'], fromJS({ baz: {} })) .setIn(['initialContentTypes'], fromJS({ baz: {} })); expect(reducer(state, { type: 'DELETE_NOT_SAVED_TYPE' })).toEqual(expected); }); });
.set('initialComponents', fromJS(testData.components)) .set('initialContentTypes', fromJS(testData.contentTypes)) .setIn( ['modifiedData', 'contentType'], fromJS(testData.contentTypes[contentTypeUID]) ); const expected = state.setIn( ['modifiedData', 'contentType', 'schema', 'attributes', 'address'], fromJS({
describe('RESET_PROPS', () => { it('Should return the initialState', () => { const state = initialState.setIn(['modifiedData'], 'test'); const action = { type: 'RESET_PROPS' }; expect(reducer(state, action)).toEqual(initialState); }); });
describe('CREATE_SCHEMA', () => { it('Should create a content type schema correctly', () => { const uid = 'application::test'; const data = { collectionName: 'test', name: 'test', }; const expected = initialState.setIn( ['contentTypes', uid], fromJS({ uid, isTemporary: true, schema: { collectionName: data.collectionName, name: data.name, attributes: {}, }, }) ); expect(reducer(initialState, { type: 'CREATE_SCHEMA', uid, data })).toEqual(expected); }); });
describe('SET_DYNAMIC_ZONE_DATA_SCHEMA', () => { it('Should set the dynamic zone schema correctly', () => { const action = { type: 'SET_DYNAMIC_ZONE_DATA_SCHEMA', attributeToEdit: { type: 'dynamiczone', components: [], name: 'dz', createComponent: false, componentToCreate: { type: 'component' }, }, }; const expected = initialState .setIn(['modifiedData'], fromJS(action.attributeToEdit)) .setIn(['initialData'], fromJS(action.attributeToEdit)); expect(reducer(initialState, action)).toEqual(expected); }); });
describe('RELOAD_PLUGIN', () => { it('Should return the initial state constant', () => { expect( reducer(initialState.setIn(['components', 'foo'], {}), { type: 'RELOAD_PLUGIN', }) ).toEqual(initialState); }); });
describe('RESET_PROPS', () => { it('Should return the initialState', () => { const state = initialState.setIn(['modifiedData'], 'test'); const action = { type: 'RESET_PROPS' }; expect(reducer(state, action)).toEqual(initialState); }); });
describe('RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO', () => { it('Should reset the state and update the modifiedData object with the component field basic schema', () => { const action = { type: 'RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO', }; const state = initialState.setIn(['modifiedData'], 'test'); const expected = state.setIn( ['modifiedData'], fromJS({ type: 'component', repeatable: true }) ); expect(reducer(state, action)).toEqual(expected); }); });
describe('DELETE_NOT_SAVED_TYPE', () => { it('Should reset the components and and contentTypes object', () => { const state = initialState .setIn(['components'], fromJS({ foo: {}, bar: {} })) .setIn(['initialComponents'], fromJS({ foo: {} })) .setIn(['contentTypes'], fromJS({ baz: {}, bat: {} })) .setIn(['initialContentTypes'], fromJS({ baz: {} })); const expected = initialState .setIn(['components'], fromJS({ foo: {} })) .setIn(['initialComponents'], fromJS({ foo: {} })) .setIn(['contentTypes'], fromJS({ baz: {} })) .setIn(['initialContentTypes'], fromJS({ baz: {} })); expect(reducer(state, { type: 'DELETE_NOT_SAVED_TYPE' })).toEqual(expected); }); });
describe('SET_DYNAMIC_ZONE_DATA_SCHEMA', () => { it('Should set the dynamic zone schema correctly', () => { const action = { type: 'SET_DYNAMIC_ZONE_DATA_SCHEMA', attributeToEdit: { type: 'dynamiczone', components: [], name: 'dz', createComponent: false, componentToCreate: { type: 'component' }, }, }; const expected = initialState .setIn(['modifiedData'], fromJS(action.attributeToEdit)) .setIn(['initialData'], fromJS(action.attributeToEdit)); expect(reducer(initialState, action)).toEqual(expected); }); });
describe('CREATE_SCHEMA', () => { it('Should create a content type schema correctly', () => { const uid = 'application::test'; const data = { collectionName: 'test', name: 'test', }; const expected = initialState.setIn( ['contentTypes', uid], fromJS({ uid, isTemporary: true, schema: { collectionName: data.collectionName, name: data.name, attributes: {}, }, }) ); expect(reducer(initialState, { type: 'CREATE_SCHEMA', uid, data })).toEqual(expected); }); });