Skip to content

Commit

Permalink
Remove OS eol diffs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Jul 22, 2024
1 parent 5d23932 commit 799cc42
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 44 deletions.
4 changes: 0 additions & 4 deletions packages/knip/test/cli/reporter/cli-reporter-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { resolve } from '../../../src/util/path.js';
import { execFactory } from '../../helpers/exec.js';
import { updatePos } from '../../helpers/index.js';

const cwd = resolve('fixtures/exports');

Expand Down Expand Up @@ -121,8 +120,5 @@ test('knip --reporter json (exports & types)', () => {
],
};

// Add line - 1 to every pos (each EOL is one more char)
updatePos(json);

assert.equal(exec('knip --reporter json').stdout, `${JSON.stringify(json)}\n`);
});
4 changes: 0 additions & 4 deletions packages/knip/test/cli/reporter/cli-reporter-json2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { resolve } from '../../../src/util/path.js';
import { execFactory } from '../../helpers/exec.js';
import { updatePos } from '../../helpers/index.js';

const cwd = resolve('fixtures/module-resolution-non-std');

Expand All @@ -28,8 +27,5 @@ test('knip --reporter json (files, unlisted & unresolved)', () => {
],
};

// Add line - 1 to every pos (each EOL is one more char)
updatePos(json);

assert.equal(exec('knip --reporter json').stdout, `${JSON.stringify(json)}\n`);
});
4 changes: 0 additions & 4 deletions packages/knip/test/cli/reporter/cli-reporter-json3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { resolve } from '../../../src/util/path.js';
import { execFactory } from '../../helpers/exec.js';
import { updatePos } from '../../helpers/index.js';

const cwd = resolve('fixtures/enum-members');

Expand Down Expand Up @@ -33,8 +32,5 @@ test('knip --reporter json (enum members)', () => {
],
};

// Add line - 1 to every pos (each EOL is one more char)
updatePos(json);

assert.equal(exec('knip --reporter json').stdout, `${JSON.stringify(json)}\n`);
});
13 changes: 6 additions & 7 deletions packages/knip/test/fix-workspaces.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { readFile, writeFile } from 'node:fs/promises';
import { EOL } from 'node:os';
import { main } from '../src/index.js';
import { join, resolve } from '../src/util/path.js';
import baseArguments from './helpers/baseArguments.js';
Expand All @@ -22,7 +21,7 @@ type T = number;
/** @knipignore */
export type U = number;
`.replace(/\n/g, EOL),
`,
],
[
'package.json',
Expand All @@ -36,7 +35,7 @@ export type U = number;
"packages/*"
]
}
`.replace(/\n/g, EOL),
`,
],
[
'packages/lib/exports.ts',
Expand All @@ -48,7 +47,7 @@ type T = number;
/** @knipignore */
export type U = number;
`.replace(/\n/g, EOL),
`,
],
[
'packages/lib/package.json',
Expand All @@ -59,7 +58,7 @@ export type U = number;
"ignored": "*"
}
}
`.replace(/\n/g, EOL),
`,
],
];

Expand Down Expand Up @@ -114,7 +113,7 @@ type T = number;
/** @knipignore */
export type U = number;
`.replace(/\n/g, EOL),
`,
],
[
'packages/lib/exports.ts',
Expand All @@ -126,7 +125,7 @@ type T = number;
/** @knipignore */
export type U = number;
`.replace(/\n/g, EOL),
`,
],
];

Expand Down
15 changes: 7 additions & 8 deletions packages/knip/test/fix.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { readFile, writeFile } from 'node:fs/promises';
import { EOL } from 'node:os';
import { main } from '../src/index.js';
import { join, resolve } from '../src/util/path.js';
import baseArguments from './helpers/baseArguments.js';
Expand Down Expand Up @@ -32,15 +31,15 @@ class MyClass {}
/** @knipignore */
export type U = number;
`.replace(/\n/g, EOL),
`,
],
[
'access.js',
await readContents('access.js'),
`module.exports.USED = 1;
`.replace(/\n/g, EOL),
`,
],
[
'exports.js',
Expand All @@ -49,7 +48,7 @@ export type U = number;
const identifier2 = 2;
module.exports = { identifier, };
`.replace(/\n/g, EOL),
`,
],
[
'reexports.js',
Expand All @@ -59,7 +58,7 @@ export { Rating } from './reexported';
export { One } from './reexported';
export { Col, Col as KCol } from './reexported';
export { Row as KRow, Row } from './reexported';
`.replace(/\n/g, EOL),
`,
],
[
'reexported.js',
Expand All @@ -69,7 +68,7 @@ const Three = 2;
export const One = 1;
`.replace(/\n/g, EOL),
`,
],
[
'package.json',
Expand All @@ -82,7 +81,7 @@ export const One = 1;
},
"devDependencies": {}
}
`.replace(/\n/g, EOL),
`,
],
];

Expand Down Expand Up @@ -145,7 +144,7 @@ export default class MyClass {}
/** @knipignore */
export type U = number;
`.replace(/\n/g, EOL),
`,
],
];

Expand Down
17 changes: 0 additions & 17 deletions packages/knip/test/helpers/index.ts

This file was deleted.

0 comments on commit 799cc42

Please sign in to comment.