From e5c8def4dbd7adc17812c7680fc5dc7be2354101 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 9 Jun 2024 15:33:41 -0400 Subject: [PATCH] feat(test): Add test to ensure that FileTrees use POSIX paths --- bids-validator/src/files/deno.test.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bids-validator/src/files/deno.test.ts b/bids-validator/src/files/deno.test.ts index 73ef18d89..1952553dd 100644 --- a/bids-validator/src/files/deno.test.ts +++ b/bids-validator/src/files/deno.test.ts @@ -1,8 +1,8 @@ -import { assertEquals, assertRejects } from '../deps/asserts.ts' +import { assert, assertEquals, assertRejects } from '../deps/asserts.ts' import { readAll, readerFromStreamReader } from '../deps/stream.ts' import { dirname, basename, join, fromFileUrl } from '../deps/path.ts' import { EOL } from '../deps/fs.ts' -import { BIDSFileDeno, UnicodeDecodeError } from './deno.ts' +import { BIDSFileDeno, readFileTree, UnicodeDecodeError } from './deno.ts' import { requestReadPermission } from '../setup/requestPermissions.ts' import { FileIgnoreRules } from './ignore.ts' @@ -60,3 +60,18 @@ Deno.test('Deno implementation of BIDSFile', async (t) => { }, ) }) + +Deno.test('Deno implementation of FileTree', async (t) => { + const srcdir = dirname(testDir) + const parent = basename(testDir) + const tree = await readFileTree(srcdir) + await t.step('uses POSIX relative paths', async () => { + assertEquals(tree.path, '/') + const parentObj = tree.directories.find((dir) => dir.name === parent) + assert(parentObj !== undefined) + assertEquals(parentObj.path, `/${parent}`) + const testObj = parentObj.files.find((file) => file.name === testFilename) + assert(testObj !== undefined) + assertEquals(testObj.path, `/${parent}/${testFilename}`) + }) +})