@pezkuwi/dev-test 0.84.3 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.skip-deno +0 -0
- package/README.md +5 -5
- package/package.json +9 -199
- package/tsconfig.build.json +16 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.spec.json +16 -0
- package/tsconfig.spec.tsbuildinfo +1 -0
- package/LICENSE +0 -201
- package/browser.d.ts +0 -1
- package/browser.js +0 -2
- package/cjs/browser.d.ts +0 -1
- package/cjs/browser.js +0 -4
- package/cjs/detectOther.d.ts +0 -2
- package/cjs/detectOther.js +0 -3
- package/cjs/env/browser.d.ts +0 -313
- package/cjs/env/browser.js +0 -98
- package/cjs/env/expect.d.ts +0 -297
- package/cjs/env/expect.js +0 -213
- package/cjs/env/index.d.ts +0 -4
- package/cjs/env/index.js +0 -20
- package/cjs/env/jest.d.ts +0 -127
- package/cjs/env/jest.js +0 -56
- package/cjs/env/lifecycle.d.ts +0 -12
- package/cjs/env/lifecycle.js +0 -17
- package/cjs/env/suite.d.ts +0 -16
- package/cjs/env/suite.js +0 -35
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +0 -1
- package/cjs/node.d.ts +0 -1
- package/cjs/node.js +0 -4
- package/cjs/package.json +0 -3
- package/cjs/packageInfo.d.ts +0 -6
- package/cjs/packageInfo.js +0 -4
- package/cjs/root.d.ts +0 -2
- package/cjs/root.js +0 -6
- package/cjs/rootJs/Clazz.d.ts +0 -18
- package/cjs/rootJs/Clazz.js +0 -36
- package/cjs/rootJs/Jsx.d.ts +0 -5
- package/cjs/rootJs/Jsx.js +0 -16
- package/cjs/rootJs/JsxChild.d.ts +0 -9
- package/cjs/rootJs/JsxChild.js +0 -9
- package/cjs/rootJs/augmented.d.ts +0 -8
- package/cjs/rootJs/augmented.js +0 -3
- package/cjs/rootJs/index.d.ts +0 -19
- package/cjs/rootJs/index.js +0 -51
- package/cjs/rootTests.d.ts +0 -2
- package/cjs/rootTests.js +0 -44
- package/cjs/sample.d.ts +0 -1
- package/cjs/sample.js +0 -4
- package/cjs/types.d.ts +0 -15
- package/cjs/types.js +0 -2
- package/cjs/util.d.ts +0 -20
- package/cjs/util.js +0 -51
- package/config/eslint.js +0 -160
- package/config/eslint.rules.js +0 -214
- package/config/prettier.cjs +0 -22
- package/config/rollup.js +0 -113
- package/config/tsconfig.json +0 -32
- package/config/typedoc.cjs +0 -18
- package/detectOther.d.ts +0 -2
- package/detectOther.js +0 -1
- package/env/browser.d.ts +0 -313
- package/env/browser.js +0 -95
- package/env/expect.d.ts +0 -297
- package/env/expect.js +0 -210
- package/env/index.d.ts +0 -4
- package/env/index.js +0 -17
- package/env/jest.d.ts +0 -127
- package/env/jest.js +0 -53
- package/env/lifecycle.d.ts +0 -12
- package/env/lifecycle.js +0 -14
- package/env/suite.d.ts +0 -16
- package/env/suite.js +0 -32
- package/globals.cjs +0 -4
- package/globals.d.cts +0 -1
- package/globals.d.ts +0 -32
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/node.d.ts +0 -1
- package/node.js +0 -2
- package/packageInfo.d.ts +0 -6
- package/packageInfo.js +0 -1
- package/root.d.ts +0 -2
- package/root.js +0 -2
- package/rootJs/Clazz.d.ts +0 -18
- package/rootJs/Clazz.js +0 -32
- package/rootJs/Jsx.d.ts +0 -5
- package/rootJs/Jsx.js +0 -13
- package/rootJs/JsxChild.d.ts +0 -9
- package/rootJs/JsxChild.js +0 -6
- package/rootJs/augmented.d.ts +0 -8
- package/rootJs/augmented.js +0 -2
- package/rootJs/dynamic.d.mts +0 -8
- package/rootJs/dynamic.mjs +0 -13
- package/rootJs/index.d.ts +0 -19
- package/rootJs/index.js +0 -39
- package/rootJs/testJson.json +0 -5
- package/rootStatic/kusama.svg +0 -1
- package/rootTests.d.ts +0 -2
- package/rootTests.js +0 -41
- package/scripts/polkadot-ci-ghact-build.mjs +0 -536
- package/scripts/polkadot-ci-ghact-docs.mjs +0 -14
- package/scripts/polkadot-ci-ghpages-force.mjs +0 -43
- package/scripts/polkadot-dev-build-docs.mjs +0 -19
- package/scripts/polkadot-dev-build-ts.mjs +0 -1518
- package/scripts/polkadot-dev-circular.mjs +0 -29
- package/scripts/polkadot-dev-clean-build.mjs +0 -61
- package/scripts/polkadot-dev-contrib.mjs +0 -74
- package/scripts/polkadot-dev-copy-dir.mjs +0 -44
- package/scripts/polkadot-dev-copy-to.mjs +0 -53
- package/scripts/polkadot-dev-deno-map.mjs +0 -35
- package/scripts/polkadot-dev-run-lint.mjs +0 -40
- package/scripts/polkadot-dev-run-node-ts.mjs +0 -9
- package/scripts/polkadot-dev-run-test.mjs +0 -163
- package/scripts/polkadot-dev-version.mjs +0 -143
- package/scripts/polkadot-dev-yarn-only.mjs +0 -11
- package/scripts/polkadot-exec-eslint.mjs +0 -7
- package/scripts/polkadot-exec-ghpages.mjs +0 -11
- package/scripts/polkadot-exec-ghrelease.mjs +0 -7
- package/scripts/polkadot-exec-node-test.mjs +0 -368
- package/scripts/polkadot-exec-rollup.mjs +0 -7
- package/scripts/polkadot-exec-tsc.mjs +0 -7
- package/scripts/polkadot-exec-webpack.mjs +0 -7
- package/scripts/util.mjs +0 -540
- package/types.d.ts +0 -15
- package/types.js +0 -1
- package/util.d.ts +0 -20
- package/util.js +0 -46
package/cjs/env/jest.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jest = jest;
|
|
4
|
-
const node_test_1 = require("node:test");
|
|
5
|
-
const util_js_1 = require("../util.js");
|
|
6
|
-
const JEST_KEYS_STUB = ['advanceTimersByTime', 'advanceTimersToNextTimer', 'autoMockOff', 'autoMockOn', 'clearAllMocks', 'clearAllTimers', 'createMockFromModule', 'deepUnmock', 'disableAutomock', 'doMock', 'dontMock', 'enableAutomock', 'fn', 'genMockFromModule', 'getRealSystemTime', 'getSeed', 'getTimerCount', 'isEnvironmentTornDown', 'isMockFunction', 'isolateModules', 'isolateModulesAsync', 'mock', 'mocked', 'now', 'replaceProperty', 'requireActual', 'requireMock', 'resetAllMocks', 'resetModules', 'restoreAllMocks', 'retryTimes', 'runAllImmediates', 'runAllTicks', 'runAllTimers', 'runOnlyPendingTimers', 'setMock', 'setSystemTime', 'setTimeout', 'spyOn', 'unmock', 'unstable_mockModule', 'useFakeTimers', 'useRealTimers'];
|
|
7
|
-
const JEST_KEYS_WARN = ['setTimeout'];
|
|
8
|
-
const MOCK_KEYS_STUB = ['_isMockFunction', 'getMockImplementation', 'getMockName', 'mock', 'mockClear', 'mockImplementation', 'mockImplementationOnce', 'mockName', 'mockRejectedValue', 'mockRejectedValueOnce', 'mockReset', 'mockResolvedValue', 'mockResolvedValueOnce', 'mockRestore', 'mockReturnThis', 'mockReturnValue', 'mockReturnValueOnce', 'withImplementation'];
|
|
9
|
-
const jestStub = (0, util_js_1.stubObj)('jest', JEST_KEYS_STUB);
|
|
10
|
-
const jestWarn = (0, util_js_1.warnObj)('jest', JEST_KEYS_WARN);
|
|
11
|
-
const mockStub = (0, util_js_1.stubObj)('jest.fn()', MOCK_KEYS_STUB);
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*
|
|
15
|
-
* This adds the mockReset and mockRestore functionality to any
|
|
16
|
-
* spy or mock function
|
|
17
|
-
**/
|
|
18
|
-
function extendMock(mocked) {
|
|
19
|
-
// We use the node:test mock here for casting below - however we
|
|
20
|
-
// don't want this in any method signature since this is a private
|
|
21
|
-
// types export, which could get us in "some" trouble
|
|
22
|
-
//
|
|
23
|
-
// Effectively the casts below ensure that our WithMock<*> aligns
|
|
24
|
-
// on a high-level to what we use via private type...
|
|
25
|
-
const spy = mocked;
|
|
26
|
-
return (0, util_js_1.enhanceObj)((0, util_js_1.enhanceObj)(mocked, {
|
|
27
|
-
mockImplementation: (fn) => {
|
|
28
|
-
spy.mock.mockImplementation(fn);
|
|
29
|
-
},
|
|
30
|
-
mockImplementationOnce: (fn) => {
|
|
31
|
-
spy.mock.mockImplementationOnce(fn);
|
|
32
|
-
},
|
|
33
|
-
mockReset: () => {
|
|
34
|
-
spy.mock.resetCalls();
|
|
35
|
-
},
|
|
36
|
-
mockRestore: () => {
|
|
37
|
-
spy.mock.restore();
|
|
38
|
-
}
|
|
39
|
-
}), mockStub);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Sets up the jest object. This is certainly not extensive, and probably
|
|
43
|
-
* not quite meant to be (never say never). Rather this adds the functionality
|
|
44
|
-
* that we use in the polkadot-js projects.
|
|
45
|
-
**/
|
|
46
|
-
function jest() {
|
|
47
|
-
return {
|
|
48
|
-
jest: (0, util_js_1.enhanceObj)((0, util_js_1.enhanceObj)({
|
|
49
|
-
fn: (fn) => extendMock(node_test_1.mock.fn(fn)),
|
|
50
|
-
restoreAllMocks: () => {
|
|
51
|
-
node_test_1.mock.reset();
|
|
52
|
-
},
|
|
53
|
-
spyOn: (obj, key) => extendMock(node_test_1.mock.method(obj, key))
|
|
54
|
-
}, jestWarn), jestStub)
|
|
55
|
-
};
|
|
56
|
-
}
|
package/cjs/env/lifecycle.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { after, afterEach, before, beforeEach } from 'node:test';
|
|
2
|
-
/**
|
|
3
|
-
* This ensures that the before/after functions are exposed
|
|
4
|
-
**/
|
|
5
|
-
export declare function lifecycle(): {
|
|
6
|
-
after: typeof after;
|
|
7
|
-
afterAll: typeof after;
|
|
8
|
-
afterEach: typeof afterEach;
|
|
9
|
-
before: typeof before;
|
|
10
|
-
beforeAll: typeof before;
|
|
11
|
-
beforeEach: typeof beforeEach;
|
|
12
|
-
};
|
package/cjs/env/lifecycle.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lifecycle = lifecycle;
|
|
4
|
-
const node_test_1 = require("node:test");
|
|
5
|
-
/**
|
|
6
|
-
* This ensures that the before/after functions are exposed
|
|
7
|
-
**/
|
|
8
|
-
function lifecycle() {
|
|
9
|
-
return {
|
|
10
|
-
after: node_test_1.after,
|
|
11
|
-
afterAll: node_test_1.after,
|
|
12
|
-
afterEach: node_test_1.afterEach,
|
|
13
|
-
before: node_test_1.before,
|
|
14
|
-
beforeAll: node_test_1.before,
|
|
15
|
-
beforeEach: node_test_1.beforeEach
|
|
16
|
-
};
|
|
17
|
-
}
|
package/cjs/env/suite.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This ensures that the describe and it functions match our actual usages.
|
|
3
|
-
* This includes .only, .skip and .todo helpers (.each is not applied)
|
|
4
|
-
**/
|
|
5
|
-
export declare function suite(): {
|
|
6
|
-
describe: ((name: string, exec: () => void | Promise<void>, timeout?: number) => void) & Omit<{
|
|
7
|
-
only: (name: string, exec: () => void | Promise<void>, timeout?: number) => void;
|
|
8
|
-
skip: (name: string, exec: () => void | Promise<void>, timeout?: number) => void;
|
|
9
|
-
todo: (name: string, exec: () => void | Promise<void>, timeout?: number) => void;
|
|
10
|
-
}, never>;
|
|
11
|
-
it: ((name: string, exec: () => void | Promise<void>, timeout?: number) => void) & Omit<{
|
|
12
|
-
only: (name: string, exec: () => void | Promise<void>, timeout?: number) => void;
|
|
13
|
-
skip: (name: string, exec: () => void | Promise<void>, timeout?: number) => void;
|
|
14
|
-
todo: (name: string, exec: () => void | Promise<void>, timeout?: number) => void;
|
|
15
|
-
}, never>;
|
|
16
|
-
};
|
package/cjs/env/suite.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.suite = suite;
|
|
4
|
-
const node_test_1 = require("node:test");
|
|
5
|
-
const util_js_1 = require("../util.js");
|
|
6
|
-
const MINUTE = 60 * 1000;
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*
|
|
10
|
-
* Wraps either describe or it with relevant .only, .skip, .todo & .each helpers,
|
|
11
|
-
* shimming it into a Jest-compatible environment.
|
|
12
|
-
*
|
|
13
|
-
* @param {} fn
|
|
14
|
-
*/
|
|
15
|
-
function createWrapper(fn, defaultTimeout) {
|
|
16
|
-
const wrap = (opts) => (name, exec, timeout) => fn(name, { ...opts, timeout: (timeout || defaultTimeout) }, exec);
|
|
17
|
-
// Ensure that we have consistent helpers on the function. These are not consistently
|
|
18
|
-
// applied accross all node:test versions, latest has all, so always apply ours.
|
|
19
|
-
// Instead of node:test options for e.g. timeout, we provide a Jest-compatible signature
|
|
20
|
-
return (0, util_js_1.enhanceObj)(wrap({}), {
|
|
21
|
-
only: wrap({ only: true }),
|
|
22
|
-
skip: wrap({ skip: true }),
|
|
23
|
-
todo: wrap({ todo: true })
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* This ensures that the describe and it functions match our actual usages.
|
|
28
|
-
* This includes .only, .skip and .todo helpers (.each is not applied)
|
|
29
|
-
**/
|
|
30
|
-
function suite() {
|
|
31
|
-
return {
|
|
32
|
-
describe: createWrapper(node_test_1.describe, 60 * MINUTE),
|
|
33
|
-
it: createWrapper(node_test_1.it, 2 * MINUTE)
|
|
34
|
-
};
|
|
35
|
-
}
|
package/cjs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/cjs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
throw new Error('Use node --require @pezkuwi/dev-test/{node, browser} depending on the required environment');
|
package/cjs/node.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/cjs/node.js
DELETED
package/cjs/package.json
DELETED
package/cjs/packageInfo.d.ts
DELETED
package/cjs/packageInfo.js
DELETED
package/cjs/root.d.ts
DELETED
package/cjs/root.js
DELETED
package/cjs/rootJs/Clazz.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare class Clazz {
|
|
2
|
-
#private;
|
|
3
|
-
readonly and: number;
|
|
4
|
-
static staticProperty: string;
|
|
5
|
-
static staticFunction: () => string | null;
|
|
6
|
-
/**
|
|
7
|
-
* @param and the number we should and with
|
|
8
|
-
*/
|
|
9
|
-
constructor(and: number);
|
|
10
|
-
get something(): number;
|
|
11
|
-
doAsync(): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* @description Sets something to something
|
|
14
|
-
* @param something The addition
|
|
15
|
-
*/
|
|
16
|
-
setSomething: (something?: number) => number;
|
|
17
|
-
toString(): string;
|
|
18
|
-
}
|
package/cjs/rootJs/Clazz.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Clazz = void 0;
|
|
4
|
-
class Clazz {
|
|
5
|
-
#something = 123_456_789;
|
|
6
|
-
and;
|
|
7
|
-
static staticProperty = 'foobar';
|
|
8
|
-
static staticFunction = () => Clazz.staticProperty;
|
|
9
|
-
/**
|
|
10
|
-
* @param and the number we should and with
|
|
11
|
-
*/
|
|
12
|
-
constructor(and) {
|
|
13
|
-
this.and = and;
|
|
14
|
-
this.#something = this.#something & and;
|
|
15
|
-
}
|
|
16
|
-
get something() {
|
|
17
|
-
return this.#something;
|
|
18
|
-
}
|
|
19
|
-
async doAsync() {
|
|
20
|
-
const res = await new Promise((resolve) => resolve(true));
|
|
21
|
-
console.log(res);
|
|
22
|
-
return res;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @description Sets something to something
|
|
26
|
-
* @param something The addition
|
|
27
|
-
*/
|
|
28
|
-
setSomething = (something) => {
|
|
29
|
-
this.#something = (something ?? 123_456) & this.and;
|
|
30
|
-
return this.#something;
|
|
31
|
-
};
|
|
32
|
-
toString() {
|
|
33
|
-
return `something=${this.#something}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.Clazz = Clazz;
|
package/cjs/rootJs/Jsx.d.ts
DELETED
package/cjs/rootJs/Jsx.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const styled_components_1 = require("styled-components");
|
|
7
|
-
const JsxChild_js_1 = tslib_1.__importDefault(require("./JsxChild.js"));
|
|
8
|
-
function Hidden({ children, className }) {
|
|
9
|
-
const [isMessageVisible, setMessageVisibility] = (0, react_1.useState)(false);
|
|
10
|
-
const onShow = (0, react_1.useCallback)((e) => setMessageVisibility(e.target.checked), []);
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)(StyledDiv, { className: className, children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: 'toggle', children: "Show Message" }), (0, jsx_runtime_1.jsx)("input", { checked: isMessageVisible, id: 'toggle', onChange: onShow, type: 'checkbox' }), isMessageVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children, (0, jsx_runtime_1.jsx)(JsxChild_js_1.default, { label: 'hello' })] }))] }));
|
|
12
|
-
}
|
|
13
|
-
const StyledDiv = styled_components_1.styled.div `
|
|
14
|
-
background: red;
|
|
15
|
-
`;
|
|
16
|
-
exports.default = react_1.default.memo(Hidden);
|
package/cjs/rootJs/JsxChild.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface Props {
|
|
3
|
-
children?: React.ReactNode;
|
|
4
|
-
className?: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function Child({ children, className, label }: Props): React.ReactElement<Props>;
|
|
8
|
-
declare const _default: React.MemoExoticComponent<typeof Child>;
|
|
9
|
-
export default _default;
|
package/cjs/rootJs/JsxChild.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
function Child({ children, className, label }) {
|
|
7
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: className, children: [label || '', children] }));
|
|
8
|
-
}
|
|
9
|
-
exports.default = react_1.default.memo(Child);
|
package/cjs/rootJs/augmented.js
DELETED
package/cjs/rootJs/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** This should appear as-is in the output with: 1. extension added, 2. augmented.d.ts correct */
|
|
2
|
-
import './augmented.js';
|
|
3
|
-
/** Double double work, i.e. re-exports */
|
|
4
|
-
export { Clazz } from './Clazz.js';
|
|
5
|
-
/** Function to ensure that BigInt does not have the Babel Math.pow() transform */
|
|
6
|
-
export declare function bigIntExp(): bigint;
|
|
7
|
-
/** Function to ensure that dynamic imports work */
|
|
8
|
-
export declare function dynamic(a: number, b: number): Promise<number>;
|
|
9
|
-
/** Function to ensure we have json correctly imported */
|
|
10
|
-
export declare function json(): string;
|
|
11
|
-
/** Check support for the ?? operator */
|
|
12
|
-
export declare function jsOpExp(a?: number): number;
|
|
13
|
-
/** This is an actual check to ensure PURE is all-happy */
|
|
14
|
-
export declare const pureOpExp: number;
|
|
15
|
-
declare const fooA = 1;
|
|
16
|
-
declare const fooB = 2;
|
|
17
|
-
declare const fooC = 3;
|
|
18
|
-
declare const fooD = 4;
|
|
19
|
-
export { fooA, fooB, fooC, fooD };
|
package/cjs/rootJs/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fooD = exports.fooC = exports.fooB = exports.fooA = exports.pureOpExp = exports.Clazz = void 0;
|
|
4
|
-
exports.bigIntExp = bigIntExp;
|
|
5
|
-
exports.dynamic = dynamic;
|
|
6
|
-
exports.json = json;
|
|
7
|
-
exports.jsOpExp = jsOpExp;
|
|
8
|
-
const tslib_1 = require("tslib");
|
|
9
|
-
/** This should appear as-is in the output with: 1. extension added, 2. augmented.d.ts correct */
|
|
10
|
-
require("./augmented.js");
|
|
11
|
-
/** This import should appear as-in in the ouput (cjs without asserts) */
|
|
12
|
-
const testJson_json_1 = tslib_1.__importDefault(require("@pezkuwi/dev/rootJs/testJson.json"));
|
|
13
|
-
/** Double double work, i.e. re-exports */
|
|
14
|
-
var Clazz_js_1 = require("./Clazz.js");
|
|
15
|
-
Object.defineProperty(exports, "Clazz", { enumerable: true, get: function () { return Clazz_js_1.Clazz; } });
|
|
16
|
-
/** Function to ensure that BigInt does not have the Babel Math.pow() transform */
|
|
17
|
-
function bigIntExp() {
|
|
18
|
-
// 123_456n * 137_858_491_849n
|
|
19
|
-
return 123456789n * (13n ** 10n);
|
|
20
|
-
}
|
|
21
|
-
/** Function to ensure that dynamic imports work */
|
|
22
|
-
async function dynamic(a, b) {
|
|
23
|
-
// NOTE we go via this path so it points to the same location in both ESM
|
|
24
|
-
// and CJS output (a './dynamic' import would be different otherwise)
|
|
25
|
-
const { sum } = await import('@pezkuwi/dev/rootJs/dynamic.mjs');
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
27
|
-
return sum(a, b);
|
|
28
|
-
}
|
|
29
|
-
/** Function to ensure we have json correctly imported */
|
|
30
|
-
function json() {
|
|
31
|
-
return testJson_json_1.default.test.json;
|
|
32
|
-
}
|
|
33
|
-
/** Check support for the ?? operator */
|
|
34
|
-
function jsOpExp(a) {
|
|
35
|
-
const defaults = {
|
|
36
|
-
a: 42,
|
|
37
|
-
b: 43,
|
|
38
|
-
c: 44
|
|
39
|
-
};
|
|
40
|
-
return a ?? defaults.a;
|
|
41
|
-
}
|
|
42
|
-
/** This is an actual check to ensure PURE is all-happy */
|
|
43
|
-
exports.pureOpExp = jsOpExp();
|
|
44
|
-
const fooA = 1;
|
|
45
|
-
exports.fooA = fooA;
|
|
46
|
-
const fooB = 2;
|
|
47
|
-
exports.fooB = fooB;
|
|
48
|
-
const fooC = 3;
|
|
49
|
-
exports.fooC = fooC;
|
|
50
|
-
const fooD = 4;
|
|
51
|
-
exports.fooD = fooD;
|
package/cjs/rootTests.d.ts
DELETED
package/cjs/rootTests.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runTests = runTests;
|
|
4
|
-
function runTests({ Clazz, TEST_PURE, bigIntExp, dynamic, jsOpExp, json }) {
|
|
5
|
-
describe('Clazz', () => {
|
|
6
|
-
it('has staticProperty', () => {
|
|
7
|
-
expect(Clazz.staticProperty).toBe('foobar');
|
|
8
|
-
});
|
|
9
|
-
it('creates an instance with get/set', () => {
|
|
10
|
-
const c = new Clazz(456);
|
|
11
|
-
expect(c.something).toBe(123_456_789 & 456);
|
|
12
|
-
c.setSomething(123);
|
|
13
|
-
expect(c.something).toBe(123 & 456);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe('TEST_PURE', () => {
|
|
17
|
-
it('should have the correct value', () => {
|
|
18
|
-
expect(TEST_PURE).toBe('testRoot');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('dynamic()', () => {
|
|
22
|
-
it('should allow dynamic import usage', async () => {
|
|
23
|
-
expect(await dynamic(5, 37)).toBe(42);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('bigIntExp()', () => {
|
|
27
|
-
it('should return the correct value', () => {
|
|
28
|
-
expect(bigIntExp()).toBe(123456789n * 137858491849n);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe('jsOpExp', () => {
|
|
32
|
-
it('handles 0 ?? 42 correctly', () => {
|
|
33
|
-
expect(jsOpExp(0)).toBe(0);
|
|
34
|
-
});
|
|
35
|
-
it('handles undefined ?? 42 correctly', () => {
|
|
36
|
-
expect(jsOpExp()).toBe(42);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
describe('json()', () => {
|
|
40
|
-
it('should return the correct value', () => {
|
|
41
|
-
expect(json()).toBe('works');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
package/cjs/sample.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export let foo: string;
|
package/cjs/sample.js
DELETED
package/cjs/types.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type AnyFn = (...args: any[]) => any;
|
|
2
|
-
export type BaseObj = Record<string, unknown>;
|
|
3
|
-
export type BaseFn = Function;
|
|
4
|
-
export type StubFn = (...args: unknown[]) => unknown;
|
|
5
|
-
export type WithMock<F extends AnyFn> = F & {
|
|
6
|
-
mock: {
|
|
7
|
-
calls: {
|
|
8
|
-
arguments: unknown[];
|
|
9
|
-
}[];
|
|
10
|
-
mockImplementation: (fn: AnyFn) => void;
|
|
11
|
-
mockImplementationOnce: (fn: AnyFn) => void;
|
|
12
|
-
resetCalls: () => void;
|
|
13
|
-
restore: () => void;
|
|
14
|
-
};
|
|
15
|
-
};
|
package/cjs/types.js
DELETED
package/cjs/util.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { BaseFn, BaseObj, StubFn } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Extends an existing object with the additional function if they
|
|
4
|
-
* are not already existing.
|
|
5
|
-
*/
|
|
6
|
-
export declare function enhanceObj<T extends BaseObj | BaseFn, X>(obj: T, extra: X): T & Omit<X, keyof T>;
|
|
7
|
-
/**
|
|
8
|
-
* Extends a given object with the named functions if they do not
|
|
9
|
-
* already exist on the object.
|
|
10
|
-
*
|
|
11
|
-
* @type {StubObjFn}
|
|
12
|
-
*/
|
|
13
|
-
export declare function stubObj<N extends readonly string[]>(objName: string, keys: N, alts?: Record<string, string>): { [K in N[number]]: StubFn; };
|
|
14
|
-
/**
|
|
15
|
-
* Extends a given object with the named functions if they do not
|
|
16
|
-
* already exist on the object.
|
|
17
|
-
*
|
|
18
|
-
* @type {StubObjFn}
|
|
19
|
-
*/
|
|
20
|
-
export declare function warnObj<N extends readonly string[]>(objName: string, keys: N): { [K in N[number]]: StubFn; };
|
package/cjs/util.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enhanceObj = enhanceObj;
|
|
4
|
-
exports.stubObj = stubObj;
|
|
5
|
-
exports.warnObj = warnObj;
|
|
6
|
-
/**
|
|
7
|
-
* Extends an existing object with the additional function if they
|
|
8
|
-
* are not already existing.
|
|
9
|
-
*/
|
|
10
|
-
function enhanceObj(obj, extra) {
|
|
11
|
-
Object
|
|
12
|
-
.entries(extra)
|
|
13
|
-
.forEach(([key, value]) => {
|
|
14
|
-
obj[key] ??= value;
|
|
15
|
-
});
|
|
16
|
-
return obj;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
|
-
*
|
|
21
|
-
* A helper to create a stub object based wite the stub creator supplied
|
|
22
|
-
*/
|
|
23
|
-
function createStub(keys, creator) {
|
|
24
|
-
return keys.reduce((obj, key) => {
|
|
25
|
-
obj[key] ??= creator(key);
|
|
26
|
-
return obj;
|
|
27
|
-
}, {});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Extends a given object with the named functions if they do not
|
|
31
|
-
* already exist on the object.
|
|
32
|
-
*
|
|
33
|
-
* @type {StubObjFn}
|
|
34
|
-
*/
|
|
35
|
-
function stubObj(objName, keys, alts) {
|
|
36
|
-
return createStub(keys, (key) => () => {
|
|
37
|
-
const alt = alts?.[key];
|
|
38
|
-
throw new Error(`${objName}.${key} has not been implemented${alt ? ` (Use ${alt} instead)` : ''}`);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Extends a given object with the named functions if they do not
|
|
43
|
-
* already exist on the object.
|
|
44
|
-
*
|
|
45
|
-
* @type {StubObjFn}
|
|
46
|
-
*/
|
|
47
|
-
function warnObj(objName, keys) {
|
|
48
|
-
return createStub(keys, (key) => () => {
|
|
49
|
-
console.warn(`${objName}.${key} has been implemented as a noop`);
|
|
50
|
-
});
|
|
51
|
-
}
|