(contextLines?: number)
| 704 | |
| 705 | describe('context', () => { |
| 706 | const testDiffContextLines = (contextLines?: number) => { |
| 707 | const validContextLines = |
| 708 | typeof contextLines === 'number' && |
| 709 | Number.isSafeInteger(contextLines) && |
| 710 | contextLines >= 0; |
| 711 | |
| 712 | test(`number of lines: ${ |
| 713 | typeof contextLines === 'number' ? contextLines : 'undefined' |
| 714 | } ${validContextLines ? '' : '(5 default)'}`, () => { |
| 715 | const options = { |
| 716 | ...optionsCounts, |
| 717 | contextLines, |
| 718 | expand: false, |
| 719 | }; |
| 720 | if (!validContextLines) { |
| 721 | options.patchColor = chalk.dim; |
| 722 | } |
| 723 | |
| 724 | const result = diff( |
| 725 | {test: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}, |
| 726 | {test: [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]}, |
| 727 | options, |
| 728 | ); |
| 729 | expect(result).toMatchSnapshot(); |
| 730 | }); |
| 731 | }; |
| 732 | |
| 733 | testDiffContextLines(-1); // (5 default) |
| 734 | testDiffContextLines(0); |
no test coverage detected