From 9a58b1a8ffc7a7791179c6e0a1a7b3d2ce10da0c Mon Sep 17 00:00:00 2001 From: James Prevett Date: Fri, 17 Jan 2025 20:06:06 -0600 Subject: [PATCH] Switch to strict assertion mode --- tests/common/context.test.ts | 20 ++++++++++---------- tests/common/devices.test.ts | 2 +- tests/common/handle.test.ts | 2 +- tests/common/mounts.test.ts | 6 +++--- tests/common/mutex.test.ts | 4 ++-- tests/common/path.test.ts | 2 +- tests/fs/append.test.ts | 2 +- tests/fs/dir.test.ts | 8 ++++---- tests/fs/directory.test.ts | 16 ++++++++-------- tests/fs/errors.test.ts | 2 +- tests/fs/exists.test.ts | 2 +- tests/fs/links.test.ts | 8 ++++---- tests/fs/open.test.ts | 6 +++--- tests/fs/permissions.test.ts | 4 ++-- tests/fs/read.test.ts | 18 +++++++++--------- tests/fs/readFile.test.ts | 12 ++++++------ tests/fs/rename.test.ts | 8 ++++---- tests/fs/stat.test.ts | 2 +- tests/fs/streams.test.ts | 22 +++++++++++----------- tests/fs/times.test.ts | 12 ++++++------ tests/fs/truncate.test.ts | 2 +- tests/fs/watch.test.ts | 20 ++++++++++---------- tests/fs/write.test.ts | 14 +++++++------- tests/fs/writeFile.test.ts | 12 ++++++------ tests/port/channel.test.ts | 2 +- tests/port/config.test.ts | 2 +- tests/port/remote.test.ts | 2 +- tests/port/timeout.test.ts | 6 +++--- 28 files changed, 109 insertions(+), 109 deletions(-) diff --git a/tests/common/context.test.ts b/tests/common/context.test.ts index a8afc7b6..9c6343c0 100644 --- a/tests/common/context.test.ts +++ b/tests/common/context.test.ts @@ -1,5 +1,5 @@ import { suite, test } from 'node:test'; -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { bindContext } from '../../dist/context.js'; import * as fs from '../../dist/vfs/index.js'; @@ -15,8 +15,8 @@ suite('Context', () => { test('linking', async () => { await ctx.promises.symlink('/example.txt', '/link'); - assert.strictEqual(await ctx.promises.readlink('link', 'utf8'), '/example.txt'); - assert.strictEqual(await fs.promises.readlink('/ctx/link'), '/example.txt'); + assert.equal(await ctx.promises.readlink('link', 'utf8'), '/example.txt'); + assert.equal(await fs.promises.readlink('/ctx/link'), '/example.txt'); assert.deepEqual(await ctx.promises.readFile('/link', 'utf-8'), await fs.promises.readFile('/ctx/example.txt', 'utf-8')); // The symlink should only work inside the chroot /ctx @@ -25,12 +25,12 @@ suite('Context', () => { test('path resolution', async () => { // Correct/normal - assert.strictEqual(ctx.realpathSync('/'), '/'); - assert.strictEqual(ctx.realpathSync('example.txt'), '/example.txt'); - assert.strictEqual(ctx.realpathSync('../link'), '/example.txt'); - assert.strictEqual(await ctx.promises.realpath('/../link'), '/example.txt'); + assert.equal(ctx.realpathSync('/'), '/'); + assert.equal(ctx.realpathSync('example.txt'), '/example.txt'); + assert.equal(ctx.realpathSync('../link'), '/example.txt'); + assert.equal(await ctx.promises.realpath('/../link'), '/example.txt'); - assert.strictEqual(fs.realpathSync('/ctx/link'), '/example.txt'); + assert.equal(fs.realpathSync('/ctx/link'), '/example.txt'); }); test('break-out fails', () => { @@ -49,8 +49,8 @@ suite('Context', () => { } })(); await ctx.promises.writeFile('/xpto.txt', 'in real root'); - assert.strictEqual(lastFile!, 'xpto.txt'); + assert.equal(lastFile!, 'xpto.txt'); await ctx.promises.unlink('/xpto.txt'); - assert.strictEqual(lastFile, 'xpto.txt'); + assert.equal(lastFile, 'xpto.txt'); }); }); diff --git a/tests/common/devices.test.ts b/tests/common/devices.test.ts index e86fa351..a3e47cd1 100644 --- a/tests/common/devices.test.ts +++ b/tests/common/devices.test.ts @@ -1,5 +1,5 @@ import { suite, test } from 'node:test'; -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { configure } from '../../dist/config.js'; import * as fs from '../../dist/vfs/index.js'; import { S_IFCHR, S_IFMT } from '../../dist/vfs/constants.js'; diff --git a/tests/common/handle.test.ts b/tests/common/handle.test.ts index 1c099d68..e9aa792c 100644 --- a/tests/common/handle.test.ts +++ b/tests/common/handle.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { constants, type FileHandle, open } from '../../dist/vfs/promises.js'; diff --git a/tests/common/mounts.test.ts b/tests/common/mounts.test.ts index 7dd090ac..9da50033 100644 --- a/tests/common/mounts.test.ts +++ b/tests/common/mounts.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { configure } from '../../dist/config.js'; import * as fs from '../../dist/vfs/index.js'; @@ -12,8 +12,8 @@ suite('Mounts', () => { }, }); - assert.deepStrictEqual(fs.readdirSync('/'), ['nested']); - assert.deepStrictEqual(fs.readdirSync('/nested'), ['dir']); + assert.deepEqual(fs.readdirSync('/'), ['nested']); + assert.deepEqual(fs.readdirSync('/nested'), ['dir']); // cleanup fs.umount('/nested/dir'); diff --git a/tests/common/mutex.test.ts b/tests/common/mutex.test.ts index 3dcff863..00fdd192 100644 --- a/tests/common/mutex.test.ts +++ b/tests/common/mutex.test.ts @@ -3,7 +3,7 @@ import { Mutexed } from '../../dist/mixins/mutexed.js'; import { StoreFS } from '../../dist/backends/store/fs.js'; import { InMemoryStore } from '../../dist/backends/memory.js'; import { suite, test } from 'node:test'; -import assert from 'node:assert'; +import assert from 'node:assert/strict'; suite('LockFS mutex', () => { const fs = new (Mutexed(StoreFS))(new InMemoryStore('test')); @@ -57,6 +57,6 @@ suite('LockFS mutex', () => { } await Promise.all([foo(), foo(), foo()]); - assert.strictEqual(x, 4); + assert.equal(x, 4); }); }); diff --git a/tests/common/path.test.ts b/tests/common/path.test.ts index 87c54658..5ec3a7a6 100644 --- a/tests/common/path.test.ts +++ b/tests/common/path.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { basename, dirname, extname, join, normalize, resolve } from '../../dist/vfs/path.js'; diff --git a/tests/fs/append.test.ts b/tests/fs/append.test.ts index 5cc51798..93eb962b 100644 --- a/tests/fs/append.test.ts +++ b/tests/fs/append.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; diff --git a/tests/fs/dir.test.ts b/tests/fs/dir.test.ts index 5f1aac2d..dc6ba408 100644 --- a/tests/fs/dir.test.ts +++ b/tests/fs/dir.test.ts @@ -1,4 +1,4 @@ -import assert, { rejects } from 'node:assert'; +import assert, { rejects } from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs, type Dirent } from '../common.js'; @@ -68,7 +68,7 @@ suite('Dir', () => { assert(testFiles.includes(dirent2?.name)); const dirent3 = await dir.read(); - assert.strictEqual(dirent3, null); + assert.equal(dirent3, null); await dir.close(); }); @@ -85,7 +85,7 @@ suite('Dir', () => { assert(testFiles.includes(dirent2?.name)); const dirent3 = dir.readSync(); - assert.strictEqual(dirent3, null); + assert.equal(dirent3, null); dir.closeSync(); }); @@ -110,7 +110,7 @@ suite('Dir', () => { dirents.push(dirent); } - assert.strictEqual(dirents.length, 2); + assert.equal(dirents.length, 2); assert(dirents[0] instanceof fs.Dirent); assert(testFiles.includes(dirents[0].name)); assert(testFiles.includes(dirents[1].name)); diff --git a/tests/fs/directory.test.ts b/tests/fs/directory.test.ts index f2d2a388..c368474e 100644 --- a/tests/fs/directory.test.ts +++ b/tests/fs/directory.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { ErrnoError } from '../../dist/error.js'; import { fs } from '../common.js'; @@ -32,7 +32,7 @@ suite('Directories', () => { await fs.promises.mkdir('/nested/dir'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'ENOENT'); + assert.equal(error.code, 'ENOENT'); } assert(!(await fs.promises.exists('/nested/dir'))); }); @@ -66,7 +66,7 @@ suite('Directories', () => { fs.readdirSync('/two'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'EACCES'); + assert.equal(error.code, 'EACCES'); } }); @@ -78,7 +78,7 @@ suite('Directories', () => { await fs.promises.rmdir('/rmdirTest'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'ENOTEMPTY'); + assert.equal(error.code, 'ENOTEMPTY'); } }); @@ -90,7 +90,7 @@ suite('Directories', () => { } catch (error: any) { assert(error instanceof ErrnoError); wasThrown = true; - assert.strictEqual(error.code, 'ENOTDIR'); + assert.equal(error.code, 'ENOTDIR'); } assert(wasThrown); }); @@ -100,7 +100,7 @@ suite('Directories', () => { await fs.promises.readdir('a.js'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'ENOTDIR'); + assert.equal(error.code, 'ENOTDIR'); } }); @@ -112,7 +112,7 @@ suite('Directories', () => { } catch (error: any) { assert(error instanceof ErrnoError); wasThrown = true; - assert.strictEqual(error.code, 'ENOENT'); + assert.equal(error.code, 'ENOENT'); } assert(wasThrown); }); @@ -122,7 +122,7 @@ suite('Directories', () => { await fs.promises.readdir('/does/not/exist'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'ENOENT'); + assert.equal(error.code, 'ENOENT'); } }); diff --git a/tests/fs/errors.test.ts b/tests/fs/errors.test.ts index 596a4890..6f8f665f 100644 --- a/tests/fs/errors.test.ts +++ b/tests/fs/errors.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import test, { suite } from 'node:test'; import type { ErrnoError } from '../../dist/error.js'; import { fs } from '../common.js'; diff --git a/tests/fs/exists.test.ts b/tests/fs/exists.test.ts index ea1f0843..89107e52 100644 --- a/tests/fs/exists.test.ts +++ b/tests/fs/exists.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; diff --git a/tests/fs/links.test.ts b/tests/fs/links.test.ts index ccd187ec..d9a508bc 100644 --- a/tests/fs/links.test.ts +++ b/tests/fs/links.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { join } from '../../dist/vfs/path.js'; import { fs } from '../common.js'; @@ -20,7 +20,7 @@ suite('Links', () => { test('readlink', async () => { const destination = await fs.promises.readlink(symlink); - assert.strictEqual(destination, target); + assert.equal(destination, target); }); test('read target contents', async () => { @@ -43,7 +43,7 @@ suite('Links', () => { } const targetContent = await fs.promises.readFile(target, 'utf8'); const linkContent = await fs.promises.readFile(hardlink, 'utf8'); - assert.strictEqual(targetContent, linkContent); + assert.equal(targetContent, linkContent); }); test('file inside symlinked directory', async () => { @@ -52,6 +52,6 @@ suite('Links', () => { const link = join('link', target); assert((await fs.promises.realpath(link)) === target); const linkContent = await fs.promises.readFile(link, 'utf8'); - assert.strictEqual(targetContent, linkContent); + assert.equal(targetContent, linkContent); }); }); diff --git a/tests/fs/open.test.ts b/tests/fs/open.test.ts index cb9f1938..89299cc4 100644 --- a/tests/fs/open.test.ts +++ b/tests/fs/open.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { ErrnoError } from '../../dist/error.js'; import { fs } from '../common.js'; @@ -12,7 +12,7 @@ suite('fs file opening', () => { fs.openSync('/path/to/file/that/does/not/exist', 'r'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error?.code, 'ENOENT'); + assert.equal(error?.code, 'ENOENT'); caughtException = true; } assert(caughtException); @@ -23,7 +23,7 @@ suite('fs file opening', () => { await fs.promises.open('/path/to/file/that/does/not/exist', 'r'); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error?.code, 'ENOENT'); + assert.equal(error?.code, 'ENOENT'); } }); diff --git a/tests/fs/permissions.test.ts b/tests/fs/permissions.test.ts index 8ac2fe9f..05b075c2 100644 --- a/tests/fs/permissions.test.ts +++ b/tests/fs/permissions.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { credentials } from '../../dist/credentials.js'; import { R_OK, W_OK, X_OK } from '../../dist/vfs/constants.js'; @@ -50,7 +50,7 @@ suite('Permissions', () => { async function test_item(path: string): Promise { const stats = await fs.promises.stat(path).catch((error: ErrnoError) => { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'EACCES'); + assert.equal(error.code, 'EACCES'); }); if (!stats) { return; diff --git a/tests/fs/read.test.ts b/tests/fs/read.test.ts index 8326e444..f9fe3914 100644 --- a/tests/fs/read.test.ts +++ b/tests/fs/read.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; import { Buffer } from 'buffer'; @@ -27,12 +27,12 @@ suite('read', () => { suite('read binary', () => { test('Read a file and check its binary bytes (asynchronous)', async () => { const buff = await fs.promises.readFile('elipses.txt'); - assert.strictEqual((buff[1] << 8) | buff[0], 32994); + assert.equal((buff[1] << 8) | buff[0], 32994); }); test('Read a file and check its binary bytes (synchronous)', () => { const buff = fs.readFileSync('elipses.txt'); - assert.strictEqual((buff[1] << 8) | buff[0], 32994); + assert.equal((buff[1] << 8) | buff[0], 32994); }); }); @@ -44,16 +44,16 @@ suite('read buffer', () => { const handle = await fs.promises.open(filepath, 'r'); const { bytesRead } = await handle.read(bufferAsync, 0, expected.length, 0); - assert.strictEqual(bytesRead, expected.length); - assert.strictEqual(bufferAsync.toString(), expected); + assert.equal(bytesRead, expected.length); + assert.equal(bufferAsync.toString(), expected); }); test('read file synchronously', () => { const fd = fs.openSync(filepath, 'r'); const bytesRead = fs.readSync(fd, bufferSync, 0, expected.length, 0); - assert.strictEqual(bufferSync.toString(), expected); - assert.strictEqual(bytesRead, expected.length); + assert.equal(bufferSync.toString(), expected); + assert.equal(bytesRead, expected.length); }); test('read file synchronously to non-zero offset', () => { @@ -61,7 +61,7 @@ suite('read buffer', () => { const buffer = Buffer.alloc(expected.length + 10); const bytesRead = fs.readSync(fd, buffer, 10, expected.length, 0); - assert.strictEqual(buffer.subarray(10, buffer.length).toString(), expected); - assert.strictEqual(bytesRead, expected.length); + assert.equal(buffer.subarray(10, buffer.length).toString(), expected); + assert.equal(bytesRead, expected.length); }); }); diff --git a/tests/fs/readFile.test.ts b/tests/fs/readFile.test.ts index a88ea7d2..3dc98851 100644 --- a/tests/fs/readFile.test.ts +++ b/tests/fs/readFile.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; @@ -10,7 +10,7 @@ suite('Reading', () => { test('Reading past the end of a file should not be an error', async () => { const handle = await fs.promises.open('a.js', 'r'); const { bytesRead } = await handle.read(new Uint8Array(10), 0, 10, 10000); - assert.strictEqual(bytesRead, 0); + assert.equal(bytesRead, 0); }); }); @@ -46,7 +46,7 @@ suite('Read File Test', () => { test('read file with utf-8 encoding asynchronously', async () => { const data: string = await fs.promises.readFile(fn, 'utf8'); - assert.strictEqual(data, ''); + assert.equal(data, ''); }); test('read file synchronously', () => { @@ -56,7 +56,7 @@ suite('Read File Test', () => { test('read file with utf-8 encoding synchronously', () => { const data: string = fs.readFileSync(fn, 'utf8'); - assert.strictEqual(data, ''); + assert.equal(data, ''); }); }); @@ -65,9 +65,9 @@ suite('fs file reading', () => { const content = fs.readFileSync('elipses.txt', 'utf8'); for (let i = 0; i < content.length; i++) { - assert.strictEqual(content[i], '…'); + assert.equal(content[i], '…'); } - assert.strictEqual(content.length, 10000); + assert.equal(content.length, 10000); }); }); diff --git a/tests/fs/rename.test.ts b/tests/fs/rename.test.ts index 88d71903..fac568fc 100644 --- a/tests/fs/rename.test.ts +++ b/tests/fs/rename.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { ErrnoError } from '../../dist/error.js'; import { fs } from '../common.js'; @@ -21,10 +21,10 @@ suite('Rename', () => { */ async function check_directory(dir: string) { const contents = await fs.promises.readdir(dir); - assert.strictEqual(contents.length, 2); + assert.equal(contents.length, 2); const subContents = await fs.promises.readdir(dir + '/_rename_me'); - assert.strictEqual(subContents.length, 1); + assert.equal(subContents.length, 1); assert(await fs.promises.exists(dir + '/file.dat')); assert(await fs.promises.exists(dir + '/_rename_me/lol.txt')); @@ -91,7 +91,7 @@ suite('Rename', () => { await fs.promises.rename(renDir1, renDir2).catch((error: ErrnoError) => { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'EBUSY'); + assert.equal(error.code, 'EBUSY'); }); }); }); diff --git a/tests/fs/stat.test.ts b/tests/fs/stat.test.ts index 10211a17..f409aef3 100644 --- a/tests/fs/stat.test.ts +++ b/tests/fs/stat.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { credentials } from '../../dist/credentials.js'; import { Stats } from '../../dist/stats.js'; diff --git a/tests/fs/streams.test.ts b/tests/fs/streams.test.ts index 2e817394..4d1616f6 100644 --- a/tests/fs/streams.test.ts +++ b/tests/fs/streams.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; @@ -41,17 +41,17 @@ suite('ReadStream', () => { test('ReadStream declared properties', () => { const readStream = new fs.ReadStream(); - assert.strictEqual(readStream.bytesRead, undefined); - assert.strictEqual(readStream.path, undefined); - assert.strictEqual(readStream.pending, undefined); + assert.equal(readStream.bytesRead, undefined); + assert.equal(readStream.path, undefined); + assert.equal(readStream.pending, undefined); // Assign values readStream.bytesRead = 10; readStream.path = testFilePath; readStream.pending = false; - assert.strictEqual(readStream.bytesRead, 10); - assert.strictEqual(readStream.path, testFilePath); + assert.equal(readStream.bytesRead, 10); + assert.equal(readStream.path, testFilePath); assert(!readStream.pending); }); @@ -102,17 +102,17 @@ suite('WriteStream', () => { test('WriteStream declared properties', () => { const writeStream = new fs.WriteStream(); - assert.strictEqual(writeStream.bytesWritten, undefined); - assert.strictEqual(writeStream.path, undefined); - assert.strictEqual(writeStream.pending, undefined); + assert.equal(writeStream.bytesWritten, undefined); + assert.equal(writeStream.path, undefined); + assert.equal(writeStream.pending, undefined); // Assign values writeStream.bytesWritten = 20; writeStream.path = testFilePathWrite; writeStream.pending = true; - assert.strictEqual(writeStream.bytesWritten, 20); - assert.strictEqual(writeStream.path, testFilePathWrite); + assert.equal(writeStream.bytesWritten, 20); + assert.equal(writeStream.path, testFilePathWrite); assert(writeStream.pending); }); diff --git a/tests/fs/times.test.ts b/tests/fs/times.test.ts index 8ce557d9..35f4bde6 100644 --- a/tests/fs/times.test.ts +++ b/tests/fs/times.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { wait } from 'utilium'; import { ErrnoError } from '../../dist/error.js'; @@ -28,26 +28,26 @@ suite('times', () => { await fs.promises.utimes(path, atime, mtime); - assert.deepStrictEqual(unixTimestamps(await fs.promises.stat(path)), times); + assert.deepEqual(unixTimestamps(await fs.promises.stat(path)), times); await fs.promises.utimes('foobarbaz', atime, mtime).catch((error: ErrnoError) => { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'ENOENT'); + assert.equal(error.code, 'ENOENT'); }); await using handle = await fs.promises.open(path, 'r'); await handle.utimes(atime, mtime); - assert.deepStrictEqual(unixTimestamps(await handle.stat()), times); + assert.deepEqual(unixTimestamps(await handle.stat()), times); fs.utimesSync(path, atime, mtime); - assert.deepStrictEqual(unixTimestamps(fs.statSync(path)), times); + assert.deepEqual(unixTimestamps(fs.statSync(path)), times); try { fs.utimesSync('foobarbaz', atime, mtime); } catch (error: any) { assert(error instanceof ErrnoError); - assert.strictEqual(error.code, 'ENOENT'); + assert.equal(error.code, 'ENOENT'); } try { diff --git a/tests/fs/truncate.test.ts b/tests/fs/truncate.test.ts index a2180d8b..3d4ed2ef 100644 --- a/tests/fs/truncate.test.ts +++ b/tests/fs/truncate.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; import type { FileHandle } from '../../dist/vfs/promises.js'; diff --git a/tests/fs/watch.test.ts b/tests/fs/watch.test.ts index 5a3fa3e3..89704cc8 100644 --- a/tests/fs/watch.test.ts +++ b/tests/fs/watch.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs, type Stats } from '../common.js'; @@ -14,8 +14,8 @@ await fs.promises.writeFile(testFile, 'Initial content'); suite('Watch Features', () => { test('fs.watch should emit events on file change', async () => { using watcher = fs.watch(testFile, (eventType, filename) => { - assert.strictEqual(eventType, 'change'); - assert.strictEqual(filename, 'test.txt'); + assert.equal(eventType, 'change'); + assert.equal(filename, 'test.txt'); }); // Modify the file to trigger the event @@ -24,8 +24,8 @@ suite('Watch Features', () => { test('fs.watch should emit events on file rename (delete)', async () => { using watcher = fs.watch(testFile, (eventType, filename) => { - assert.strictEqual(eventType, 'rename'); - assert.strictEqual(filename, 'test.txt'); + assert.equal(eventType, 'rename'); + assert.equal(filename, 'test.txt'); }); // Delete the file to trigger the event @@ -63,8 +63,8 @@ suite('Watch Features', () => { test('fs.watch should work with directories', async () => { using watcher = fs.watch(testDir, (eventType, filename) => { - assert.strictEqual(eventType, 'change'); - assert.strictEqual(filename, 'newFile.txt'); + assert.equal(eventType, 'change'); + assert.equal(filename, 'newFile.txt'); }); await fs.promises.writeFile(`${testDir}/newFile.txt`, 'Content'); @@ -87,7 +87,7 @@ suite('Watch Features', () => { using watcher = fs.watch(testDir, (eventType, filename) => { const resolver = fileResolvers[filename]; assert.notEqual(resolver, undefined); // should have a resolver so file is expected - assert.strictEqual(eventType, resolver.eventType); + assert.equal(eventType, resolver.eventType); resolver.resolver.resolve(); }); @@ -102,8 +102,8 @@ suite('Watch Features', () => { await fs.promises.writeFile(tempFile, 'Temporary content'); using watcher = fs.watch(tempFile, (eventType, filename) => { - assert.strictEqual(eventType, 'rename'); - assert.strictEqual(filename, 'tempFile.txt'); + assert.equal(eventType, 'rename'); + assert.equal(filename, 'tempFile.txt'); }); await fs.promises.unlink(tempFile); diff --git a/tests/fs/write.test.ts b/tests/fs/write.test.ts index aa7b92c0..ae009804 100644 --- a/tests/fs/write.test.ts +++ b/tests/fs/write.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; const fn = 'write.txt'; @@ -9,11 +9,11 @@ suite('write', () => { const handle = await fs.promises.open(fn, 'w', 0o644); await handle.write('', 0, 'utf8'); const { bytesWritten } = await handle.write(expected, 0, 'utf8'); - assert.strictEqual(bytesWritten, Buffer.from(expected).length); + assert.equal(bytesWritten, Buffer.from(expected).length); await handle.close(); const data = await fs.promises.readFile(fn, 'utf8'); - assert.strictEqual(data, expected); + assert.equal(data, expected); await fs.promises.unlink(fn); }); @@ -25,7 +25,7 @@ suite('write', () => { const written = await handle.write(expected, 0, expected.length, null); - assert.strictEqual(expected.length, written.bytesWritten); + assert.equal(expected.length, written.bytesWritten); await handle.close(); @@ -38,16 +38,16 @@ suite('write', () => { const fd = fs.openSync(fn, 'w'); let written = fs.writeSync(fd, ''); - assert.strictEqual(written, 0); + assert.equal(written, 0); fs.writeSync(fd, 'foo'); const data = Buffer.from('bár'); written = fs.writeSync(fd, data, 0, data.length); - assert.strictEqual(written, 4); + assert.equal(written, 4); fs.closeSync(fd); - assert.strictEqual(fs.readFileSync(fn, 'utf8'), 'foobár'); + assert.equal(fs.readFileSync(fn, 'utf8'), 'foobár'); }); }); diff --git a/tests/fs/writeFile.test.ts b/tests/fs/writeFile.test.ts index ce6b4cf3..fb04da63 100644 --- a/tests/fs/writeFile.test.ts +++ b/tests/fs/writeFile.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { fs } from '../common.js'; @@ -10,7 +10,7 @@ suite('writeFile', () => { const filename = 'test.txt'; await fs.promises.writeFile(filename, s); const data = await fs.promises.readFile(filename); - assert.strictEqual(data.length, Buffer.from(s).length); + assert.equal(data.length, Buffer.from(s).length); await fs.promises.unlink(filename); }); @@ -20,7 +20,7 @@ suite('writeFile', () => { await fs.promises.writeFile(filename, expected); const actual = await fs.promises.readFile(filename); - assert.strictEqual(actual.length, expected.length); + assert.equal(actual.length, expected.length); await fs.promises.unlink(filename); }); @@ -35,7 +35,7 @@ suite('writeFile', () => { await fs.promises.writeFile(filePath, buffer); const read = await fs.promises.readFile(filePath, 'base64'); - assert.strictEqual(read, data); + assert.equal(read, data); }); }); @@ -47,7 +47,7 @@ suite('File Writing with Custom Mode', () => { fs.writeFileSync(file, '123', { mode }); const content = fs.readFileSync(file, 'utf8'); - assert.strictEqual(content, '123'); + assert.equal(content, '123'); assert((fs.statSync(file).mode & 0o777) === mode); fs.unlinkSync(file); @@ -60,7 +60,7 @@ suite('File Writing with Custom Mode', () => { fs.appendFileSync(file, 'abc', { mode }); const content = fs.readFileSync(file, { encoding: 'utf8' }); - assert.strictEqual(content, 'abc'); + assert.equal(content, 'abc'); assert((fs.statSync(file).mode & 0o777) === mode); diff --git a/tests/port/channel.test.ts b/tests/port/channel.test.ts index fe0c71e0..01a04d54 100644 --- a/tests/port/channel.test.ts +++ b/tests/port/channel.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { MessageChannel } from 'node:worker_threads'; import { Port, attachFS } from '../../dist/backends/port/fs.js'; diff --git a/tests/port/config.test.ts b/tests/port/config.test.ts index c778e982..d0ab5211 100644 --- a/tests/port/config.test.ts +++ b/tests/port/config.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { dirname } from 'node:path'; import { suite, test } from 'node:test'; import { fileURLToPath } from 'node:url'; diff --git a/tests/port/remote.test.ts b/tests/port/remote.test.ts index a6d5c6a7..42309d17 100644 --- a/tests/port/remote.test.ts +++ b/tests/port/remote.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { dirname } from 'node:path'; import { suite, test } from 'node:test'; import { fileURLToPath } from 'node:url'; diff --git a/tests/port/timeout.test.ts b/tests/port/timeout.test.ts index 165ff0bb..62900cdd 100644 --- a/tests/port/timeout.test.ts +++ b/tests/port/timeout.test.ts @@ -1,4 +1,4 @@ -import assert from 'node:assert'; +import assert from 'node:assert/strict'; import { suite, test } from 'node:test'; import { MessageChannel } from 'node:worker_threads'; import { Port } from '../../dist/backends/port/fs.js'; @@ -26,7 +26,7 @@ await suite('Timeout', { timeout: 1000 }, () => { error = e; } assert(error! instanceof ErrnoError); - assert.strictEqual(error.code, 'EIO'); + assert.equal(error.code, 'EIO'); assert(error.message.includes('RPC Failed')); }); @@ -40,7 +40,7 @@ await suite('Timeout', { timeout: 1000 }, () => { error = e; } assert(error! instanceof ErrnoError); - assert.strictEqual(error.code, 'EIO'); + assert.equal(error.code, 'EIO'); assert(error.message.includes('RPC Failed')); }); });