Update deps and tests
This commit is contained in:
parent
5af58c65d3
commit
8a2c0187b2
|
@ -0,0 +1,21 @@
|
||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node_version: 14.16.0
|
||||||
|
- run: cd test
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run test-ci
|
|
@ -8,4 +8,5 @@
|
||||||
.eslintrc
|
.eslintrc
|
||||||
node_modules/
|
node_modules/
|
||||||
test/build/
|
test/build/
|
||||||
|
doc/jest/
|
||||||
*.log
|
*.log
|
||||||
|
|
82
README.md
82
README.md
|
@ -3,11 +3,11 @@
|
||||||
This is a part of [Node3D](https://github.com/node-3d) project.
|
This is a part of [Node3D](https://github.com/node-3d) project.
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/addon-tools-raub)
|
[](https://www.npmjs.com/package/addon-tools-raub)
|
||||||
|
|
||||||
[](https://travis-ci.com/node-3d/addon-tools-raub)
|
|
||||||
[](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub)
|
[](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub)
|
||||||
|
|
||||||
> npm i addon-tools-raub
|
```
|
||||||
|
npm i addon-tools-raub
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
@ -33,23 +33,41 @@ additional snippets follow the links below.
|
||||||
## index.js
|
## index.js
|
||||||
|
|
||||||
Main exports for cross-platform addon configuration.
|
Main exports for cross-platform addon configuration.
|
||||||
* `paths(dir)` - function. Returns a set of platform dependent paths depending on
|
|
||||||
|
```
|
||||||
|
export const paths: (dir: string) => Readonly<{
|
||||||
|
bin: string;
|
||||||
|
include: string;
|
||||||
|
}>;
|
||||||
|
export const bin: string;
|
||||||
|
export const platform: string;
|
||||||
|
export const include: string;
|
||||||
|
```
|
||||||
|
|
||||||
|
* `paths` - Returns a set of platform dependent paths depending on
|
||||||
input `dir`.
|
input `dir`.
|
||||||
* `bin` - platform binary directory absolute path.
|
* `bin` - platform binary directory absolute path.
|
||||||
* `include` - include directory for this `dir`.
|
* `include` - include directory for this `dir`.
|
||||||
* `include` - both `'addon-tools-raub'` and `'node-addon-api'` include paths.
|
|
||||||
Use with `node -p` through list context command expansion `<!@(...)`.
|
|
||||||
* `bin` - platform-dependent binary directory name.
|
* `bin` - platform-dependent binary directory name.
|
||||||
* `platform` - platform name: `'windows', 'linux', 'osx'`.
|
* `platform` - platform name: `'windows', 'linux', 'osx'`.
|
||||||
|
* `include` - both `'addon-tools-raub'` and `'node-addon-api'` include paths.
|
||||||
|
Use with `node -p` through list context command expansion `<!@(...)`.
|
||||||
|
|
||||||
|
|
||||||
## download.js
|
## download.js
|
||||||
|
|
||||||
Downloads a file into the memory, **HTTP** or **HTTPS**.
|
Downloads a file into the memory, **HTTP** or **HTTPS**.
|
||||||
`async WritableBuffer download(string url)` - accepts an **URL**, and
|
|
||||||
returns an in-memory buffer, when file is loaded.
|
|
||||||
|
|
||||||
Example use:
|
```
|
||||||
|
declare const download: (url: string) => Promise<Buffer>;
|
||||||
|
export default download;
|
||||||
|
```
|
||||||
|
|
||||||
|
Accepts an **URL**, and returns an in-memory file Buffer,
|
||||||
|
when the file is loaded. Use for small files, as the whole
|
||||||
|
file will be loaded into memory at once.
|
||||||
|
|
||||||
|
Example:
|
||||||
```
|
```
|
||||||
download(srcUrl).then(
|
download(srcUrl).then(
|
||||||
data => useData(data),
|
data => useData(data),
|
||||||
|
@ -63,7 +81,13 @@ useData(data);
|
||||||
|
|
||||||
## cpbin.js
|
## cpbin.js
|
||||||
|
|
||||||
Copies the addon binary from **src/build/Release** to the platform folder.
|
Copies the addon binary from `src/build/Release` to the platform folder.
|
||||||
|
|
||||||
|
```
|
||||||
|
declare const cpbin: (name: string) => Promise<void>;
|
||||||
|
export default cpbin;
|
||||||
|
```
|
||||||
|
|
||||||
It is useful for development builds. Use it in your **src/package.json**:
|
It is useful for development builds. Use it in your **src/package.json**:
|
||||||
```
|
```
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -76,6 +100,12 @@ Here ADDON should be replaced with the name of your addon, without `.node` exten
|
||||||
## install.js
|
## install.js
|
||||||
|
|
||||||
Downloads and unzips the platform specific binary for the calling package.
|
Downloads and unzips the platform specific binary for the calling package.
|
||||||
|
|
||||||
|
```
|
||||||
|
declare const install: (folder: string) => void;
|
||||||
|
export default install;
|
||||||
|
```
|
||||||
|
|
||||||
To use it, create a new script for your package, which may as well be named
|
To use it, create a new script for your package, which may as well be named
|
||||||
**install.js**, with the following content:
|
**install.js**, with the following content:
|
||||||
|
|
||||||
|
@ -110,6 +140,14 @@ stream buffer, that is stored in-memory and can be fully
|
||||||
obtained when writing was finished. It is equivalent to stream-writing
|
obtained when writing was finished. It is equivalent to stream-writing
|
||||||
a temporary file and then reading it into a `Buffer`.
|
a temporary file and then reading it into a `Buffer`.
|
||||||
|
|
||||||
|
```
|
||||||
|
import type { Writable } from 'stream';
|
||||||
|
export class WritableBuffer extends Writable {
|
||||||
|
constructor();
|
||||||
|
get(): Buffer;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
Use `stream.get()` to obtain the data when writing was finished:
|
Use `stream.get()` to obtain the data when writing was finished:
|
||||||
```
|
```
|
||||||
const stream = new WritableBuffer();
|
const stream = new WritableBuffer();
|
||||||
|
@ -121,6 +159,30 @@ sourceStream.on('end', () => useData(stream.get()));
|
||||||
|
|
||||||
## utils.js
|
## utils.js
|
||||||
|
|
||||||
|
Async `fs` based helpers for common addon-related file operations.
|
||||||
|
|
||||||
|
```
|
||||||
|
import type { Stats } from 'fs';
|
||||||
|
export const read: (name: string) => Promise<string>;
|
||||||
|
export const write: (name: string, text: string) => Promise<void>;
|
||||||
|
export const copy: (src: string, dest: string) => Promise<void>;
|
||||||
|
export const exists: (name: string) => Promise<boolean>;
|
||||||
|
export const mkdir: (name: string) => Promise<void>;
|
||||||
|
export const stat: (name: string) => Promise<Stats>;
|
||||||
|
export const isDir: (name: string) => Promise<boolean>;
|
||||||
|
export const isFile: (name: string) => Promise<boolean>;
|
||||||
|
export const dirUp: (dir: string) => string;
|
||||||
|
export const ensuredir: (dir: string) => Promise<void>;
|
||||||
|
export const copysafe: (src: string, dest: string) => Promise<void>;
|
||||||
|
export const readdir: (src: string, dest: string) => Promise<ReadonlyArray<string>>;
|
||||||
|
export const subdirs: (name: string) => Promise<ReadonlyArray<string>>;
|
||||||
|
export const subfiles: (name: string) => Promise<ReadonlyArray<string>>;
|
||||||
|
export const traverse: (name: string, showDirs?: boolean) => Promise<ReadonlyArray<string>>;
|
||||||
|
export const copyall: (src: string, dest: string) => Promise<void>;
|
||||||
|
export const rmdir: (name: string) => Promise<void>;
|
||||||
|
export const rm: (name: string) => Promise<void>;
|
||||||
|
```
|
||||||
|
|
||||||
* `read` - (async) Reads a whole file to string, NOT A Buffer.
|
* `read` - (async) Reads a whole file to string, NOT A Buffer.
|
||||||
* `write` - (async) Write a file.
|
* `write` - (async) Write a file.
|
||||||
* `copy` - (async) Copy a file.
|
* `copy` - (async) Copy a file.
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
declare const cpbin: (name: string) => Promise<void>;
|
||||||
|
export default cpbin;
|
2
cpbin.js
2
cpbin.js
|
@ -5,7 +5,6 @@ const { bin } = require('.');
|
||||||
|
|
||||||
|
|
||||||
module.exports = async name => {
|
module.exports = async name => {
|
||||||
|
|
||||||
const srcDir = process.cwd().replace(/\\/g, '/');
|
const srcDir = process.cwd().replace(/\\/g, '/');
|
||||||
|
|
||||||
if (!await exists(`${srcDir}/build/Release/${name}.node`) ) {
|
if (!await exists(`${srcDir}/build/Release/${name}.node`) ) {
|
||||||
|
@ -27,5 +26,4 @@ module.exports = async name => {
|
||||||
await copy(`${srcDir}/build/Release/${name}.node`, destAbs);
|
await copy(`${srcDir}/build/Release/${name}.node`, destAbs);
|
||||||
|
|
||||||
console.log(`The binary "${name}.node" was copied to "${bin}".`);
|
console.log(`The binary "${name}.node" was copied to "${bin}".`);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
declare const download: (url: string) => Promise<Buffer>;
|
||||||
|
export default download;
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const paths: (dir: string) => Readonly<{
|
||||||
|
bin: string;
|
||||||
|
include: string;
|
||||||
|
}>;
|
||||||
|
export const bin: string;
|
||||||
|
export const platform: string;
|
||||||
|
export const include: string;
|
10
index.js
10
index.js
|
@ -1,5 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const napi = require('node-addon-api');
|
||||||
|
|
||||||
|
|
||||||
const platformNames = {
|
const platformNames = {
|
||||||
win32 : 'windows',
|
win32 : 'windows',
|
||||||
linux : 'linux',
|
linux : 'linux',
|
||||||
|
@ -16,13 +19,12 @@ if ( ! platformName ) {
|
||||||
const rootPath = __dirname.replace(/\\/g, '/');
|
const rootPath = __dirname.replace(/\\/g, '/');
|
||||||
|
|
||||||
|
|
||||||
const napiInclude = require('node-addon-api').include.replace(/\\/g, '/');
|
const napiInclude = napi.include.replace(/\\/g, '/');
|
||||||
const thisInclude = `${rootPath}/include`;
|
const thisInclude = `${rootPath}/include`;
|
||||||
const includePath = `${napiInclude} ${thisInclude}`;
|
const includePath = `${napiInclude} ${thisInclude}`;
|
||||||
|
|
||||||
|
|
||||||
const paths = dir => {
|
const paths = dir => {
|
||||||
|
|
||||||
dir = dir.replace(/\\/g, '/');
|
dir = dir.replace(/\\/g, '/');
|
||||||
|
|
||||||
const bin = `${dir}/bin-${platformName}`;
|
const bin = `${dir}/bin-${platformName}`;
|
||||||
|
@ -33,16 +35,12 @@ const paths = dir => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return { bin, include };
|
return { bin, include };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
paths,
|
paths,
|
||||||
|
|
||||||
bin : `bin-${platformName}`,
|
bin : `bin-${platformName}`,
|
||||||
platform : platformName,
|
platform : platformName,
|
||||||
include : includePath,
|
include : includePath,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
declare const install: (folder: string) => void;
|
||||||
|
export default install;
|
|
@ -1,18 +1,18 @@
|
||||||
{
|
{
|
||||||
"name": "addon-tools-raub",
|
"name": "addon-tools-raub",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"adm-zip": {
|
"adm-zip": {
|
||||||
"version": "0.4.16",
|
"version": "0.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz",
|
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.4.tgz",
|
||||||
"integrity": "sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg=="
|
"integrity": "sha512-GMQg1a1cAegh+/EgWbz+XHZrwB467iB/IgtToldvxs7Xa5Br8mPmvCeRfY/Un2fLzrlIPt6Yu7Cej+8Ut9TGPg=="
|
||||||
},
|
},
|
||||||
"node-addon-api": {
|
"node-addon-api": {
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz",
|
||||||
"integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg=="
|
"integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
package.json
18
package.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"author": "Luis Blanco <luisblanco1337@gmail.com>",
|
"author": "Luis Blanco <luisblanco1337@gmail.com>",
|
||||||
"name": "addon-tools-raub",
|
"name": "addon-tools-raub",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"description": "Helpers for Node.js addons and dependency packages",
|
"description": "Helpers for Node.js addons and dependency packages",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
@ -19,26 +19,32 @@
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"include",
|
"include",
|
||||||
"download.js",
|
|
||||||
"cpbin.js",
|
"cpbin.js",
|
||||||
|
"cpbin.d.ts",
|
||||||
|
"download.js",
|
||||||
|
"download.d.ts",
|
||||||
"index.js",
|
"index.js",
|
||||||
|
"index.d.ts",
|
||||||
"install.js",
|
"install.js",
|
||||||
|
"install.d.ts",
|
||||||
"utils.js",
|
"utils.js",
|
||||||
|
"utils.d.ts",
|
||||||
"writable-buffer.js",
|
"writable-buffer.js",
|
||||||
|
"writable-buffer.d.ts",
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
"package.json",
|
"package.json",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.13.0",
|
"node": ">=14.16.0",
|
||||||
"npm": ">=6.12.0"
|
"npm": ">=6.14.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/node-3d/addon-tools-raub.git"
|
"url": "https://github.com/node-3d/addon-tools-raub.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"adm-zip": "0.4.16",
|
"adm-zip": "0.5.4",
|
||||||
"node-addon-api": "3.0.0"
|
"node-addon-api": "3.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const arrayArgMsg = 'Argument 0 must be of type `Array`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_ARRAY_ARG', () => {
|
||||||
|
it('exports reqArrayArg', () => {
|
||||||
|
expect(typeof test.reqArrayArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqArrayArg()).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqArrayArg(undefined)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqArrayArg(null)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqArrayArg('1')).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.reqArrayArg(1)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqArrayArg(true)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a pointer', () => {
|
||||||
|
expect(() => test.reqArrayArg(test.retExt())).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqArrayArg({})).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an array', () => {
|
||||||
|
expect(Array.isArray(test.reqArrayArg([]))).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_ARRAY_ARG', () => {
|
||||||
|
it('exports letArrayArg', () => {
|
||||||
|
expect(typeof test.letArrayArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letArrayArg('1')).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.letArrayArg(1)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letArrayArg(true)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a pointer', () => {
|
||||||
|
expect(() => test.letArrayArg(test.retExt())).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letArrayArg({})).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(Array.isArray(test.letArrayArg())).toBe(true);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(Array.isArray(test.letArrayArg(undefined))).toBe(true);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(Array.isArray(test.letArrayArg(null))).toBe(true);
|
||||||
|
});
|
||||||
|
it('accepts an array', () => {
|
||||||
|
expect(Array.isArray(test.letArrayArg([]))).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_ARRAY_ARG', () => {
|
||||||
|
it('exports useArrayArg', () => {
|
||||||
|
expect(typeof test.useArrayArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useArrayArg('1')).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.useArrayArg(1)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useArrayArg(true)).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a pointer', () => {
|
||||||
|
expect(() => test.useArrayArg(test.retExt())).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useArrayArg({})).toThrow(arrayArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(Array.isArray(test.useArrayArg())).toBe(true);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(Array.isArray(test.useArrayArg(undefined))).toBe(true);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(Array.isArray(test.useArrayArg(null))).toBe(true);
|
||||||
|
});
|
||||||
|
it('accepts an array', () => {
|
||||||
|
expect(Array.isArray(test.useArrayArg([]))).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const boolArgMsg = 'Argument 0 must be of type `Bool`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_BOOL_ARG', () => {
|
||||||
|
it('exports reqBoolArg', () => {
|
||||||
|
expect(typeof test.reqBoolArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqBoolArg()).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqBoolArg(undefined)).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqBoolArg(null)).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqBoolArg('1')).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.reqBoolArg(1)).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqBoolArg({})).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqBoolArg([])).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a boolean', () => {
|
||||||
|
expect(test.reqBoolArg(true)).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_BOOL_ARG', () => {
|
||||||
|
it('exports letBoolArg', () => {
|
||||||
|
expect(typeof test.letBoolArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letBoolArg('1')).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.letBoolArg(1)).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letBoolArg({})).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letBoolArg([])).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letBoolArg()).toEqual(false);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letBoolArg(undefined)).toEqual(false);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letBoolArg(null)).toEqual(false);
|
||||||
|
});
|
||||||
|
it('accepts a boolean', () => {
|
||||||
|
expect(test.letBoolArg(true)).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_BOOL_ARG', () => {
|
||||||
|
it('exports useBoolArg', () => {
|
||||||
|
expect(typeof test.useBoolArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useBoolArg('1')).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.useBoolArg(1)).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useBoolArg({})).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useBoolArg([])).toThrow(boolArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useBoolArg()).toEqual(true);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useBoolArg(undefined)).toEqual(true);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useBoolArg(null)).toEqual(true);
|
||||||
|
});
|
||||||
|
it('accepts a boolean', () => {
|
||||||
|
expect(test.useBoolArg(true)).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const numArgMsg = 'Argument 0 must be of type `Number`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_DOUBLE_ARG', () => {
|
||||||
|
it('exports reqDoubleArg', () => {
|
||||||
|
expect(typeof test.reqDoubleArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqDoubleArg()).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqDoubleArg(undefined)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqDoubleArg(null)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqDoubleArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqDoubleArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqDoubleArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqDoubleArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.reqDoubleArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_DOUBLE_ARG', () => {
|
||||||
|
it('exports letDoubleArg', () => {
|
||||||
|
expect(typeof test.letDoubleArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letDoubleArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letDoubleArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letDoubleArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letDoubleArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letDoubleArg()).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letDoubleArg(undefined)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letDoubleArg(null)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.letDoubleArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_DOUBLE_ARG', () => {
|
||||||
|
it('exports useDoubleArg', () => {
|
||||||
|
expect(typeof test.useDoubleArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useDoubleArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useDoubleArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useDoubleArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useDoubleArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useDoubleArg()).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useDoubleArg(undefined)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useDoubleArg(null)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.useDoubleArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,105 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const extArgMsg = 'Argument 0 must be of type `Pointer`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_EXT_ARG', () => {
|
||||||
|
it('exports reqExtArg', () => {
|
||||||
|
expect(typeof test.reqExtArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqExtArg()).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqExtArg(undefined)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqExtArg(null)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqExtArg('1')).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.reqExtArg(1)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqExtArg(true)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqExtArg({})).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqExtArg([])).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a pointer', () => {
|
||||||
|
expect(typeof test.reqExtArg(test.retExt())).toBe('object');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_EXT_ARG', () => {
|
||||||
|
it('exports letExtArg', () => {
|
||||||
|
expect(typeof test.letExtArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letExtArg('1')).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.letExtArg(1)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letExtArg(true)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letExtArg({})).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letExtArg([])).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(typeof test.letExtArg()).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(typeof test.letExtArg(undefined)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(typeof test.letExtArg(null)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts a pointer', () => {
|
||||||
|
expect(typeof test.reqExtArg(test.retExt())).toBe('object');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_EXT_ARG', () => {
|
||||||
|
it('exports useExtArg', () => {
|
||||||
|
expect(typeof test.useExtArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useExtArg('1')).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.useExtArg(1)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useExtArg(true)).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useExtArg({})).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useExtArg([])).toThrow(extArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(typeof test.useExtArg()).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(typeof test.useExtArg(undefined)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(typeof test.useExtArg(null)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(typeof test.useExtArg(test.retExt())).toBe('object');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const numArgMsg = 'Argument 0 must be of type `Number`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_FLOAT_ARG', () => {
|
||||||
|
it('exports reqFloatArg', () => {
|
||||||
|
expect(typeof test.reqFloatArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqFloatArg()).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqFloatArg(undefined)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqFloatArg(null)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqFloatArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqFloatArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqFloatArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqFloatArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.reqFloatArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_FLOAT_ARG', () => {
|
||||||
|
it('exports letFloatArg', () => {
|
||||||
|
expect(typeof test.letFloatArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letFloatArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letFloatArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letFloatArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letFloatArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letFloatArg()).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letFloatArg(undefined)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letFloatArg(null)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.letFloatArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_FLOAT_ARG', () => {
|
||||||
|
it('exports useFloatArg', () => {
|
||||||
|
expect(typeof test.useFloatArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useFloatArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useFloatArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useFloatArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useFloatArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useFloatArg()).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useFloatArg(undefined)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useFloatArg(null)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.useFloatArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const intArgMsg = 'Argument 0 must be of type `Int32`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_INT_ARG / REQ_INT32_ARG', () => {
|
||||||
|
it('exports reqIntArg', () => {
|
||||||
|
expect(typeof test.reqIntArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqIntArg()).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqIntArg(undefined)).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqIntArg(null)).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqIntArg('1')).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqIntArg(true)).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqIntArg({})).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqIntArg([])).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.reqIntArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_INT_ARG / LET_INT32_ARG', () => {
|
||||||
|
it('exports letIntArg', () => {
|
||||||
|
expect(typeof test.letIntArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letIntArg('1')).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letIntArg(true)).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letIntArg({})).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letIntArg([])).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letIntArg()).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letIntArg(undefined)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letIntArg(null)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.letIntArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_INT_ARG / USE_INT32_ARG', () => {
|
||||||
|
it('exports useIntArg', () => {
|
||||||
|
expect(typeof test.useIntArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useIntArg('1')).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useIntArg(true)).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useIntArg({})).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useIntArg([])).toThrow(intArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useIntArg()).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useIntArg(undefined)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useIntArg(null)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.useIntArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,105 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const objArgMsg = 'Argument 0 must be of type `Object`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_OBJ_ARG', () => {
|
||||||
|
it('exports reqObjArg', () => {
|
||||||
|
expect(typeof test.reqObjArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqObjArg()).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqObjArg(undefined)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqObjArg(null)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqObjArg('1')).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.reqObjArg(1)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqObjArg(true)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a pointer', () => {
|
||||||
|
expect(() => test.reqObjArg(test.retExt())).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an object', () => {
|
||||||
|
expect(typeof test.reqObjArg({})).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts an array', () => {
|
||||||
|
expect(Array.isArray(test.reqObjArg([]))).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_OBJ_ARG', () => {
|
||||||
|
it('exports letObjArg', () => {
|
||||||
|
expect(typeof test.letObjArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letObjArg('1')).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.letObjArg(1)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letObjArg(true)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a pointer', () => {
|
||||||
|
expect(() => test.letObjArg(test.retExt())).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(typeof test.letObjArg()).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(typeof test.letObjArg(undefined)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(typeof test.letObjArg(null)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts an object', () => {
|
||||||
|
expect(typeof test.letObjArg({})).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts an array', () => {
|
||||||
|
expect(Array.isArray(test.letObjArg([]))).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_OBJ_ARG', () => {
|
||||||
|
it('exports useObjArg', () => {
|
||||||
|
expect(typeof test.useObjArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useObjArg('1')).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.useObjArg(1)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useObjArg(true)).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a pointer', () => {
|
||||||
|
expect(() => test.useObjArg(test.retExt())).toThrow(objArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(typeof test.useObjArg()).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(typeof test.useObjArg(undefined)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(typeof test.useObjArg(null)).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts an object', () => {
|
||||||
|
expect(typeof test.useObjArg({})).toBe('object');
|
||||||
|
});
|
||||||
|
it('accepts an array', () => {
|
||||||
|
expect(Array.isArray(test.useObjArg([]))).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const numArgMsg = 'Argument 0 must be of type `Number`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_OFFS_ARG', () => {
|
||||||
|
it('exports reqOffsArg', () => {
|
||||||
|
expect(typeof test.reqOffsArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqOffsArg()).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqOffsArg(undefined)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqOffsArg(null)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqOffsArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqOffsArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqOffsArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqOffsArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.reqOffsArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_OFFS_ARG', () => {
|
||||||
|
it('exports letOffsArg', () => {
|
||||||
|
expect(typeof test.letOffsArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letOffsArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letOffsArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letOffsArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letOffsArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letOffsArg()).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letOffsArg(undefined)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letOffsArg(null)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.letOffsArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_OFFS_ARG', () => {
|
||||||
|
it('exports useOffsArg', () => {
|
||||||
|
expect(typeof test.useOffsArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useOffsArg('1')).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useOffsArg(true)).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useOffsArg({})).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useOffsArg([])).toThrow(numArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useOffsArg()).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useOffsArg(undefined)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useOffsArg(null)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.useOffsArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const strArgMsg = 'Argument 0 must be of type `String`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_STR_ARG', () => {
|
||||||
|
it('exports reqStrArg', () => {
|
||||||
|
expect(typeof test.reqStrArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqStrArg()).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqStrArg(undefined)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqStrArg(null)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.reqStrArg(1)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqStrArg(true)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqStrArg({})).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqStrArg([])).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a string', () => {
|
||||||
|
expect(test.reqStrArg('1abc')).toEqual('1abc');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_STR_ARG', () => {
|
||||||
|
it('exports letStrArg', () => {
|
||||||
|
expect(typeof test.letStrArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.letStrArg(1)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letStrArg(true)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letStrArg({})).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letStrArg([])).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letStrArg()).toEqual('');
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letStrArg(undefined)).toEqual('');
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letStrArg(null)).toEqual('');
|
||||||
|
});
|
||||||
|
it('accepts a string', () => {
|
||||||
|
expect(test.letStrArg('1abc')).toEqual('1abc');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_STR_ARG', () => {
|
||||||
|
it('exports useStrArg', () => {
|
||||||
|
expect(typeof test.useStrArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a number', () => {
|
||||||
|
expect(() => test.useStrArg(1)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useStrArg(true)).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useStrArg({})).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useStrArg([])).toThrow(strArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useStrArg()).toEqual('default');
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useStrArg(undefined)).toEqual('default');
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useStrArg(null)).toEqual('default');
|
||||||
|
});
|
||||||
|
it('accepts a string', () => {
|
||||||
|
expect(test.useStrArg('1abc')).toEqual('1abc');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
|
const uintArgMsg = 'Argument 0 must be of type `Uint32`';
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: REQ_UINT_ARG / REQ_UINT32_ARG', () => {
|
||||||
|
it('exports reqUintArg', () => {
|
||||||
|
expect(typeof test.reqUintArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was not passed', () => {
|
||||||
|
expect(() => test.reqUintArg()).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed undefined', () => {
|
||||||
|
expect(() => test.reqUintArg(undefined)).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed null', () => {
|
||||||
|
expect(() => test.reqUintArg(null)).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.reqUintArg('1')).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.reqUintArg(true)).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.reqUintArg({})).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.reqUintArg([])).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.reqUintArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: LET_UINT_ARG / LET_UINT32_ARG', () => {
|
||||||
|
it('exports letUintArg', () => {
|
||||||
|
expect(typeof test.letUintArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.letUintArg('1')).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.letUintArg(true)).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.letUintArg({})).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.letUintArg([])).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.letUintArg()).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.letUintArg(undefined)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.letUintArg(null)).toEqual(0);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.letUintArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addon-tools.hpp: USE_UINT_ARG / USE_UINT32_ARG', () => {
|
||||||
|
it('exports useUintArg', () => {
|
||||||
|
expect(typeof test.useUintArg).toBe('function');
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a string', () => {
|
||||||
|
expect(() => test.useUintArg('1')).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed a boolean', () => {
|
||||||
|
expect(() => test.useUintArg(true)).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an object', () => {
|
||||||
|
expect(() => test.useUintArg({})).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('throws if arg was passed an array', () => {
|
||||||
|
expect(() => test.useUintArg([])).toThrow(uintArgMsg);
|
||||||
|
});
|
||||||
|
it('accepts an empty arg', () => {
|
||||||
|
expect(test.useUintArg()).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts undefined', () => {
|
||||||
|
expect(test.useUintArg(undefined)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts null', () => {
|
||||||
|
expect(test.useUintArg(null)).toEqual(10);
|
||||||
|
});
|
||||||
|
it('accepts a number', () => {
|
||||||
|
expect(test.useUintArg(55)).toEqual(55);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,95 +1,83 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
|
|
||||||
describe('Function arguments', () => {
|
describe('addon-tools.hpp: Function arguments', () => {
|
||||||
|
|
||||||
describe('REQ_ARGS', () => {
|
describe('REQ_ARGS', () => {
|
||||||
it('exports reqArgs3', () => {
|
it('exports reqArgs3', () => {
|
||||||
expect(test.reqArgs3).to.be.a('function');
|
expect(typeof test.reqArgs3).toBe('function');
|
||||||
});
|
});
|
||||||
it('throws if no args passed', () => {
|
it('throws if no args passed', () => {
|
||||||
expect(() => test.reqArgs3()).to.throw('Expected at least 3 arguments');
|
expect(() => test.reqArgs3()).toThrow('Expected at least 3 arguments');
|
||||||
});
|
});
|
||||||
it('throws if 1 arg passed', () => {
|
it('throws if 1 arg passed', () => {
|
||||||
expect(() => test.reqArgs3(1)).to.throw('Expected at least 3 arguments');
|
expect(() => test.reqArgs3(1)).toThrow('Expected at least 3 arguments');
|
||||||
});
|
});
|
||||||
it('returns true if 3 args passed', () => {
|
it('returns true if 3 args passed', () => {
|
||||||
expect(test.reqArgs3(1, 2, 3)).to.be.true;
|
expect(test.reqArgs3(1, 2, 3)).toEqual(true);
|
||||||
});
|
});
|
||||||
it('returns true if 5 args passed', () => {
|
it('returns true if 5 args passed', () => {
|
||||||
expect(test.reqArgs3(1, 2, 3, 4, 5)).to.be.true;
|
expect(test.reqArgs3(1, 2, 3, 4, 5)).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('IS_ARG_EMPTY', () => {
|
describe('IS_ARG_EMPTY', () => {
|
||||||
it('exports isArg0Empty', () => {
|
it('exports isArg0Empty', () => {
|
||||||
expect(test.isArg0Empty).to.be.a('function');
|
expect(typeof test.isArg0Empty).toBe('function');
|
||||||
});
|
});
|
||||||
it('returns true for absent arg', () => {
|
it('returns true for absent arg', () => {
|
||||||
expect(test.isArg0Empty()).to.be.true;
|
expect(test.isArg0Empty()).toEqual(true);
|
||||||
});
|
});
|
||||||
it('returns true for undefined arg', () => {
|
it('returns true for undefined arg', () => {
|
||||||
expect(test.isArg0Empty(undefined)).to.be.true;
|
expect(test.isArg0Empty(undefined)).toEqual(true);
|
||||||
});
|
});
|
||||||
it('returns true for null arg', () => {
|
it('returns true for null arg', () => {
|
||||||
expect(test.isArg0Empty(null)).to.be.true;
|
expect(test.isArg0Empty(null)).toEqual(true);
|
||||||
});
|
});
|
||||||
it('returns false for non-empty value', () => {
|
it('returns false for non-empty value', () => {
|
||||||
expect(test.isArg0Empty(1)).to.be.false;
|
expect(test.isArg0Empty(1)).toEqual(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
require('./test-hpp-arg-str');
|
|
||||||
require('./test-hpp-arg-int');
|
|
||||||
require('./test-hpp-arg-uint');
|
|
||||||
require('./test-hpp-arg-bool');
|
|
||||||
require('./test-hpp-arg-offs');
|
|
||||||
require('./test-hpp-arg-double');
|
|
||||||
require('./test-hpp-arg-float');
|
|
||||||
require('./test-hpp-arg-ext');
|
|
||||||
require('./test-hpp-arg-obj');
|
|
||||||
require('./test-hpp-arg-array');
|
|
||||||
|
|
||||||
// ------------------------------ FUN_ARG
|
// ------------------------------ FUN_ARG
|
||||||
|
|
||||||
const funArgMsg = 'Argument 0 must be of type `Function`';
|
const funArgMsg = 'Argument 0 must be of type `Function`';
|
||||||
|
|
||||||
describe('REQ_FUN_ARG', () => {
|
describe('REQ_FUN_ARG', () => {
|
||||||
it('exports reqFunArg', () => {
|
it('exports reqFunArg', () => {
|
||||||
expect(test.reqFunArg).to.be.a('function');
|
expect(typeof test.reqFunArg).toBe('function');
|
||||||
});
|
});
|
||||||
it('throws if arg was not passed', () => {
|
it('throws if arg was not passed', () => {
|
||||||
expect(() => test.reqFunArg()).to.throw(funArgMsg);
|
expect(() => test.reqFunArg()).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed undefined', () => {
|
it('throws if arg was passed undefined', () => {
|
||||||
expect(() => test.reqFunArg(undefined)).to.throw(funArgMsg);
|
expect(() => test.reqFunArg(undefined)).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed null', () => {
|
it('throws if arg was passed null', () => {
|
||||||
expect(() => test.reqFunArg(null)).to.throw(funArgMsg);
|
expect(() => test.reqFunArg(null)).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a string', () => {
|
it('throws if arg was passed a string', () => {
|
||||||
expect(() => test.reqFunArg('1')).to.throw(funArgMsg);
|
expect(() => test.reqFunArg('1')).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a number', () => {
|
it('throws if arg was passed a number', () => {
|
||||||
expect(() => test.reqFunArg(1)).to.throw(funArgMsg);
|
expect(() => test.reqFunArg(1)).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a boolean', () => {
|
it('throws if arg was passed a boolean', () => {
|
||||||
expect(() => test.reqFunArg(true)).to.throw(funArgMsg);
|
expect(() => test.reqFunArg(true)).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a pointer', () => {
|
it('throws if arg was passed a pointer', () => {
|
||||||
expect(() => test.reqFunArg(test.retExt())).to.throw(funArgMsg);
|
expect(() => test.reqFunArg(test.retExt())).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an object', () => {
|
it('throws if arg was passed an object', () => {
|
||||||
expect(() => test.reqFunArg({})).to.throw(funArgMsg);
|
expect(() => test.reqFunArg({})).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an array', () => {
|
it('throws if arg was passed an array', () => {
|
||||||
expect(() => test.reqFunArg([])).to.throw(funArgMsg);
|
expect(() => test.reqFunArg([])).toThrow(funArgMsg);
|
||||||
});
|
});
|
||||||
it('accepts a function', () => {
|
it('accepts a function', () => {
|
||||||
expect(test.reqFunArg(() => {})).to.be.a('function');
|
expect(typeof test.reqFunArg(() => {})).toBe('function');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,38 +87,38 @@ describe('Function arguments', () => {
|
||||||
|
|
||||||
describe('REQ_ARRV_ARG', () => {
|
describe('REQ_ARRV_ARG', () => {
|
||||||
it('exports reqArrvArg', () => {
|
it('exports reqArrvArg', () => {
|
||||||
expect(test.reqArrvArg).to.be.a('function');
|
expect(typeof test.reqArrvArg).toBe('function');
|
||||||
});
|
});
|
||||||
it('throws if arg was not passed', () => {
|
it('throws if arg was not passed', () => {
|
||||||
expect(() => test.reqArrvArg()).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg()).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed undefined', () => {
|
it('throws if arg was passed undefined', () => {
|
||||||
expect(() => test.reqArrvArg(undefined)).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg(undefined)).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed null', () => {
|
it('throws if arg was passed null', () => {
|
||||||
expect(() => test.reqArrvArg(null)).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg(null)).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a string', () => {
|
it('throws if arg was passed a string', () => {
|
||||||
expect(() => test.reqArrvArg('1')).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg('1')).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a number', () => {
|
it('throws if arg was passed a number', () => {
|
||||||
expect(() => test.reqArrvArg(1)).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg(1)).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a boolean', () => {
|
it('throws if arg was passed a boolean', () => {
|
||||||
expect(() => test.reqArrvArg(true)).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg(true)).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a pointer', () => {
|
it('throws if arg was passed a pointer', () => {
|
||||||
expect(() => test.reqArrvArg(test.retExt())).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg(test.retExt())).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an object', () => {
|
it('throws if arg was passed an object', () => {
|
||||||
expect(() => test.reqArrvArg({})).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg({})).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an array', () => {
|
it('throws if arg was passed an array', () => {
|
||||||
expect(() => test.reqArrvArg([])).to.throw(arrvArgMsg);
|
expect(() => test.reqArrvArg([])).toThrow(arrvArgMsg);
|
||||||
});
|
});
|
||||||
it('accepts an array buffer', () => {
|
it('accepts an array buffer', () => {
|
||||||
const { buffer } = new Uint8Array([1, 2, 3]);
|
const { buffer } = new Uint8Array([1, 2, 3]);
|
||||||
expect(test.reqArrvArg(buffer)).to.be.equal(buffer);
|
expect(test.reqArrvArg(buffer)).toEqual(buffer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -140,38 +128,38 @@ describe('Function arguments', () => {
|
||||||
|
|
||||||
describe('REQ_BUF_ARG', () => {
|
describe('REQ_BUF_ARG', () => {
|
||||||
it('exports reqBufArg', () => {
|
it('exports reqBufArg', () => {
|
||||||
expect(test.reqBufArg).to.be.a('function');
|
expect(typeof test.reqBufArg).toBe('function');
|
||||||
});
|
});
|
||||||
it('throws if arg was not passed', () => {
|
it('throws if arg was not passed', () => {
|
||||||
expect(() => test.reqBufArg()).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg()).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed undefined', () => {
|
it('throws if arg was passed undefined', () => {
|
||||||
expect(() => test.reqBufArg(undefined)).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg(undefined)).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed null', () => {
|
it('throws if arg was passed null', () => {
|
||||||
expect(() => test.reqBufArg(null)).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg(null)).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a string', () => {
|
it('throws if arg was passed a string', () => {
|
||||||
expect(() => test.reqBufArg('1')).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg('1')).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a number', () => {
|
it('throws if arg was passed a number', () => {
|
||||||
expect(() => test.reqBufArg(1)).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg(1)).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a boolean', () => {
|
it('throws if arg was passed a boolean', () => {
|
||||||
expect(() => test.reqBufArg(true)).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg(true)).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a pointer', () => {
|
it('throws if arg was passed a pointer', () => {
|
||||||
expect(() => test.reqBufArg(test.retExt())).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg(test.retExt())).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an object', () => {
|
it('throws if arg was passed an object', () => {
|
||||||
expect(() => test.reqBufArg({})).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg({})).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an array', () => {
|
it('throws if arg was passed an array', () => {
|
||||||
expect(() => test.reqBufArg([])).to.throw(bufArgMsg);
|
expect(() => test.reqBufArg([])).toThrow(bufArgMsg);
|
||||||
});
|
});
|
||||||
it('accepts a buffer', () => {
|
it('accepts a buffer', () => {
|
||||||
const buffer = Buffer.from([1, 2, 3]);
|
const buffer = Buffer.from([1, 2, 3]);
|
||||||
expect(test.reqBufArg(buffer)).to.be.equal(buffer);
|
expect(test.reqBufArg(buffer)).toEqual(buffer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -181,38 +169,38 @@ describe('Function arguments', () => {
|
||||||
|
|
||||||
describe('REQ_TYPED_ARRAY_ARG', () => {
|
describe('REQ_TYPED_ARRAY_ARG', () => {
|
||||||
it('exports reqTypedArg', () => {
|
it('exports reqTypedArg', () => {
|
||||||
expect(test.reqTypedArg).to.be.a('function');
|
expect(typeof test.reqTypedArg).toBe('function');
|
||||||
});
|
});
|
||||||
it('throws if arg was not passed', () => {
|
it('throws if arg was not passed', () => {
|
||||||
expect(() => test.reqTypedArg()).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg()).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed undefined', () => {
|
it('throws if arg was passed undefined', () => {
|
||||||
expect(() => test.reqTypedArg(undefined)).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg(undefined)).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed null', () => {
|
it('throws if arg was passed null', () => {
|
||||||
expect(() => test.reqTypedArg(null)).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg(null)).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a string', () => {
|
it('throws if arg was passed a string', () => {
|
||||||
expect(() => test.reqTypedArg('1')).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg('1')).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a number', () => {
|
it('throws if arg was passed a number', () => {
|
||||||
expect(() => test.reqTypedArg(1)).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg(1)).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a boolean', () => {
|
it('throws if arg was passed a boolean', () => {
|
||||||
expect(() => test.reqTypedArg(true)).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg(true)).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed a pointer', () => {
|
it('throws if arg was passed a pointer', () => {
|
||||||
expect(() => test.reqTypedArg(test.retExt())).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg(test.retExt())).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an object', () => {
|
it('throws if arg was passed an object', () => {
|
||||||
expect(() => test.reqTypedArg({})).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg({})).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('throws if arg was passed an array', () => {
|
it('throws if arg was passed an array', () => {
|
||||||
expect(() => test.reqTypedArg([])).to.throw(typedArgMsg);
|
expect(() => test.reqTypedArg([])).toThrow(typedArgMsg);
|
||||||
});
|
});
|
||||||
it('accepts a typed array', () => {
|
it('accepts a typed array', () => {
|
||||||
const typed = new Uint8Array([1, 2, 3]);
|
const typed = new Uint8Array([1, 2, 3]);
|
||||||
expect(test.reqTypedArg(typed)).to.be.equal(typed);
|
expect(test.reqTypedArg(typed)).toEqual(typed);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
|
|
||||||
|
|
||||||
describe('index.js', () => {
|
|
||||||
|
|
||||||
const tools = require('..');
|
const tools = require('..');
|
||||||
|
|
||||||
|
|
||||||
|
describe('index.js', () => {
|
||||||
describe(
|
describe(
|
||||||
'Properties',
|
'Properties',
|
||||||
() => ['bin', 'platform', 'include'].forEach(
|
() => ['bin', 'platform', 'include'].forEach(
|
||||||
m => it(`#${m} is a string`, () => {
|
m => it(`#${m} is a string`, () => {
|
||||||
expect(tools[m]).to.be.a('string');
|
expect(typeof tools[m]).toBe('string');
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('#paths()', () => {
|
describe('#paths()', () => {
|
||||||
|
|
||||||
it('is a function', () => {
|
it('is a function', () => {
|
||||||
expect(tools.paths).to.be.a('function');
|
expect(typeof tools.paths).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an object', () => {
|
it('returns an object', () => {
|
||||||
expect(tools.paths(__dirname)).to.be.an('object');
|
expect(typeof tools.paths(__dirname)).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has "include" string', () => {
|
it('has "include" string', () => {
|
||||||
expect(tools.paths(__dirname).include).to.be.a('string');
|
expect(typeof tools.paths(__dirname).include).toBe('string');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has "bin" string', () => {
|
it('has "bin" string', () => {
|
||||||
expect(tools.paths(__dirname).include).to.be.a('string');
|
expect(typeof tools.paths(__dirname).include).toBe('string');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
File diff suppressed because it is too large
Load Diff
|
@ -2,14 +2,29 @@
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "mocha",
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js"
|
||||||
|
],
|
||||||
|
"testMatch": [
|
||||||
|
"./**/*.test.js"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../doc/jest",
|
||||||
|
"coverageReporters": [
|
||||||
|
"lcov"
|
||||||
|
],
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"../**/*.js",
|
||||||
|
"!../**/*.test.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha",
|
"test": "jest --coverage=false --watch",
|
||||||
|
"test-ci": "jest --coverage=false --verbose",
|
||||||
"build": "node-gyp rebuild",
|
"build": "node-gyp rebuild",
|
||||||
"preinstall": "cd .. && npm ci"
|
"preinstall": "cd .. && npm ci"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chai": "4.2.0",
|
"jest": "26.6.3"
|
||||||
"mocha": "8.1.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const arrayArgMsg = 'Argument 0 must be of type `Array`';
|
|
||||||
|
|
||||||
describe('REQ_ARRAY_ARG', () => {
|
|
||||||
it('exports reqArrayArg', () => {
|
|
||||||
expect(test.reqArrayArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqArrayArg()).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqArrayArg(undefined)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqArrayArg(null)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqArrayArg('1')).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.reqArrayArg(1)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqArrayArg(true)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a pointer', () => {
|
|
||||||
expect(() => test.reqArrayArg(test.retExt())).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqArrayArg({})).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an array', () => {
|
|
||||||
expect(test.reqArrayArg([])).to.be.an('array');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_ARRAY_ARG', () => {
|
|
||||||
it('exports letArrayArg', () => {
|
|
||||||
expect(test.letArrayArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letArrayArg('1')).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.letArrayArg(1)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letArrayArg(true)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a pointer', () => {
|
|
||||||
expect(() => test.letArrayArg(test.retExt())).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letArrayArg({})).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letArrayArg()).to.be.an('array');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letArrayArg(undefined)).to.be.an('array');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letArrayArg(null)).to.be.an('array');
|
|
||||||
});
|
|
||||||
it('accepts an array', () => {
|
|
||||||
expect(test.letArrayArg([])).to.be.an('array');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_ARRAY_ARG', () => {
|
|
||||||
it('exports useArrayArg', () => {
|
|
||||||
expect(test.useArrayArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useArrayArg('1')).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.useArrayArg(1)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useArrayArg(true)).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a pointer', () => {
|
|
||||||
expect(() => test.useArrayArg(test.retExt())).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useArrayArg({})).to.throw(arrayArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useArrayArg()).to.be.an('array');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useArrayArg(undefined)).to.be.an('array');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useArrayArg(null)).to.be.an('array');
|
|
||||||
});
|
|
||||||
it('accepts an array', () => {
|
|
||||||
expect(test.useArrayArg([])).to.be.an('array');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const boolArgMsg = 'Argument 0 must be of type `Bool`';
|
|
||||||
|
|
||||||
describe('REQ_BOOL_ARG', () => {
|
|
||||||
it('exports reqBoolArg', () => {
|
|
||||||
expect(test.reqBoolArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqBoolArg()).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqBoolArg(undefined)).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqBoolArg(null)).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqBoolArg('1')).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.reqBoolArg(1)).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqBoolArg({})).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqBoolArg([])).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a boolean', () => {
|
|
||||||
expect(test.reqBoolArg(true)).to.be.equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_BOOL_ARG', () => {
|
|
||||||
it('exports letBoolArg', () => {
|
|
||||||
expect(test.letBoolArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letBoolArg('1')).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.letBoolArg(1)).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letBoolArg({})).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letBoolArg([])).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letBoolArg()).to.be.equal(false);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letBoolArg(undefined)).to.be.equal(false);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letBoolArg(null)).to.be.equal(false);
|
|
||||||
});
|
|
||||||
it('accepts a boolean', () => {
|
|
||||||
expect(test.letBoolArg(true)).to.be.equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_BOOL_ARG', () => {
|
|
||||||
it('exports useBoolArg', () => {
|
|
||||||
expect(test.useBoolArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useBoolArg('1')).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.useBoolArg(1)).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useBoolArg({})).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useBoolArg([])).to.throw(boolArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useBoolArg()).to.be.equal(true);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useBoolArg(undefined)).to.be.equal(true);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useBoolArg(null)).to.be.equal(true);
|
|
||||||
});
|
|
||||||
it('accepts a boolean', () => {
|
|
||||||
expect(test.useBoolArg(true)).to.be.equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const numArgMsg = 'Argument 0 must be of type `Number`';
|
|
||||||
|
|
||||||
describe('REQ_DOUBLE_ARG', () => {
|
|
||||||
it('exports reqDoubleArg', () => {
|
|
||||||
expect(test.reqDoubleArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqDoubleArg()).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqDoubleArg(undefined)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqDoubleArg(null)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqDoubleArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqDoubleArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqDoubleArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqDoubleArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.reqDoubleArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_DOUBLE_ARG', () => {
|
|
||||||
it('exports letDoubleArg', () => {
|
|
||||||
expect(test.letDoubleArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letDoubleArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letDoubleArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letDoubleArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letDoubleArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letDoubleArg()).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letDoubleArg(undefined)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letDoubleArg(null)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.letDoubleArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_DOUBLE_ARG', () => {
|
|
||||||
it('exports useDoubleArg', () => {
|
|
||||||
expect(test.useDoubleArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useDoubleArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useDoubleArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useDoubleArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useDoubleArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useDoubleArg()).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useDoubleArg(undefined)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useDoubleArg(null)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.useDoubleArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,106 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const extArgMsg = 'Argument 0 must be of type `Pointer`';
|
|
||||||
|
|
||||||
describe('REQ_EXT_ARG', () => {
|
|
||||||
it('exports reqExtArg', () => {
|
|
||||||
expect(test.reqExtArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqExtArg()).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqExtArg(undefined)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqExtArg(null)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqExtArg('1')).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.reqExtArg(1)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqExtArg(true)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqExtArg({})).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqExtArg([])).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a pointer', () => {
|
|
||||||
expect(test.reqExtArg(test.retExt())).to.be.an('object');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_EXT_ARG', () => {
|
|
||||||
it('exports letExtArg', () => {
|
|
||||||
expect(test.letExtArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letExtArg('1')).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.letExtArg(1)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letExtArg(true)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letExtArg({})).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letExtArg([])).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letExtArg()).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letExtArg(undefined)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letExtArg(null)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts a pointer', () => {
|
|
||||||
expect(test.reqExtArg(test.retExt())).to.be.an('object');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_EXT_ARG', () => {
|
|
||||||
it('exports useExtArg', () => {
|
|
||||||
expect(test.useExtArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useExtArg('1')).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.useExtArg(1)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useExtArg(true)).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useExtArg({})).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useExtArg([])).to.throw(extArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useExtArg()).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useExtArg(undefined)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useExtArg(null)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.useExtArg(test.retExt())).to.be.an('object');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const numArgMsg = 'Argument 0 must be of type `Number`';
|
|
||||||
|
|
||||||
describe('REQ_FLOAT_ARG', () => {
|
|
||||||
it('exports reqFloatArg', () => {
|
|
||||||
expect(test.reqFloatArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqFloatArg()).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqFloatArg(undefined)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqFloatArg(null)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqFloatArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqFloatArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqFloatArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqFloatArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.reqFloatArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_FLOAT_ARG', () => {
|
|
||||||
it('exports letFloatArg', () => {
|
|
||||||
expect(test.letFloatArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letFloatArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letFloatArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letFloatArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letFloatArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letFloatArg()).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letFloatArg(undefined)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letFloatArg(null)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.letFloatArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_FLOAT_ARG', () => {
|
|
||||||
it('exports useFloatArg', () => {
|
|
||||||
expect(test.useFloatArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useFloatArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useFloatArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useFloatArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useFloatArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useFloatArg()).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useFloatArg(undefined)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useFloatArg(null)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.useFloatArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const intArgMsg = 'Argument 0 must be of type `Int32`';
|
|
||||||
|
|
||||||
describe('REQ_INT_ARG / REQ_INT32_ARG', () => {
|
|
||||||
it('exports reqIntArg', () => {
|
|
||||||
expect(test.reqIntArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqIntArg()).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqIntArg(undefined)).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqIntArg(null)).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqIntArg('1')).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqIntArg(true)).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqIntArg({})).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqIntArg([])).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.reqIntArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_INT_ARG / LET_INT32_ARG', () => {
|
|
||||||
it('exports letIntArg', () => {
|
|
||||||
expect(test.letIntArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letIntArg('1')).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letIntArg(true)).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letIntArg({})).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letIntArg([])).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letIntArg()).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letIntArg(undefined)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letIntArg(null)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.letIntArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_INT_ARG / USE_INT32_ARG', () => {
|
|
||||||
it('exports useIntArg', () => {
|
|
||||||
expect(test.useIntArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useIntArg('1')).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useIntArg(true)).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useIntArg({})).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useIntArg([])).to.throw(intArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useIntArg()).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useIntArg(undefined)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useIntArg(null)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.useIntArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,106 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const objArgMsg = 'Argument 0 must be of type `Object`';
|
|
||||||
|
|
||||||
describe('REQ_OBJ_ARG', () => {
|
|
||||||
it('exports reqObjArg', () => {
|
|
||||||
expect(test.reqObjArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqObjArg()).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqObjArg(undefined)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqObjArg(null)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqObjArg('1')).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.reqObjArg(1)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqObjArg(true)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a pointer', () => {
|
|
||||||
expect(() => test.reqObjArg(test.retExt())).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an object', () => {
|
|
||||||
expect(test.reqObjArg({})).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts an array', () => {
|
|
||||||
expect(test.reqObjArg([])).to.be.an('array');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_OBJ_ARG', () => {
|
|
||||||
it('exports letObjArg', () => {
|
|
||||||
expect(test.letObjArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letObjArg('1')).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.letObjArg(1)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letObjArg(true)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a pointer', () => {
|
|
||||||
expect(() => test.letObjArg(test.retExt())).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letObjArg()).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letObjArg(undefined)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letObjArg(null)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts an object', () => {
|
|
||||||
expect(test.letObjArg({})).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts an array', () => {
|
|
||||||
expect(test.letObjArg([])).to.be.an('array');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_OBJ_ARG', () => {
|
|
||||||
it('exports useObjArg', () => {
|
|
||||||
expect(test.useObjArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useObjArg('1')).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.useObjArg(1)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useObjArg(true)).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a pointer', () => {
|
|
||||||
expect(() => test.useObjArg(test.retExt())).to.throw(objArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useObjArg()).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useObjArg(undefined)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useObjArg(null)).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts an object', () => {
|
|
||||||
expect(test.useObjArg({})).to.be.an('object');
|
|
||||||
});
|
|
||||||
it('accepts an array', () => {
|
|
||||||
expect(test.useObjArg([])).to.be.an('array');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const numArgMsg = 'Argument 0 must be of type `Number`';
|
|
||||||
|
|
||||||
describe('REQ_OFFS_ARG', () => {
|
|
||||||
it('exports reqOffsArg', () => {
|
|
||||||
expect(test.reqOffsArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqOffsArg()).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqOffsArg(undefined)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqOffsArg(null)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqOffsArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqOffsArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqOffsArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqOffsArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.reqOffsArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_OFFS_ARG', () => {
|
|
||||||
it('exports letOffsArg', () => {
|
|
||||||
expect(test.letOffsArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letOffsArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letOffsArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letOffsArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letOffsArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letOffsArg()).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letOffsArg(undefined)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letOffsArg(null)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.letOffsArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_OFFS_ARG', () => {
|
|
||||||
it('exports useOffsArg', () => {
|
|
||||||
expect(test.useOffsArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useOffsArg('1')).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useOffsArg(true)).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useOffsArg({})).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useOffsArg([])).to.throw(numArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useOffsArg()).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useOffsArg(undefined)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useOffsArg(null)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.useOffsArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const strArgMsg = 'Argument 0 must be of type `String`';
|
|
||||||
|
|
||||||
describe('REQ_STR_ARG', () => {
|
|
||||||
it('exports reqStrArg', () => {
|
|
||||||
expect(test.reqStrArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqStrArg()).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqStrArg(undefined)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqStrArg(null)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.reqStrArg(1)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqStrArg(true)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqStrArg({})).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqStrArg([])).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a string', () => {
|
|
||||||
expect(test.reqStrArg('1abc')).to.be.equal('1abc');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_STR_ARG', () => {
|
|
||||||
it('exports letStrArg', () => {
|
|
||||||
expect(test.letStrArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.letStrArg(1)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letStrArg(true)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letStrArg({})).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letStrArg([])).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letStrArg()).to.be.equal('');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letStrArg(undefined)).to.be.equal('');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letStrArg(null)).to.be.equal('');
|
|
||||||
});
|
|
||||||
it('accepts a string', () => {
|
|
||||||
expect(test.letStrArg('1abc')).to.be.equal('1abc');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_STR_ARG', () => {
|
|
||||||
it('exports useStrArg', () => {
|
|
||||||
expect(test.useStrArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a number', () => {
|
|
||||||
expect(() => test.useStrArg(1)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useStrArg(true)).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useStrArg({})).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useStrArg([])).to.throw(strArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useStrArg()).to.be.equal('default');
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useStrArg(undefined)).to.be.equal('default');
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useStrArg(null)).to.be.equal('default');
|
|
||||||
});
|
|
||||||
it('accepts a string', () => {
|
|
||||||
expect(test.useStrArg('1abc')).to.be.equal('1abc');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { expect } = require('chai');
|
|
||||||
const test = require('./build/Release/test.node');
|
|
||||||
|
|
||||||
|
|
||||||
const uintArgMsg = 'Argument 0 must be of type `Uint32`';
|
|
||||||
|
|
||||||
describe('REQ_UINT_ARG / REQ_UINT32_ARG', () => {
|
|
||||||
it('exports reqUintArg', () => {
|
|
||||||
expect(test.reqUintArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was not passed', () => {
|
|
||||||
expect(() => test.reqUintArg()).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed undefined', () => {
|
|
||||||
expect(() => test.reqUintArg(undefined)).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed null', () => {
|
|
||||||
expect(() => test.reqUintArg(null)).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.reqUintArg('1')).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.reqUintArg(true)).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.reqUintArg({})).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.reqUintArg([])).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.reqUintArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('LET_UINT_ARG / LET_UINT32_ARG', () => {
|
|
||||||
it('exports letUintArg', () => {
|
|
||||||
expect(test.letUintArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.letUintArg('1')).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.letUintArg(true)).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.letUintArg({})).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.letUintArg([])).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.letUintArg()).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.letUintArg(undefined)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.letUintArg(null)).to.be.equal(0);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.letUintArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('USE_UINT_ARG / USE_UINT32_ARG', () => {
|
|
||||||
it('exports useUintArg', () => {
|
|
||||||
expect(test.useUintArg).to.be.a('function');
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a string', () => {
|
|
||||||
expect(() => test.useUintArg('1')).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed a boolean', () => {
|
|
||||||
expect(() => test.useUintArg(true)).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an object', () => {
|
|
||||||
expect(() => test.useUintArg({})).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('throws if arg was passed an array', () => {
|
|
||||||
expect(() => test.useUintArg([])).to.throw(uintArgMsg);
|
|
||||||
});
|
|
||||||
it('accepts an empty arg', () => {
|
|
||||||
expect(test.useUintArg()).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts undefined', () => {
|
|
||||||
expect(test.useUintArg(undefined)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts null', () => {
|
|
||||||
expect(test.useUintArg(null)).to.be.equal(10);
|
|
||||||
});
|
|
||||||
it('accepts a number', () => {
|
|
||||||
expect(test.useUintArg(55)).to.be.equal(55);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,8 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
describe('addon-tools.hpp', () => {
|
|
||||||
|
|
||||||
require('./test-hpp-arg');
|
|
||||||
|
|
||||||
});
|
|
|
@ -1,4 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
require('./test-index');
|
|
||||||
require('./test-hpp');
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
import type { Stats } from 'fs';
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Reads a whole file to string, NOT A Buffer
|
||||||
|
export const read: (name: string) => Promise<string>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Write a file
|
||||||
|
export const write: (name: string, text: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Copy a file
|
||||||
|
export const copy: (src: string, dest: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Check if a file/folder exists
|
||||||
|
export const exists: (name: string) => Promise<boolean>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Create an empty folder
|
||||||
|
export const mkdir: (name: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Get status on a file
|
||||||
|
export const stat: (name: string) => Promise<Stats>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Check if the path is a folder
|
||||||
|
export const isDir: (name: string) => Promise<boolean>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Check if the path is a file
|
||||||
|
export const isFile: (name: string) => Promise<boolean>;
|
||||||
|
|
||||||
|
|
||||||
|
// Cut the path one folder up
|
||||||
|
export const dirUp: (dir: string) => string;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Like `mkdir -p`, makes sure a directory exists
|
||||||
|
export const ensuredir: (dir: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Copy a file, `dest` folder is created if needed
|
||||||
|
export const copysafe: (src: string, dest: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Get file/folder names of the 1st level
|
||||||
|
export const readdir: (src: string, dest: string) => Promise<ReadonlyArray<string>>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Get folder paths (concatenated with input) of the 1st level
|
||||||
|
export const subdirs: (name: string) => Promise<ReadonlyArray<string>>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Get file paths (concatenated with input) of the 1st level
|
||||||
|
export const subfiles: (name: string) => Promise<ReadonlyArray<string>>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Get all nested files recursively
|
||||||
|
// Folder paths are omitted by default
|
||||||
|
// Order is: shallow-to-deep, each subdirectory lists dirs-then-files.
|
||||||
|
export const traverse: (name: string, showDirs?: boolean) => Promise<ReadonlyArray<string>>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Copy a folder with all the contained files
|
||||||
|
export const copyall: (src: string, dest: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Like `rm -rf`, removes everything recursively
|
||||||
|
export const rmdir: (name: string) => Promise<void>;
|
||||||
|
|
||||||
|
|
||||||
|
// (async) Remove a file. Must be a file, not a folder. Just `fs.unlink`.
|
||||||
|
export const rm: (name: string) => Promise<void>;
|
|
@ -0,0 +1,6 @@
|
||||||
|
import type { Writable } from 'stream';
|
||||||
|
|
||||||
|
export class WritableBuffer extends Writable {
|
||||||
|
constructor();
|
||||||
|
get(): Buffer;
|
||||||
|
};
|
Loading…
Reference in New Issue