56 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
const contentManagerService = require('../ContentManager');
describe('Content-Manager', () => {
describe('Publish', () => {
beforeEach(() => {
global.strapi = {
entityService: {
update: jest.fn(),
},
};
});
afterEach(() => {
jest.clearAllMocks();
});
test('Publish a content-type', async () => {
const model = 'application::test.test';
const params = { id: 1 };
await contentManagerService.publish(params, model);
expect(strapi.entityService.update).toBeCalledWith(
{ params, data: { published_at: expect.any(String) } },
{ model }
);
});
});
describe('Unpublish', () => {
beforeEach(() => {
global.strapi = {
entityService: {
update: jest.fn(),
},
};
});
afterEach(() => {
jest.clearAllMocks();
});
test('Unpublish a content-type', async () => {
const model = 'application::test.test';
const params = { id: 1 };
await contentManagerService.unpublish(params, model);
expect(strapi.entityService.update).toHaveBeenCalledWith(
{ params, data: { published_at: null } },
{ model }
);
});
});
});