remove test-node.js, use Function constructor to preserve whitespace
This commit is contained in:
parent
e5991b561e
commit
b2aad37462
4 changed files with 6 additions and 17 deletions
|
|
@ -21,7 +21,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "del distribution && tsc",
|
||||
"test": "tsc --noEmit && xo && ava && node test/test-node.js",
|
||||
"test": "tsc --noEmit && xo && ava",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ export function isBuffer(value: unknown): value is NodeBuffer {
|
|||
}
|
||||
|
||||
export function isClass<T = unknown>(value: unknown): value is Class<T> {
|
||||
return isFunction(value) && /^class(\s|{)/.test(value.toString());
|
||||
return isFunction(value) && /^class(\s+|{)/.test(value.toString());
|
||||
}
|
||||
|
||||
export function isDataView(value: unknown): value is DataView {
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
import assert from 'node:assert';
|
||||
import {test} from 'node:test';
|
||||
import is, {assert as isAssert} from '../distribution/index.js';
|
||||
|
||||
// Note: this test is separate from the rest of the tests, as it requires
|
||||
// preserving whitespace. The tsimp modifies the source and does not
|
||||
// properly preserve the intended test case
|
||||
test('is.class', () => {
|
||||
const minifiedClass = class{}; // eslint-disable-line keyword-spacing
|
||||
assert.ok(is.class(minifiedClass));
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
isAssert.class(minifiedClass);
|
||||
});
|
||||
});
|
||||
|
|
@ -1086,9 +1086,13 @@ test('is.asyncIterable', t => {
|
|||
test('is.class', t => {
|
||||
class Foo {} // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||
|
||||
// Note: Using new Function to prevent whitespace modifications in tsimp
|
||||
const minifiedClass = new Function('return class{};'); // eslint-disable-line no-new-func
|
||||
|
||||
const classDeclarations = [
|
||||
Foo,
|
||||
class Bar extends Foo {},
|
||||
minifiedClass(),
|
||||
];
|
||||
|
||||
for (const classDeclaration of classDeclarations) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue