-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathaudits.unit.test.ts
More file actions
31 lines (28 loc) · 949 Bytes
/
Copy pathaudits.unit.test.ts
File metadata and controls
31 lines (28 loc) · 949 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
28
29
30
31
import { describe, expect, it } from 'vitest';
import type { AxePreset } from '../config.js';
import { loadAxeRules, transformRulesToAudits } from './transform.js';
describe('transformRulesToAudits', () => {
it.each<[AxePreset, number, number]>([
['wcag21aa', 65, 70],
['wcag22aa', 66, 72],
['best-practice', 25, 35],
['all', 100, 110],
])(
'should transform %j preset rules into audits within expected range',
(preset, min, max) => {
expect(transformRulesToAudits(loadAxeRules(preset))).toBeInRange(
min,
max,
);
},
);
it('should include required metadata fields for all transformed audits', () => {
const audit = transformRulesToAudits(loadAxeRules('wcag21aa'))[0]!;
expect(audit).toMatchObject({
slug: expect.any(String),
title: expect.any(String),
description: expect.any(String),
docsUrl: expect.stringMatching(/^https:\/\//),
});
});
});