const {models} = require('vn-loopback/server/server'); describe('Share Token', () => { let ctx = null; beforeAll(async() => { const unAuthCtx = { req: { headers: {}, connection: { remoteAddress: '127.0.0.1' }, getLocale: () => 'en' }, args: {} }; let login = await models.VnUser.signIn(unAuthCtx, 'salesAssistant', 'nightmare'); let accessToken = await models.AccessToken.findById(login.token); ctx = {req: {accessToken: accessToken}}; }); it('should renew token', async() => { const multimediaToken = await models.VnUser.shareToken(ctx); expect(Object.keys(multimediaToken).length).toEqual(1); expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId); expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia'); }); });