21 lines
885 B
JavaScript
21 lines
885 B
JavaScript
const {models} = require('vn-loopback/server/server');
|
|
|
|
describe('toggleStarredModule()', () => {
|
|
const {ctx} = beforeAll;
|
|
|
|
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
|
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
|
|
let starredModules = await models.StarredModule.getStarredModules(ctx);
|
|
|
|
expect(starredModules.length).toEqual(1);
|
|
expect(starredModule.moduleFk).toEqual('order');
|
|
expect(starredModule.workerFk).toEqual(ctx.req.accessToken.userId);
|
|
expect(starredModule.position).toEqual(starredModules.length);
|
|
|
|
await models.StarredModule.toggleStarredModule(ctx, 'order');
|
|
starredModules = await models.StarredModule.getStarredModules(ctx);
|
|
|
|
expect(starredModules.length).toEqual(0);
|
|
});
|
|
});
|