|
| 1 | +import { Report } from '@code-pushup/models'; |
| 2 | +import { |
| 3 | + listAuditsFromAllPlugins, |
| 4 | + listGroupsFromAllPlugins, |
| 5 | +} from './flatten-plugins'; |
| 6 | + |
| 7 | +describe('listGroupsFromAllPlugins', () => { |
| 8 | + it("should flatten plugins' groups", () => { |
| 9 | + expect( |
| 10 | + listGroupsFromAllPlugins({ |
| 11 | + plugins: [ |
| 12 | + { |
| 13 | + slug: 'eslint', |
| 14 | + groups: [ |
| 15 | + { slug: 'problems' }, |
| 16 | + { slug: 'suggestions' }, |
| 17 | + { slug: 'formatting' }, |
| 18 | + ], |
| 19 | + }, |
| 20 | + { |
| 21 | + slug: 'lighthouse', |
| 22 | + groups: [ |
| 23 | + { slug: 'performance' }, |
| 24 | + { slug: 'accessibility' }, |
| 25 | + { slug: 'best-practices' }, |
| 26 | + { slug: 'seo' }, |
| 27 | + ], |
| 28 | + }, |
| 29 | + ], |
| 30 | + } as Report), |
| 31 | + ).toEqual([ |
| 32 | + { |
| 33 | + group: expect.objectContaining({ slug: 'problems' }), |
| 34 | + plugin: expect.objectContaining({ slug: 'eslint' }), |
| 35 | + }, |
| 36 | + { |
| 37 | + group: expect.objectContaining({ slug: 'suggestions' }), |
| 38 | + plugin: expect.objectContaining({ slug: 'eslint' }), |
| 39 | + }, |
| 40 | + { |
| 41 | + group: expect.objectContaining({ slug: 'formatting' }), |
| 42 | + plugin: expect.objectContaining({ slug: 'eslint' }), |
| 43 | + }, |
| 44 | + { |
| 45 | + group: expect.objectContaining({ slug: 'performance' }), |
| 46 | + plugin: expect.objectContaining({ slug: 'lighthouse' }), |
| 47 | + }, |
| 48 | + { |
| 49 | + group: expect.objectContaining({ slug: 'accessibility' }), |
| 50 | + plugin: expect.objectContaining({ slug: 'lighthouse' }), |
| 51 | + }, |
| 52 | + { |
| 53 | + group: expect.objectContaining({ slug: 'best-practices' }), |
| 54 | + plugin: expect.objectContaining({ slug: 'lighthouse' }), |
| 55 | + }, |
| 56 | + { |
| 57 | + group: expect.objectContaining({ slug: 'seo' }), |
| 58 | + plugin: expect.objectContaining({ slug: 'lighthouse' }), |
| 59 | + }, |
| 60 | + ]); |
| 61 | + }); |
| 62 | +}); |
| 63 | + |
| 64 | +describe('listAuditsFromAllPlugins', () => { |
| 65 | + it("should flatten plugins' audits", () => { |
| 66 | + expect( |
| 67 | + listAuditsFromAllPlugins({ |
| 68 | + plugins: [ |
| 69 | + { |
| 70 | + slug: 'coverage', |
| 71 | + audits: [ |
| 72 | + { slug: 'function-coverage' }, |
| 73 | + { slug: 'branch-coverage' }, |
| 74 | + { slug: 'statement-coverage' }, |
| 75 | + ], |
| 76 | + }, |
| 77 | + { |
| 78 | + slug: 'js-packages', |
| 79 | + audits: [{ slug: 'audit' }, { slug: 'outdated' }], |
| 80 | + }, |
| 81 | + ], |
| 82 | + } as Report), |
| 83 | + ).toEqual([ |
| 84 | + { |
| 85 | + audit: expect.objectContaining({ slug: 'function-coverage' }), |
| 86 | + plugin: expect.objectContaining({ slug: 'coverage' }), |
| 87 | + }, |
| 88 | + { |
| 89 | + audit: expect.objectContaining({ slug: 'branch-coverage' }), |
| 90 | + plugin: expect.objectContaining({ slug: 'coverage' }), |
| 91 | + }, |
| 92 | + { |
| 93 | + audit: expect.objectContaining({ slug: 'statement-coverage' }), |
| 94 | + plugin: expect.objectContaining({ slug: 'coverage' }), |
| 95 | + }, |
| 96 | + { |
| 97 | + audit: expect.objectContaining({ slug: 'audit' }), |
| 98 | + plugin: expect.objectContaining({ slug: 'js-packages' }), |
| 99 | + }, |
| 100 | + { |
| 101 | + audit: expect.objectContaining({ slug: 'outdated' }), |
| 102 | + plugin: expect.objectContaining({ slug: 'js-packages' }), |
| 103 | + }, |
| 104 | + ]); |
| 105 | + }); |
| 106 | +}); |
0 commit comments