-
Notifications
You must be signed in to change notification settings - Fork 66.5k
Expand file tree
/
Copy pathproducts.ts
More file actions
27 lines (22 loc) · 861 Bytes
/
products.ts
File metadata and controls
27 lines (22 loc) · 861 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
27
import { describe, expect, test } from 'vitest'
import { getJsonValidator } from '@/tests/lib/validate-json-schema'
import { productMap } from '@/products/lib/all-products'
import { formatAjvErrors } from '@/tests/helpers/schemas'
import schema from '@/tests/helpers/schemas/products-schema'
const validate = getJsonValidator(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', () => {
for (const product of Object.values(productMap)) {
const isValid = validate(product)
let errors: string | undefined
if (!isValid && validate.errors) {
errors = formatAjvErrors(validate.errors)
}
expect(isValid, errors).toBe(true)
}
})
})