forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproducts.js
More file actions
26 lines (22 loc) · 747 Bytes
/
products.js
File metadata and controls
26 lines (22 loc) · 747 Bytes
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
import Ajv from 'ajv'
import { productMap } from '../../lib/all-products.js'
import { formatAjvErrors } from '../helpers/schemas.js'
import schema from '../helpers/schemas/products-schema.js'
const ajv = new Ajv({ allErrors: true })
const validate = ajv.compile(schema)
describe('products module', () => {
test('is an object with product ids as keys', () => {
expect('desktop' in productMap).toBe(true)
expect('get-started' in productMap).toBe(true)
})
test('every product is valid', () => {
Object.values(productMap).forEach((product) => {
const valid = validate(product)
let errors
if (!valid) {
errors = formatAjvErrors(valid.errors)
}
expect(valid, errors).toBe(true)
})
})
})