Fix tests

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-10-05 16:00:58 +02:00
parent c60f826f4e
commit cd6894e573
2 changed files with 6 additions and 6 deletions

View File

@ -58,7 +58,8 @@ module.exports = {
}, },
edit(params, { data, files }, { model } = {}) { edit(params, { data, files }, { model } = {}) {
return strapi.entityService.update({ params, data, files }, { model }); const publishData = _.omit(data, PUBLISHED_AT_ATTRIBUTE);
return strapi.entityService.update({ params, data: publishData, files }, { model });
}, },
delete(model, query) { delete(model, query) {

View File

@ -82,7 +82,7 @@ describe('Core API - Basic + draftAndPublish', () => {
data.products.push(res.body); data.products.push(res.body);
}); });
test('Create a product + cannot overwrite published_at', async () => { test('Create a product + can overwrite published_at', async () => {
const product = { const product = {
name: 'Product 2', name: 'Product 2',
description: 'Product description', description: 'Product description',
@ -97,7 +97,7 @@ describe('Core API - Basic + draftAndPublish', () => {
expect(res.statusCode).toBe(200); expect(res.statusCode).toBe(200);
expect(res.body).toMatchObject(_.omit(product, 'published_at')); expect(res.body).toMatchObject(_.omit(product, 'published_at'));
expect(res.body.published_at).toBeISODate(); expect(res.body.published_at).toBeISODate();
expect(res.body.published_at).not.toBe(product.published_at); expect(res.body.published_at).toBe(product.published_at);
data.products.push(res.body); data.products.push(res.body);
}); });
@ -141,7 +141,7 @@ describe('Core API - Basic + draftAndPublish', () => {
data.products[0] = res.body; data.products[0] = res.body;
}); });
test('Update product + cannot overwrite published_at', async () => { test('Update product + can overwrite published_at', async () => {
const product = { const product = {
name: 'Product 1 updated', name: 'Product 1 updated',
description: 'Updated Product description', description: 'Updated Product description',
@ -155,9 +155,8 @@ describe('Core API - Basic + draftAndPublish', () => {
expect(res.statusCode).toBe(200); expect(res.statusCode).toBe(200);
expect(res.body).toMatchObject(_.pick(data.products[0], ['name', 'description'])); expect(res.body).toMatchObject(_.pick(data.products[0], ['name', 'description']));
expect(res.body.published_at).toBe(data.products[0].published_at);
expect(res.body.published_at).toBeISODate(); expect(res.body.published_at).toBeISODate();
expect(res.body.published_at).not.toBe(product.published_at); expect(res.body.published_at).toBe(product.published_at);
data.products[0] = res.body; data.products[0] = res.body;
}); });