12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import crlf, { Ending } from '../../src/transforms/crlf';
- import getParser, { Parser } from '../../src/parser/index';
- import getStringifier, { Stringifier } from '../../src/stringifier/index';
-
- const tests = [
- [
- 'no CR',
- 'CRLF',
- `
- /**
- * description
- *
- */`,
- `
- /**\r
- * description\r
- *\r
- */\r`,
- ],
- [
- 'mixed',
- 'CRLF',
- `
- /**
- * description
- *\r
- */`,
- `
- /**\r
- * description\r
- *\r
- */\r`,
- ],
- [
- 'no CR',
- 'LF',
- `
- /**
- * description
- *
- */`,
- `
- /**
- * description
- *
- */`,
- ],
- [
- 'mixed',
- 'LF',
- `
- /**
- * description
- *\r
- */`,
- `
- /**
- * description
- *
- */`,
- ],
- ];
-
- test.each(tests)('CRLF - %s to %s', (name, mode, source, expected) => {
- expected = expected.slice(1);
- const parsed = getParser()(source);
- const normalized = crlf(mode as Ending)(parsed[0]);
- const out = getStringifier()(normalized);
- expect(out).toBe(expected);
- });
|