Skip to content

Commit

Permalink
tests to .ts, formatting, test infra
Browse files Browse the repository at this point in the history
  • Loading branch information
anibalsolon committed Dec 20, 2021
1 parent 338116a commit 165dd34
Show file tree
Hide file tree
Showing 33 changed files with 12,024 additions and 11,835 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"plugin:@typescript-eslint/recommended"
],
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }]
"indent": ["error", 2, { "SwitchCase": 1 }],
"semi": [2, "always"]
},
"ignorePatterns": ["dist"]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
dist
/data
.nyc_output
.test_output
coverage
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "./test/unit/**/*.test.js",
"spec": "./test/unit/**/*.test.ts",
"recursive": true,
"require": ["ts-node/register"]
}
7 changes: 2 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
"recommendations": [
]
}
76 changes: 39 additions & 37 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"${workspaceFolder}/data",
"--extensionDevelopmentPath=${workspaceFolder}"
]
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/test/suite/index"
]
},
{
"name": "Unit Tests",
"type": "pwa-node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"sourceMaps": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
],
},
]
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"${workspaceFolder}/data",
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extensions"
]
},
{
"name": "Run Extension Tests",
"type": "pwa-node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"test:vscode",
],
"skipFiles": [
"<node_internals>/**"
]
},
{
"name": "Unit Tests",
"type": "pwa-node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"test:unittests",
],
"skipFiles": [
"<node_internals>/**"
]
},
]
}
5 changes: 3 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
test/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/jsconfig.json
**/*.map
**/.eslintrc.json
Expand All @@ -13,4 +12,6 @@ tsconfig.json
data
extension
webview
*.ipynb
*.ipynb
.nyc_output
.test_output
2 changes: 1 addition & 1 deletion extension/formats/nifti/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export abstract class Nifti {
intercept: scalingIntercept,
},
}
}
};

if (min === max && min === 0) {
const values = await this.values();
Expand Down
8 changes: 4 additions & 4 deletions extension/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function isGzipped(fd: number): boolean {
const view = new DataView(buffer);
const bytes = fs.readSync(fd, view, 0, 2, 0);
if (bytes < 2){
throw new Error("Invalid file: empty")
throw new Error("Invalid file: empty");
}
return (
view.getUint8(0) === GZIP_MAGIC_COOKIE[0] &&
Expand Down Expand Up @@ -88,7 +88,7 @@ export class Slicer extends Transform {
}
if (this._offset_end !== null && this._passedThrough >= this._offset_end) {
callback();
return
return;
}
const begin = this._passedThrough > this._offset ? 0 : this._offset - this._passedThrough;
let end = undefined;
Expand Down Expand Up @@ -181,8 +181,8 @@ export class Bufferizer extends Transform {
}

_transform(chunk: number[], encoding: string, callback: TransformCallback) {
// const rounded: number[] = chunk.map((v) => Math.round(v));
this.push(Buffer.from(Int16Array.from(chunk).buffer));
const int16Array = Int16Array.from(chunk);
this.push(Buffer.from(int16Array.buffer));
callback();
}
}
Expand Down
22 changes: 11 additions & 11 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"checkJs": true, /* Typecheck .js files. */
"lib": [
"es6"
]
},
"exclude": [
"node_modules"
]
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"checkJs": true,
"lib": [
"es6"
]
},
"exclude": [
"node_modules"
]
}
Loading

0 comments on commit 165dd34

Please sign in to comment.