-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcrawler.test.js
More file actions
61 lines (50 loc) · 1.76 KB
/
crawler.test.js
File metadata and controls
61 lines (50 loc) · 1.76 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const crawler = require('./crawler');
jest.setTimeout(36000);
describe('gets products', () => {
let products = [];
beforeAll( async () => {
products = await crawler.getData();
});
it('gets at at least 10 products', () => {
expect(products.length).toBeGreaterThanOrEqual(10);
});
it('gets valid skus', () => {
products.forEach(product => {
expect(product.sku.length).toBeLessThanOrEqual(30);
expect(product.sku.length).toBeGreaterThanOrEqual(3);
});
});
it('gets valid names', () => {
products.forEach(product => {
expect(product.name.length).toBeLessThanOrEqual(250);
expect(product.name.length).toBeGreaterThanOrEqual(3);
});
});
it('gets valid sale prices', () => {
products.forEach(product => {
expect(product.salePrice).toBeLessThanOrEqual(15000);
expect(product.salePrice).toBeGreaterThanOrEqual(0);
});
});
it('gets valid msrps', () => {
products.forEach(product => {
expect(product.msrp).toBeLessThanOrEqual(15000);
expect(product.msrp).toBeGreaterThanOrEqual(0);
});
});
it('gets valid product types', () => {
products.forEach(product => {
expect(['plugin', 'bundle']).toContain(product.type);
});
});
it('gets valid urls', () => {
products.forEach(product => {
expect(product.url).toMatch(/^https:\/\/www.waves.com\/plugins\/.+$/);
});
});
it('gets valid image urls', () => {
products.forEach(product => {
expect(product.thumbnailUrl).toMatch(/^https:\/\/.*\.png$/);
});
});
});