mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 08:08:05 +00:00
Add tests to reducer
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
9abb0e6d7f
commit
1a1f10e09b
@ -244,6 +244,71 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('ON_SUBMIT_EDIT_NEW_FILE', () => {
|
||||||
|
it('should update the filesToUploadList with the fileToEdit data', () => {
|
||||||
|
const action = {
|
||||||
|
type: 'ON_SUBMIT_EDIT_NEW_FILE',
|
||||||
|
};
|
||||||
|
const state = fromJS({
|
||||||
|
currentStep: 'edit-new',
|
||||||
|
filesToUpload: [
|
||||||
|
{
|
||||||
|
originalIndex: 0,
|
||||||
|
file: {
|
||||||
|
name: 'test',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
test: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 2,
|
||||||
|
file: {
|
||||||
|
name: 'test2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fileToEdit: {
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
test: true,
|
||||||
|
otherTest: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const expected = fromJS({
|
||||||
|
currentStep: 'edit-new',
|
||||||
|
filesToUpload: [
|
||||||
|
{
|
||||||
|
originalIndex: 0,
|
||||||
|
file: {
|
||||||
|
name: 'test',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
test: true,
|
||||||
|
otherTest: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 2,
|
||||||
|
file: {
|
||||||
|
name: 'test2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fileToEdit: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(reducer(state, action)).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('REMOVE_FILE_TO_UPLOAD', () => {
|
describe('REMOVE_FILE_TO_UPLOAD', () => {
|
||||||
it('should remove the file from the filesToUpload array', () => {
|
it('should remove the file from the filesToUpload array', () => {
|
||||||
const action = {
|
const action = {
|
||||||
@ -313,6 +378,34 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
|
|||||||
const expected = fromJS({
|
const expected = fromJS({
|
||||||
currentStep: 'browse',
|
currentStep: 'browse',
|
||||||
filesToUpload: [],
|
filesToUpload: [],
|
||||||
|
fileToEdit: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(reducer(state, action)).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('SET_CROP_RESULT', () => {
|
||||||
|
it('should update the fileToEditEntry with the passed data', () => {
|
||||||
|
const action = {
|
||||||
|
type: 'SET_CROP_RESULT',
|
||||||
|
blob: {
|
||||||
|
test: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const state = fromJS({
|
||||||
|
fileToEdit: {
|
||||||
|
originalIndex: 1,
|
||||||
|
file: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const expected = fromJS({
|
||||||
|
fileToEdit: {
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
test: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reducer(state, action)).toEqual(expected);
|
expect(reducer(state, action)).toEqual(expected);
|
||||||
@ -390,6 +483,68 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('SET_FILE_TO_EDIT', () => {
|
||||||
|
it('should set the fileToEdit key with the file at the passed index from the filesToUpload list', () => {
|
||||||
|
const action = {
|
||||||
|
type: 'SET_FILE_TO_EDIT',
|
||||||
|
fileIndex: 1,
|
||||||
|
};
|
||||||
|
const state = fromJS({
|
||||||
|
fileToEdit: null,
|
||||||
|
filesToUpload: [
|
||||||
|
{
|
||||||
|
originalIndex: 0,
|
||||||
|
file: {
|
||||||
|
name: 'test0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
name: 'test1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 2,
|
||||||
|
file: {
|
||||||
|
name: 'test2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const expected = fromJS({
|
||||||
|
fileToEdit: {
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
name: 'test1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filesToUpload: [
|
||||||
|
{
|
||||||
|
originalIndex: 0,
|
||||||
|
file: {
|
||||||
|
name: 'test0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 1,
|
||||||
|
file: {
|
||||||
|
name: 'test1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
originalIndex: 2,
|
||||||
|
file: {
|
||||||
|
name: 'test2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(reducer(state, action)).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('SET_FILES_UPLOADING_STATE', () => {
|
describe('SET_FILES_UPLOADING_STATE', () => {
|
||||||
it('should change all the isUploading keys of the filesToUpload to true', () => {
|
it('should change all the isUploading keys of the filesToUpload to true', () => {
|
||||||
const action = {
|
const action = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user