2023-01-24 08:04:43 +00:00
|
|
|
const {models} = require('vn-loopback/server/server');
|
2021-03-01 11:15:13 +00:00
|
|
|
|
|
|
|
describe('toggleStarredModule()', () => {
|
2024-06-14 06:39:57 +00:00
|
|
|
const ctx = beforeAll.getCtx();
|
2021-03-01 11:15:13 +00:00
|
|
|
|
|
|
|
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
2023-01-24 08:04:43 +00:00
|
|
|
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
|
|
|
|
let starredModules = await models.StarredModule.getStarredModules(ctx);
|
2021-03-01 11:15:13 +00:00
|
|
|
|
|
|
|
expect(starredModules.length).toEqual(1);
|
2022-12-14 13:20:41 +00:00
|
|
|
expect(starredModule.moduleFk).toEqual('order');
|
2024-06-11 07:39:06 +00:00
|
|
|
expect(starredModule.workerFk).toEqual(ctx.req.accessToken.userId);
|
2021-06-01 20:18:13 +00:00
|
|
|
expect(starredModule.position).toEqual(starredModules.length);
|
2021-03-01 11:15:13 +00:00
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
await models.StarredModule.toggleStarredModule(ctx, 'order');
|
|
|
|
starredModules = await models.StarredModule.getStarredModules(ctx);
|
2021-03-01 11:15:13 +00:00
|
|
|
|
|
|
|
expect(starredModules.length).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|