Skip to content

Commit

Permalink
feat(test): Add test to ensure that FileTrees use POSIX paths
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jun 10, 2024
1 parent 6e8ac48 commit e5c8def
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bids-validator/src/files/deno.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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}`)
})
})

0 comments on commit e5c8def

Please sign in to comment.