|
| 1 | +import { parseStyles, styleByIndex, styleBySearch } from './index'; |
| 2 | + |
| 3 | +test('correctly parses styles', () => { |
| 4 | + expect( |
| 5 | + parseStyles(`This should be *bold* |
| 6 | +and this _should italics_ be`) |
| 7 | + ).toStrictEqual([ |
| 8 | + { content: 'This should be', line: 0, style: 'regular' }, |
| 9 | + { content: 'bold', line: 0, style: 'bold' }, |
| 10 | + { content: 'and this', line: 1, style: 'regular' }, |
| 11 | + { content: 'should italics', line: 1, style: 'italics' }, |
| 12 | + { content: 'be', line: 1, style: 'regular' }, |
| 13 | + ]); |
| 14 | +}); |
| 15 | + |
| 16 | +test('correctly styles by search', () => { |
| 17 | + expect( |
| 18 | + styleBySearch( |
| 19 | + `This should be bold |
| 20 | +and this should italics be`, |
| 21 | + { boldString: 'bold', italicsString: 'should italics' } |
| 22 | + ) |
| 23 | + ).toStrictEqual([ |
| 24 | + { content: 'This should be', line: 0, style: 'regular' }, |
| 25 | + { content: 'bold', line: 0, style: 'bold' }, |
| 26 | + { content: 'and this', line: 1, style: 'regular' }, |
| 27 | + { content: 'should italics', line: 1, style: 'italics' }, |
| 28 | + { content: 'be', line: 1, style: 'regular' }, |
| 29 | + ]); |
| 30 | +}); |
| 31 | + |
| 32 | +test('correctly styles by index', () => { |
| 33 | + expect( |
| 34 | + styleByIndex( |
| 35 | + `This should be bold |
| 36 | + and this italics be`, |
| 37 | + { boldIndexes: [3], italicsIndexes: [6] } |
| 38 | + ) |
| 39 | + ).toStrictEqual([ |
| 40 | + { content: 'This should be', line: 0, style: 'regular' }, |
| 41 | + { content: 'bold', line: 0, style: 'bold' }, |
| 42 | + { content: 'and this', line: 1, style: 'regular' }, |
| 43 | + { content: 'should italics', line: 1, style: 'italics' }, |
| 44 | + { content: 'be', line: 1, style: 'regular' }, |
| 45 | + ]); |
| 46 | +}); |
0 commit comments