salix/back/methods/image/specs/download.spec.js

24 lines
750 B
JavaScript
Raw Normal View History

2023-01-24 08:04:43 +00:00
const {models} = require('vn-loopback/server/server');
2020-11-10 07:39:34 +00:00
2020-11-11 10:58:14 +00:00
describe('image download()', () => {
2020-11-10 07:39:34 +00:00
const collection = 'user';
const size = '160x160';
2020-12-11 14:04:55 +00:00
const employeeId = 1;
const ctx = {req: {accessToken: {userId: employeeId}}};
2020-11-10 07:39:34 +00:00
it('should return the image content-type of the user', async() => {
const userId = 9;
2023-01-24 08:04:43 +00:00
const image = await models.Image.download(ctx, collection, size, userId);
2020-11-11 10:58:14 +00:00
const contentType = image[1];
2020-11-10 07:39:34 +00:00
2020-11-11 10:58:14 +00:00
expect(contentType).toEqual('image/png');
2020-11-10 07:39:34 +00:00
});
2020-11-11 10:58:14 +00:00
it(`should return false if the user doesn't have image`, async() => {
const userId = 1110;
2023-01-24 08:04:43 +00:00
const image = await models.Image.download(ctx, collection, size, userId);
2020-11-10 07:39:34 +00:00
2020-11-10 10:33:01 +00:00
expect(image).toBeFalse();
2020-11-10 07:39:34 +00:00
});
});