Skip to content

Commit

Permalink
fix test node script
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmywarting committed Aug 30, 2021
1 parent d0400df commit 8a5393c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"test": "exit 0",
"test:browser": "airtap --local test/browser.js",
"test:server": "node test/server-side.js",
"test:memory": "node test/memory.js",
"test:node": "node test/test-node.js",
"test:deno": "node test/test-deno.js",
"build": "rm -rf dist && rollup -c rollup.config.js"
},
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion src/FileSystemHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ class FileSystemHandle {
*/
async isSameEntry (other) {
if (this === other) return true
if (this.kind !== other.kind) return false
if (
(!other) ||
(typeof other !== 'object') ||
(this.kind !== other.kind) ||
(!other[kAdapter])
) return false
return this[kAdapter].isSameEntry(other[kAdapter])
}
}
Expand Down
29 changes: 21 additions & 8 deletions test/test-node.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import * as fs from '../src/es6.js'
import { existsSync, mkdirSync, rmdirSync } from 'node:fs'
import { getOriginPrivateDirectory } from '../src/es6.js'
import steps from './test.js'
import {
cleanupSandboxedFileSystem
} from '../test/util.js'
import { cleanupSandboxedFileSystem } from '../test/util.js'

const { getOriginPrivateDirectory } = fs
let hasFailures = false

async function test(fs, step, root) {
try {
await cleanupSandboxedFileSystem(root)
await step.fn(root)
console.log(`[OK]: ${fs} ${step.desc}`)
} catch (err) {
console.log(`[ERR]: ${fs} ${step.desc}`)
console.log(`[ERR]: ${fs} ${step.desc}\n\t-> ${err.message}`)
hasFailures = true
}
}

async function start () {
const testFolderPath = './testfolder'
if (!existsSync(testFolderPath)) {
mkdirSync(testFolderPath)
}
const root = await getOriginPrivateDirectory(import('../src/adapters/node.js'), './testfolder')
const memory = await getOriginPrivateDirectory(import('../src/adapters/memory.js'))

Expand All @@ -25,12 +29,21 @@ async function start () {
await test('server', step, root).finally()
}

rmdirSync(testFolderPath)

console.log('\n\n\n')
setTimeout(()=>{}, 222222)

for (let step of steps) {
await test('memory', step, memory).finally()
}

if (hasFailures) {
console.log(`\n\nSome tests failed. See output above.`)
process.exit(1)
}
}

start()
start().catch(e => {
console.error(e);
process.exit(1)
})

0 comments on commit 8a5393c

Please sign in to comment.