mirror of
https://github.com/strapi/strapi.git
synced 2025-11-07 21:58:23 +00:00
test: test update
This commit is contained in:
parent
4f7f540599
commit
d7b86fae3b
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { decorator } = require('../entity-service-decorator')();
|
const { decorator } = require('../entity-service-decorator')();
|
||||||
|
const { omit } = require('lodash/fp');
|
||||||
|
|
||||||
jest.mock('../../../utils');
|
jest.mock('../../../utils');
|
||||||
|
|
||||||
@ -77,4 +78,71 @@ describe('Entity service decorator', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Update', () => {
|
||||||
|
test('Calls original update for non review workflow content types', async () => {
|
||||||
|
const entry = {
|
||||||
|
id: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultService = {
|
||||||
|
update: jest.fn(() => Promise.resolve(entry)),
|
||||||
|
};
|
||||||
|
|
||||||
|
const service = decorator(defaultService);
|
||||||
|
|
||||||
|
const id = 1;
|
||||||
|
const input = { data: { title: 'title ' } };
|
||||||
|
await service.update('non-rw-model', id, input);
|
||||||
|
|
||||||
|
expect(defaultService.update).toHaveBeenCalledWith('non-rw-model', id, input);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Assigns a stage to new review workflow entity', async () => {
|
||||||
|
const entry = {
|
||||||
|
id: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultService = {
|
||||||
|
update: jest.fn(() => Promise.resolve(entry)),
|
||||||
|
};
|
||||||
|
|
||||||
|
const service = decorator(defaultService);
|
||||||
|
|
||||||
|
const id = 1;
|
||||||
|
const input = { data: { title: 'title ', strapi_reviewWorkflows_stage: 1 } };
|
||||||
|
await service.update('test-model', id, input);
|
||||||
|
|
||||||
|
expect(defaultService.update).toHaveBeenCalledWith('test-model', id, {
|
||||||
|
...input,
|
||||||
|
data: {
|
||||||
|
...input.data,
|
||||||
|
strapi_reviewWorkflows_stage: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can not assign a null stage to new review workflow entity', async () => {
|
||||||
|
const entry = {
|
||||||
|
id: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultService = {
|
||||||
|
update: jest.fn(() => Promise.resolve(entry)),
|
||||||
|
};
|
||||||
|
|
||||||
|
const service = decorator(defaultService);
|
||||||
|
|
||||||
|
const id = 1;
|
||||||
|
const input = { data: { title: 'title ', strapi_reviewWorkflows_stage: null } };
|
||||||
|
await service.update('test-model', id, input);
|
||||||
|
|
||||||
|
expect(defaultService.update).toHaveBeenCalledWith('test-model', id, {
|
||||||
|
...input,
|
||||||
|
data: {
|
||||||
|
...omit('strapi_reviewWorkflows_stage', input.data),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user