Skip to content

Commit

Permalink
Modify tests, appears to be more reflective of reality
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 11, 2024
1 parent 7e913f6 commit ba54454
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 25 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
"clean": "rimraf dist esm",
"prebuild": "yarn clean",
"build:esm": "tsc --target es2018 --outDir esm",
"build:es5": "tsc --target es2015 --module commonjs --outDir dist",
"build:esm": "tsc --outDir esm",
"build:es5": "tsc --module commonjs --outDir dist",
"build": "yarn build:esm && yarn build:es5",
"prepublishOnly": "yarn test --run && yarn build",
"postversion": "git push --follow-tags"
Expand Down Expand Up @@ -53,7 +53,7 @@
"eslint-plugin-unicorn": "^56.0.1",
"prettier": "^3.4.1",
"rimraf": "^6.0.1",
"typescript": "~5.6.0",
"typescript": "^5.8.0",
"typescript-eslint": "^8.1.0",
"vitest": "^2.1.6"
},
Expand Down
7 changes: 3 additions & 4 deletions src/bgzFilehandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class BgzFilehandle {
length,
position,
)
const block = [] as Uint8Array[]
const blocks = [] as Uint8Array[]
for (
let blockNum = 0;
blockNum < blockPositions.length - 1;
Expand All @@ -107,11 +107,10 @@ export default class BgzFilehandle {
uncompressedPosition + uncompressedBuffer.length,
) - uncompressedPosition
if (sourceOffset >= 0 && sourceOffset < uncompressedBuffer.length) {
// uncompressedBuffer.copy(buf, destinationOffset, sourceOffset, sourceEnd)
block.push(uncompressedBuffer.subarray(sourceOffset, sourceEnd))
blocks.push(uncompressedBuffer.subarray(sourceOffset, sourceEnd))
}
}

return concatUint8Array(block)
return concatUint8Array(blocks)
}
}
2 changes: 1 addition & 1 deletion src/unzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function unzip(inputData: Uint8Array) {
result.set(chunks[i]!, offset)
offset += chunks[i]!.length
}
return Buffer.from(result)
return result
} catch (e) {
//cleanup error message
if (/incorrect header check/.exec(`${e}`)) {
Expand Down
32 changes: 20 additions & 12 deletions test/indexedfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ async function testRead(basename: string, length: number, position: number) {
expect(buf.length).toEqual(buf2.length)
expect(Array.from(buf)).toEqual(Array.from(buf2))

// const directStat = fs.fstatSync(fd)
// const myStat = await f.stat()
// expect(myStat.size).toEqual(directStat.size)
const directStat = fs.fstatSync(fd)
const myStat = await f.stat()
expect(myStat.size).toEqual(directStat.size)
}

test('can read gff3_with_syncs.gff3.gz 1', async () => {
Expand All @@ -34,12 +34,20 @@ test('can read gff3_with_syncs.gff3.gz 4', async () => {
await testRead('gff3_with_syncs.gff3', 2500, 0)
})
test('can read gff3_with_syncs.gff3.gz 5', async () => {
await testRead('gff3_with_syncs.gff3', 3000, 1)
})
// test('can read T_ko.2bit', async () => {
// await testRead('T_ko.2bit', 10, 0)
// await testRead('T_ko.2bit', 10000, 20000)
// await testRead('T_ko.2bit', 10000, 1)
// await testRead('T_ko.2bit', 10, 0)
// await testRead('T_ko.2bit', 10, 1000000)
// })
await testRead('gff3_with_syncs.gff3', 2545, 1)
})
test('can read T_ko.2bit 1', async () => {
await testRead('T_ko.2bit', 10, 0)
})
test('can read T_ko.2bit 2', async () => {
await testRead('T_ko.2bit', 10000, 20000)
})
test('can read T_ko.2bit 3', async () => {
await testRead('T_ko.2bit', 10000, 1)
})
test('can read T_ko.2bit 4', async () => {
await testRead('T_ko.2bit', 10, 0)
})
test('can read T_ko.2bit 5', async () => {
await testRead('T_ko.2bit', 0, 1000000)
})
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["src"],
"compilerOptions": {
"target": "es2015",
"target": "es2020",
"types": ["node"],
"outDir": "esm",
"declaration": true,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2741,10 +2741,10 @@ typescript-eslint@^8.1.0:
"@typescript-eslint/parser" "8.16.0"
"@typescript-eslint/utils" "8.16.0"

typescript@~5.6.0:
version "5.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b"
integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==
typescript@^5.8.0:
version "5.8.0-dev.20241211"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.0-dev.20241211.tgz#f6485c7f5f3c2779d1672785f561c3e14342498f"
integrity sha512-0Y3jLj2YHE2oulcW2viCZKxvWZpHMqnwuw9umTFCRA1/BNs2bkmh1pDH50lqh+4yQa7ukGLJfV22Bva7nOvm+w==

unbox-primitive@^1.0.2:
version "1.0.2"
Expand Down

0 comments on commit ba54454

Please sign in to comment.