|
| 1 | +import { formatStartMessage } from './helpers.js'; |
| 2 | + |
| 3 | +describe('formatStartMessage', () => { |
| 4 | + it('should format a message using only the path', () => { |
| 5 | + const result = formatStartMessage({ path: 'https://example.com/path' }); |
| 6 | + expect(result).toEqual('Running Lighthouse on https://example.com/path'); |
| 7 | + }); |
| 8 | + |
| 9 | + it('should format a message using only the path and count', () => { |
| 10 | + const result = formatStartMessage({ |
| 11 | + count: { i: 1, total: 2 }, |
| 12 | + path: 'https://example.com/path', |
| 13 | + }); |
| 14 | + expect(result).toEqual( |
| 15 | + 'Running Lighthouse on https://example.com/path (1/2)', |
| 16 | + ); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should format a message using a single feature', () => { |
| 20 | + const result = formatStartMessage({ |
| 21 | + path: 'https://example.com/path', |
| 22 | + formFactor: 'desktop', |
| 23 | + }); |
| 24 | + expect(result).toEqual( |
| 25 | + 'Running Lighthouse on https://example.com/path using the “desktop” preset', |
| 26 | + ); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should format a message using multiple features', () => { |
| 30 | + const result = formatStartMessage({ |
| 31 | + path: 'https://example.com/path', |
| 32 | + formFactor: 'desktop', |
| 33 | + locale: 'de', |
| 34 | + }); |
| 35 | + expect(result).toEqual( |
| 36 | + 'Running Lighthouse on https://example.com/path using the “de” locale and the “desktop” preset', |
| 37 | + ); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should format a message using all available inputs', () => { |
| 41 | + const result = formatStartMessage({ |
| 42 | + count: { i: 1, total: 2 }, |
| 43 | + path: 'https://example.com/path', |
| 44 | + formFactor: 'desktop', |
| 45 | + locale: 'es', |
| 46 | + }); |
| 47 | + expect(result).toEqual( |
| 48 | + 'Running Lighthouse on https://example.com/path using the “es” locale and the “desktop” preset (1/2)', |
| 49 | + ); |
| 50 | + }); |
| 51 | +}); |
0 commit comments