|
1 | 1 | import { describe, expect, it } from 'vitest';
|
2 | 2 | import { LIGHTHOUSE_URL } from '../mock/constants';
|
3 |
| -import { |
4 |
| - AuditsNotImplementedError, |
5 |
| - WithSlug, |
6 |
| - filterBySlug, |
7 |
| - filterRefsBySlug, |
8 |
| - getLighthouseCliArguments, |
9 |
| -} from './utils'; |
10 |
| - |
11 |
| -describe('filterBySlug', () => { |
12 |
| - const list: WithSlug[] = [{ slug: 'a' }, { slug: 'b' }, { slug: 'c' }]; |
13 |
| - const a = list[0] as WithSlug; |
14 |
| - it.each<[string, WithSlug[], string[], WithSlug[]]>([ |
15 |
| - ['no-filter', list, [], list], |
16 |
| - ['a-filter', list, ['a'], [a]], |
17 |
| - ])( |
18 |
| - 'should filter by slugs for case "%s"', |
19 |
| - (_, testList, slugs, expectedOutput) => { |
20 |
| - expect(filterBySlug(testList, slugs)).toEqual(expectedOutput); |
21 |
| - }, |
22 |
| - ); |
23 |
| - it.each<[string, WithSlug[], string[], string[]]>([ |
24 |
| - ['wrong-filter-1', list, ['d'], ['d']], |
25 |
| - ['wrong-filter-2', list, ['d', 'a'], ['d']], |
26 |
| - ])( |
27 |
| - 'should throw for wrong filter case "%s"', |
28 |
| - (_, testList, slugs, wrongSlugs) => { |
29 |
| - expect(() => filterBySlug(testList, slugs)).toThrow( |
30 |
| - new AuditsNotImplementedError(testList, wrongSlugs), |
31 |
| - ); |
32 |
| - }, |
33 |
| - ); |
34 |
| -}); |
35 |
| - |
36 |
| -describe('filterRefsBySlug', () => { |
37 |
| - const group: { refs: WithSlug[] } = { |
38 |
| - refs: [{ slug: 'a' }, { slug: 'b' }, { slug: 'c' }], |
39 |
| - }; |
40 |
| - const refA = group.refs[0] as WithSlug; |
41 |
| - it.each<[string, { refs: WithSlug[] }, string[], { refs: WithSlug[] }]>([ |
42 |
| - ['no-filter', group, [], group], |
43 |
| - [ |
44 |
| - 'a-filter', |
45 |
| - group, |
46 |
| - ['a'], |
47 |
| - { |
48 |
| - ...group, |
49 |
| - refs: [refA], |
50 |
| - }, |
51 |
| - ], |
52 |
| - ])( |
53 |
| - 'should filter by slugs for case "%s"', |
54 |
| - (_, testGroup, slugs, expectedOutput) => { |
55 |
| - expect(filterRefsBySlug(testGroup, slugs)).toEqual(expectedOutput); |
56 |
| - }, |
57 |
| - ); |
58 |
| - |
59 |
| - it.each<[string, { refs: WithSlug[] }, string[], string[]]>([ |
60 |
| - ['wrong-filter-1', group, ['d'], ['d']], |
61 |
| - ['wrong-filter-2', group, ['a', 'd'], ['d']], |
62 |
| - ])( |
63 |
| - 'should throw for wrong filter case "%s"', |
64 |
| - (_, testGroup, slugs, wrongSlugs) => { |
65 |
| - expect(() => filterRefsBySlug(testGroup, slugs)).toThrow( |
66 |
| - new AuditsNotImplementedError(testGroup.refs, wrongSlugs), |
67 |
| - ); |
68 |
| - }, |
69 |
| - ); |
70 |
| -}); |
| 3 | +import { getLighthouseCliArguments } from './utils'; |
71 | 4 |
|
72 | 5 | describe('getLighthouseCliArguments', () => {
|
73 | 6 | it('should parse valid options', () => {
|
|
0 commit comments