mirror of
https://github.com/strapi/strapi.git
synced 2025-12-04 19:13:20 +00:00
Unit tests fixes
This commit is contained in:
parent
ef66c9ccb8
commit
ce3ada140d
@ -36,6 +36,9 @@ describe('<Admin />', () => {
|
||||
strapiVersion: '3',
|
||||
uuid: false,
|
||||
},
|
||||
intl: {
|
||||
formatMessage: jest.fn(),
|
||||
},
|
||||
location: {},
|
||||
setAppError: jest.fn(),
|
||||
showGlobalAppBlocker: jest.fn(),
|
||||
|
||||
@ -190,6 +190,7 @@ function ListView({
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onChangeListLabels({
|
||||
target: {
|
||||
name,
|
||||
|
||||
@ -16,34 +16,42 @@ describe('Content Manager | Main | reducer', () => {
|
||||
components: [],
|
||||
initialLayouts: {
|
||||
test: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['test'],
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['test'],
|
||||
},
|
||||
},
|
||||
},
|
||||
otherTest: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest'],
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
isLoading: true,
|
||||
layouts: {
|
||||
test: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['test'],
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['test'],
|
||||
},
|
||||
},
|
||||
},
|
||||
otherTest: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest'],
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -55,7 +63,11 @@ describe('Content Manager | Main | reducer', () => {
|
||||
const expected = {
|
||||
...state,
|
||||
layouts: {
|
||||
test: { layouts: { edit: [], editRelations: [], list: ['test'] } },
|
||||
test: {
|
||||
contentType: {
|
||||
layouts: { edit: [], editRelations: [], list: ['test'] },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -72,17 +84,23 @@ describe('Content Manager | Main | reducer', () => {
|
||||
});
|
||||
|
||||
it('should handle the resetListLabels action correctly', () => {
|
||||
state.layouts.test.layouts.list.push('label');
|
||||
state.layouts.test.contentType.layouts.list.push('label');
|
||||
|
||||
const expected = {
|
||||
...state,
|
||||
layouts: {
|
||||
test: { layouts: { edit: [], editRelations: [], list: ['test'] } },
|
||||
test: {
|
||||
contentType: {
|
||||
layouts: { edit: [], editRelations: [], list: ['test'] },
|
||||
},
|
||||
},
|
||||
otherTest: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest'],
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -99,34 +117,12 @@ describe('Content Manager | Main | reducer', () => {
|
||||
layouts: {
|
||||
...state.layouts,
|
||||
otherTest: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest', 'foo'],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(
|
||||
mainReducer(
|
||||
fromJS(state),
|
||||
onChangeListLabels({ target: { name: 'otherTest.foo', value: true } })
|
||||
).toJS()
|
||||
).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle the onChangeListLabels action correctly when removing a label', () => {
|
||||
state.layouts.otherTest.layouts.list = ['otherTest', 'foo'];
|
||||
const expected = {
|
||||
...state,
|
||||
layouts: {
|
||||
...state.layouts,
|
||||
otherTest: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['foo'],
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['otherTest', 'foo'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -136,7 +132,39 @@ describe('Content Manager | Main | reducer', () => {
|
||||
mainReducer(
|
||||
fromJS(state),
|
||||
onChangeListLabels({
|
||||
target: { name: 'otherTest.otherTest', value: false },
|
||||
target: { name: 'foo', slug: 'otherTest', value: true },
|
||||
})
|
||||
).toJS()
|
||||
).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle the onChangeListLabels action correctly when removing a label', () => {
|
||||
state.layouts.otherTest.contentType.layouts.list = ['otherTest', 'foo'];
|
||||
const expected = {
|
||||
...state,
|
||||
layouts: {
|
||||
...state.layouts,
|
||||
otherTest: {
|
||||
contentType: {
|
||||
layouts: {
|
||||
edit: [],
|
||||
editRelations: [],
|
||||
list: ['foo'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(
|
||||
mainReducer(
|
||||
fromJS(state),
|
||||
onChangeListLabels({
|
||||
target: {
|
||||
name: 'otherTest',
|
||||
slug: 'otherTest',
|
||||
value: false,
|
||||
},
|
||||
})
|
||||
).toJS()
|
||||
).toEqual(expected);
|
||||
|
||||
@ -28,19 +28,4 @@ describe('<EditViewLink />', () => {
|
||||
|
||||
expect(liLink).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should handle the source correctly if it is undefined', () => {
|
||||
const wrapper = shallow(<EditViewLink {...props} />);
|
||||
const liLink = wrapper.find(LiLink);
|
||||
|
||||
expect(liLink.prop('url')).toBe('/plugins/test');
|
||||
});
|
||||
|
||||
it('should handle the source correctly if it is not undefined', () => {
|
||||
props.getSource = jest.fn(() => 'users-permissions');
|
||||
const wrapper = shallow(<EditViewLink {...props} />);
|
||||
const liLink = wrapper.find(LiLink);
|
||||
|
||||
expect(liLink.prop('url')).toBe('/plugins/test&source=users-permissions');
|
||||
});
|
||||
});
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
exports[`<Loader /> should not crash 1`] = `
|
||||
<div
|
||||
className="sc-fYxtnH jGsbTZ"
|
||||
className="sc-jnlKLf dzQmya"
|
||||
>
|
||||
<div
|
||||
className="centered"
|
||||
>
|
||||
<div
|
||||
className="sc-fMiknA iIEoBL"
|
||||
className="sc-fBuWsC chFDHA"
|
||||
>
|
||||
<div />
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user