33 lines
1005 B
JavaScript
33 lines
1005 B
JavaScript
const app = require('vn-loopback/server/server');
|
|
const LoopBackContext = require('loopback-context');
|
|
|
|
describe('getStarredModules()', () => {
|
|
const activeCtx = {
|
|
accessToken: {userId: 9},
|
|
http: {
|
|
req: {
|
|
headers: {origin: 'http://localhost'}
|
|
}
|
|
}
|
|
};
|
|
const ctx = {req: activeCtx};
|
|
|
|
beforeEach(() => {
|
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
active: activeCtx
|
|
});
|
|
});
|
|
|
|
it(`should return the starred modules for a given user`, async() => {
|
|
console.log('GET');
|
|
const newStarred = await app.models.StarredModule.create({workerFk: 9, moduleFk: 'Clients'});
|
|
const starredModules = await app.models.StarredModule.getStarredModules(ctx);
|
|
|
|
expect(starredModules.length).toEqual(1);
|
|
expect(starredModules[0].moduleFk).toEqual('Clients');
|
|
|
|
// restores
|
|
await app.models.StarredModule.destroyById(newStarred.id);
|
|
});
|
|
});
|