From f3c9b674c6a95e4d501ce5b1d4157a77a565585a Mon Sep 17 00:00:00 2001 From: James Prevett Date: Sun, 24 Nov 2024 14:55:24 -0600 Subject: [PATCH] Improve directory test assertions --- tests/fs/directory.test.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/fs/directory.test.ts b/tests/fs/directory.test.ts index e21bb655..6a94f730 100644 --- a/tests/fs/directory.test.ts +++ b/tests/fs/directory.test.ts @@ -40,27 +40,27 @@ suite('Directories', () => { }); test('mkdir, recursive', async () => { - assert((await fs.promises.mkdir('/recursiveP/A/B', { recursive: true, mode: 0o755 })) == '/recursiveP'); - assert((await fs.promises.mkdir('/recursiveP/A/B/C/D', { recursive: true, mode: 0o777 })) == '/recursiveP/A/B/C'); - assert((await fs.promises.mkdir('/recursiveP/A/B/C/D', { recursive: true, mode: 0o700 })) == undefined); + assert.equal(await fs.promises.mkdir('/recursiveP/A/B', { recursive: true, mode: 0o755 }), '/recursiveP'); + assert.equal(await fs.promises.mkdir('/recursiveP/A/B/C/D', { recursive: true, mode: 0o777 }), '/recursiveP/A/B/C'); + assert.equal(await fs.promises.mkdir('/recursiveP/A/B/C/D', { recursive: true, mode: 0o700 }), undefined); - assert((await fs.promises.stat('/recursiveP')).mode == (fs.constants.S_IFDIR | 0o755)); - assert((await fs.promises.stat('/recursiveP/A')).mode == (fs.constants.S_IFDIR | 0o755)); - assert((await fs.promises.stat('/recursiveP/A/B')).mode == (fs.constants.S_IFDIR | 0o755)); - assert((await fs.promises.stat('/recursiveP/A/B/C')).mode == (fs.constants.S_IFDIR | 0o777)); - assert((await fs.promises.stat('/recursiveP/A/B/C/D')).mode == (fs.constants.S_IFDIR | 0o777)); + assert.equal((await fs.promises.stat('/recursiveP')).mode, fs.constants.S_IFDIR | 0o755); + assert.equal((await fs.promises.stat('/recursiveP/A')).mode, fs.constants.S_IFDIR | 0o755); + assert.equal((await fs.promises.stat('/recursiveP/A/B')).mode, fs.constants.S_IFDIR | 0o755); + assert.equal((await fs.promises.stat('/recursiveP/A/B/C')).mode, fs.constants.S_IFDIR | 0o777); + assert.equal((await fs.promises.stat('/recursiveP/A/B/C/D')).mode, fs.constants.S_IFDIR | 0o777); }); test('mkdirSync, recursive', () => { - assert(fs.mkdirSync('/recursiveS/A/B', { recursive: true, mode: 0o755 }) === '/recursiveS'); - assert(fs.mkdirSync('/recursiveS/A/B/C/D', { recursive: true, mode: 0o777 }) === '/recursiveS/A/B/C'); - assert(fs.mkdirSync('/recursiveS/A/B/C/D', { recursive: true, mode: 0o700 }) === undefined); - - assert(fs.statSync('/recursiveS').mode == (fs.constants.S_IFDIR | 0o755)); - assert(fs.statSync('/recursiveS/A').mode == (fs.constants.S_IFDIR | 0o755)); - assert(fs.statSync('/recursiveS/A/B').mode == (fs.constants.S_IFDIR | 0o755)); - assert(fs.statSync('/recursiveS/A/B/C').mode == (fs.constants.S_IFDIR | 0o777)); - assert(fs.statSync('/recursiveS/A/B/C/D').mode == (fs.constants.S_IFDIR | 0o777)); + assert.equal(fs.mkdirSync('/recursiveS/A/B', { recursive: true, mode: 0o755 }), '/recursiveS'); + assert.equal(fs.mkdirSync('/recursiveS/A/B/C/D', { recursive: true, mode: 0o777 }), '/recursiveS/A/B/C'); + assert.equal(fs.mkdirSync('/recursiveS/A/B/C/D', { recursive: true, mode: 0o700 }), undefined); + + assert.equal(fs.statSync('/recursiveS').mode, fs.constants.S_IFDIR | 0o755); + assert.equal(fs.statSync('/recursiveS/A').mode, fs.constants.S_IFDIR | 0o755); + assert.equal(fs.statSync('/recursiveS/A/B').mode, fs.constants.S_IFDIR | 0o755); + assert.equal(fs.statSync('/recursiveS/A/B/C').mode, fs.constants.S_IFDIR | 0o777); + assert.equal(fs.statSync('/recursiveS/A/B/C/D').mode, fs.constants.S_IFDIR | 0o777); }); test('readdirSync without permission', () => {