@pezkuwi/dev-test 0.85.1 → 0.85.3

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.
Files changed (127) hide show
  1. package/.skip-deno +0 -0
  2. package/package.json +9 -199
  3. package/tsconfig.build.json +16 -0
  4. package/tsconfig.build.tsbuildinfo +1 -0
  5. package/tsconfig.spec.json +16 -0
  6. package/tsconfig.spec.tsbuildinfo +1 -0
  7. package/LICENSE +0 -201
  8. package/browser.d.ts +0 -1
  9. package/browser.js +0 -2
  10. package/cjs/browser.d.ts +0 -1
  11. package/cjs/browser.js +0 -4
  12. package/cjs/detectOther.d.ts +0 -2
  13. package/cjs/detectOther.js +0 -3
  14. package/cjs/env/browser.d.ts +0 -313
  15. package/cjs/env/browser.js +0 -98
  16. package/cjs/env/expect.d.ts +0 -297
  17. package/cjs/env/expect.js +0 -213
  18. package/cjs/env/index.d.ts +0 -4
  19. package/cjs/env/index.js +0 -20
  20. package/cjs/env/jest.d.ts +0 -127
  21. package/cjs/env/jest.js +0 -56
  22. package/cjs/env/lifecycle.d.ts +0 -12
  23. package/cjs/env/lifecycle.js +0 -17
  24. package/cjs/env/suite.d.ts +0 -16
  25. package/cjs/env/suite.js +0 -35
  26. package/cjs/index.d.ts +0 -1
  27. package/cjs/index.js +0 -1
  28. package/cjs/node.d.ts +0 -1
  29. package/cjs/node.js +0 -4
  30. package/cjs/package.json +0 -3
  31. package/cjs/packageInfo.d.ts +0 -6
  32. package/cjs/packageInfo.js +0 -4
  33. package/cjs/root.d.ts +0 -2
  34. package/cjs/root.js +0 -6
  35. package/cjs/rootJs/Clazz.d.ts +0 -18
  36. package/cjs/rootJs/Clazz.js +0 -36
  37. package/cjs/rootJs/Jsx.d.ts +0 -5
  38. package/cjs/rootJs/Jsx.js +0 -16
  39. package/cjs/rootJs/JsxChild.d.ts +0 -9
  40. package/cjs/rootJs/JsxChild.js +0 -9
  41. package/cjs/rootJs/augmented.d.ts +0 -8
  42. package/cjs/rootJs/augmented.js +0 -3
  43. package/cjs/rootJs/index.d.ts +0 -19
  44. package/cjs/rootJs/index.js +0 -51
  45. package/cjs/rootTests.d.ts +0 -2
  46. package/cjs/rootTests.js +0 -44
  47. package/cjs/sample.d.ts +0 -1
  48. package/cjs/sample.js +0 -4
  49. package/cjs/types.d.ts +0 -15
  50. package/cjs/types.js +0 -2
  51. package/cjs/util.d.ts +0 -20
  52. package/cjs/util.js +0 -51
  53. package/config/eslint.js +0 -160
  54. package/config/eslint.rules.js +0 -214
  55. package/config/prettier.cjs +0 -22
  56. package/config/rollup.js +0 -113
  57. package/config/tsconfig.json +0 -32
  58. package/config/typedoc.cjs +0 -18
  59. package/detectOther.d.ts +0 -2
  60. package/detectOther.js +0 -1
  61. package/env/browser.d.ts +0 -313
  62. package/env/browser.js +0 -95
  63. package/env/expect.d.ts +0 -297
  64. package/env/expect.js +0 -210
  65. package/env/index.d.ts +0 -4
  66. package/env/index.js +0 -17
  67. package/env/jest.d.ts +0 -127
  68. package/env/jest.js +0 -53
  69. package/env/lifecycle.d.ts +0 -12
  70. package/env/lifecycle.js +0 -14
  71. package/env/suite.d.ts +0 -16
  72. package/env/suite.js +0 -32
  73. package/globals.cjs +0 -4
  74. package/globals.d.cts +0 -1
  75. package/globals.d.ts +0 -32
  76. package/index.d.ts +0 -1
  77. package/index.js +0 -1
  78. package/node.d.ts +0 -1
  79. package/node.js +0 -2
  80. package/packageInfo.d.ts +0 -6
  81. package/packageInfo.js +0 -1
  82. package/root.d.ts +0 -2
  83. package/root.js +0 -2
  84. package/rootJs/Clazz.d.ts +0 -18
  85. package/rootJs/Clazz.js +0 -32
  86. package/rootJs/Jsx.d.ts +0 -5
  87. package/rootJs/Jsx.js +0 -13
  88. package/rootJs/JsxChild.d.ts +0 -9
  89. package/rootJs/JsxChild.js +0 -6
  90. package/rootJs/augmented.d.ts +0 -8
  91. package/rootJs/augmented.js +0 -2
  92. package/rootJs/dynamic.d.mts +0 -8
  93. package/rootJs/dynamic.mjs +0 -13
  94. package/rootJs/index.d.ts +0 -19
  95. package/rootJs/index.js +0 -39
  96. package/rootJs/testJson.json +0 -5
  97. package/rootStatic/zagros.svg +0 -1
  98. package/rootTests.d.ts +0 -2
  99. package/rootTests.js +0 -41
  100. package/scripts/pezkuwi-ci-ghact-build.mjs +0 -536
  101. package/scripts/pezkuwi-ci-ghact-docs.mjs +0 -14
  102. package/scripts/pezkuwi-ci-ghpages-force.mjs +0 -43
  103. package/scripts/pezkuwi-dev-build-docs.mjs +0 -19
  104. package/scripts/pezkuwi-dev-build-ts.mjs +0 -1518
  105. package/scripts/pezkuwi-dev-circular.mjs +0 -29
  106. package/scripts/pezkuwi-dev-clean-build.mjs +0 -61
  107. package/scripts/pezkuwi-dev-contrib.mjs +0 -74
  108. package/scripts/pezkuwi-dev-copy-dir.mjs +0 -44
  109. package/scripts/pezkuwi-dev-copy-to.mjs +0 -53
  110. package/scripts/pezkuwi-dev-deno-map.mjs +0 -35
  111. package/scripts/pezkuwi-dev-run-lint.mjs +0 -40
  112. package/scripts/pezkuwi-dev-run-node-ts.mjs +0 -9
  113. package/scripts/pezkuwi-dev-run-test.mjs +0 -163
  114. package/scripts/pezkuwi-dev-version.mjs +0 -143
  115. package/scripts/pezkuwi-dev-yarn-only.mjs +0 -11
  116. package/scripts/pezkuwi-exec-eslint.mjs +0 -7
  117. package/scripts/pezkuwi-exec-ghpages.mjs +0 -11
  118. package/scripts/pezkuwi-exec-ghrelease.mjs +0 -7
  119. package/scripts/pezkuwi-exec-node-test.mjs +0 -368
  120. package/scripts/pezkuwi-exec-rollup.mjs +0 -7
  121. package/scripts/pezkuwi-exec-tsc.mjs +0 -7
  122. package/scripts/pezkuwi-exec-webpack.mjs +0 -7
  123. package/scripts/util.mjs +0 -540
  124. package/types.d.ts +0 -15
  125. package/types.js +0 -1
  126. package/util.d.ts +0 -20
  127. 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 pezkuwi-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
