Skip to content

Commit

Permalink
chore: fix unit tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
L2jLiga committed Aug 2, 2024
1 parent f829b87 commit f9a7944
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/daemon.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs';
import fs_promises from 'node:fs/promises';
import { resolve } from 'node:path';
import { normalize, resolve } from 'node:path';
import crypto from 'node:crypto';
import net from 'node:net';
import { assert, refute, match, sinon } from '@sinonjs/referee-sinon';
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('lib/daemon', () => {
assert.equals(process.title, 'eslint_d');
assert.calledOnceWith(
fs.readFile,
`${resolve(project)}/package.json`,
normalize(`${resolve(project)}/package.json`),
'utf8'
);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/forwarder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('lib/forwarder', () => {

assert.calledOnceWith(
socket.write,
`["token",${color_level},"the/cwd",["node","eslint_d"]]`
`["token",${color_level},"the/cwd",[${JSON.stringify(process.argv0)},"eslint_d"]]`
);
assert.calledOnce(socket.end);
});
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('lib/forwarder', () => {
assert.calledThrice(socket.write);
assert.calledWith(
socket.write,
`["token",${color_level},"cwd",["node","eslint_d","--stdin","--fix-dry-run","--format","json","--other","--options"]]`
`["token",${color_level},"cwd",[${JSON.stringify(process.argv0)},"eslint_d","--stdin","--fix-dry-run","--format","json","--other","--options"]]`
);
assert.calledWith(socket.write, '\n');
assert.calledWith(socket.write, 'text from stdin');
Expand Down
11 changes: 6 additions & 5 deletions lib/hash.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { normalize } from 'node:path';
import fs from 'node:fs/promises';
import { assert, sinon } from '@sinonjs/referee-sinon';
import { filesHash } from './hash.js';
Expand All @@ -13,11 +14,11 @@ describe('lib/hash', () => {
filesHash(base);

assert.callCount(fs.readFile, 5);
assert.calledWith(fs.readFile, `${cwd}/some/dir/package.json`);
assert.calledWith(fs.readFile, `${cwd}/some/dir/package-lock.json`);
assert.calledWith(fs.readFile, `${cwd}/some/dir/npm-shrinkwrap.json`);
assert.calledWith(fs.readFile, `${cwd}/some/dir/yarn.lock`);
assert.calledWith(fs.readFile, `${cwd}/some/dir/pnpm-lock.yaml`);
assert.calledWith(fs.readFile, normalize(`${cwd}/some/dir/package.json`));
assert.calledWith(fs.readFile, normalize(`${cwd}/some/dir/package-lock.json`));
assert.calledWith(fs.readFile, normalize(`${cwd}/some/dir/npm-shrinkwrap.json`));
assert.calledWith(fs.readFile, normalize(`${cwd}/some/dir/yarn.lock`));
assert.calledWith(fs.readFile, normalize(`${cwd}/some/dir/pnpm-lock.yaml`));
});

it('resolves with hash of all files', async () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/resolver.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'node:path';
import { normalize, resolve } from 'node:path';
import { assert, refute, match, sinon } from '@sinonjs/referee-sinon';
import { createResolver } from './resolver.js';

Expand All @@ -16,7 +16,7 @@ describe('lib/resolver', () => {

refute.isString(resolver);
assert.isFalse(resolver['bundled']);
assert.equals(resolver['base'], `${test_dir}/node_modules/eslint`);
assert.equals(resolver['base'], normalize(`${test_dir}/node_modules/eslint`));
});
}

Expand Down

0 comments on commit f9a7944

Please sign in to comment.