-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo.spec.ts
46 lines (35 loc) · 1.36 KB
/
video.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import ProductVideoService from '../product-video';
const mockVideoId = "sdiufhs8";
const mockProductId = "1234"
// manual mocking. Replace with Medusa test tooling once officially available. Currently installing "medusa-test-utils" fails because of peer dep incompatability
const mockRepo = {
findOne: () => {
return { video_id: mockVideoId, product_id: mockProductId }
},
save: () => {
}
}
const mockManager = {
getRepository: () => {
return mockRepo;
}
}
describe('video plugin service', () => {
it('stores video', async () => {
const productVideoService = new ProductVideoService({
manager: mockManager
});
const newProductVideo = await productVideoService.storeVideo(mockProductId, mockVideoId);
expect(newProductVideo.video_id).toEqual(mockVideoId);
expect(newProductVideo.product_id).toEqual(mockProductId);
});
it('retrieves a video', async () => {
const productVideoService = new ProductVideoService({
manager: mockManager
});
const productVideo = await productVideoService.getVideoByProductId(mockProductId);
expect(productVideo.video_id).toBe(mockVideoId);
expect(productVideo.product_id).toBe(mockProductId);
expect(productVideo.embedUrl).toBe(`https://www.youtube.com/embed/${mockVideoId}`);
});
});