- }
@@ -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
- };
@@ -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
- }
@@ -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
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_js_1 = require("./env/index.js");
4
- (0, index_js_1.exposeEnv)(false);
package/cjs/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,6 +0,0 @@
1
- export declare const packageInfo: {
2
- name: string;
3
- path: string;
4
- type: string;
5
- version: string;
6
- };
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@pezkuwi/dev-test', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '0.83.3' };
package/cjs/root.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './rootJs/index.js';
2
- export declare const TEST_PURE = "testRoot";
package/cjs/root.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEST_PURE = void 0;
4
- const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./rootJs/index.js"), exports);
6
- exports.TEST_PURE = 'testRoot';
@@ -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
- }
@@ -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;
@@ -1,5 +0,0 @@
1
- import type { Props } from './JsxChild.js';
2
- import React from 'react';
3
- declare function Hidden({ children, className }: Props): React.ReactElement<Props>;
4
- declare const _default: React.MemoExoticComponent<typeof Hidden>;
5
- export default _default;
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);
@@ -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;
@@ -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);
@@ -1,8 +0,0 @@
1
- /** This tests augmentation outputs, e.g. as used in the pezkuwi-js/api */
2
- export interface Something {
3
- bar: string;
4
- foo: string;
5
- }
6
- declare module '@pezkuwi/dev/types' {
7
- const blah: string;
8
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 };
@@ -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;
@@ -1,2 +0,0 @@
1
- import type * as testRoot from './root.js';
2
- export declare function runTests({ Clazz, TEST_PURE, bigIntExp, dynamic, jsOpExp, json }: typeof testRoot): void;
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
@@ -1,4 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/dev authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- module.exports = { foo: 'bar' };
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
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- }