|
| 1 | +import { describe, it, expect } from 'vitest'; |
| 2 | +import { |
| 3 | + wrapRichText, |
| 4 | + wrapTestCaseSteps, |
| 5 | +} from '../../src/tools/testmanagement-utils/rich-text'; |
| 6 | + |
| 7 | +describe('wrapRichText', () => { |
| 8 | + it('wraps bare text containing > in <p> tags', () => { |
| 9 | + expect(wrapRichText('Navigate to Settings > Users')).toBe( |
| 10 | + '<p>Navigate to Settings > Users</p>', |
| 11 | + ); |
| 12 | + }); |
| 13 | + |
| 14 | + it('wraps bare text containing < in <p> tags', () => { |
| 15 | + expect(wrapRichText('if a < b then pass')).toBe( |
| 16 | + '<p>if a < b then pass</p>', |
| 17 | + ); |
| 18 | + }); |
| 19 | + |
| 20 | + it('wraps bare text containing & in <p> tags', () => { |
| 21 | + expect(wrapRichText('Q&A section loads')).toBe('<p>Q&A section loads</p>'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('leaves text without <, > or & untouched', () => { |
| 25 | + expect(wrapRichText('Click "Save" then \'Confirm\'')).toBe( |
| 26 | + 'Click "Save" then \'Confirm\'', |
| 27 | + ); |
| 28 | + }); |
| 29 | + |
| 30 | + it('leaves already-HTML content untouched', () => { |
| 31 | + expect(wrapRichText('<p>Settings > Users</p>')).toBe( |
| 32 | + '<p>Settings > Users</p>', |
| 33 | + ); |
| 34 | + expect(wrapRichText(' <ul><li>A & B</li></ul>')).toBe( |
| 35 | + ' <ul><li>A & B</li></ul>', |
| 36 | + ); |
| 37 | + }); |
| 38 | + |
| 39 | + it('wraps text starting with < that is not a tag', () => { |
| 40 | + expect(wrapRichText('< 5 items are shown')).toBe( |
| 41 | + '<p>< 5 items are shown</p>', |
| 42 | + ); |
| 43 | + }); |
| 44 | +}); |
| 45 | + |
| 46 | +describe('wrapTestCaseSteps', () => { |
| 47 | + it('wraps step and result independently and preserves other keys', () => { |
| 48 | + expect( |
| 49 | + wrapTestCaseSteps([ |
| 50 | + { step: 'Go to A > B', result: 'B page loads' }, |
| 51 | + { step: 'Click Save', result: 'Count > 0' }, |
| 52 | + ]), |
| 53 | + ).toEqual([ |
| 54 | + { step: '<p>Go to A > B</p>', result: 'B page loads' }, |
| 55 | + { step: 'Click Save', result: '<p>Count > 0</p>' }, |
| 56 | + ]); |
| 57 | + }); |
| 58 | + |
| 59 | + it('returns an empty array unchanged', () => { |
| 60 | + expect(wrapTestCaseSteps([])).toEqual([]); |
| 61 | + }); |
| 62 | +}); |
0 commit comments