xenopomp-essentials 0.5.0-canary.1 → 0.5.0-canary.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.
@@ -36,4 +36,5 @@ type Options = OptionsConfig & CustomConfig & TypedFlatConfigItem & CustomOption
36
36
  */
37
37
  declare function xenopomp(options?: Options, ...userConfigs: UserConfigItem[]): Configs;
38
38
 
39
- export { type Configs, type CustomConfig, type Options, type UserConfigItem, xenopomp as default };
39
+ export { xenopomp as default };
40
+ export type { Configs, CustomConfig, Options, UserConfigItem };
package/eslint/index.d.ts CHANGED
@@ -36,4 +36,5 @@ type Options = OptionsConfig & CustomConfig & TypedFlatConfigItem & CustomOption
36
36
  */
37
37
  declare function xenopomp(options?: Options, ...userConfigs: UserConfigItem[]): Configs;
38
38
 
39
- export { type Configs, type CustomConfig, type Options, type UserConfigItem, xenopomp as default };
39
+ export { xenopomp as default };
40
+ export type { Configs, CustomConfig, Options, UserConfigItem };
package/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ export { P as PromiseOr } from './shared/xenopomp-essentials.B-Vt61jj.mjs';
1
2
  import { ElementType, ComponentProps, FC, ReactNode, Dispatch, SetStateAction } from 'react';
2
3
  import { Jsonifiable } from 'type-fest';
3
4
  import * as transliteration from 'transliteration';
@@ -616,4 +617,5 @@ declare const minmax: (num: number, [min, max]: [min: number | undefined, max: n
616
617
  */
617
618
  declare function jsxDotNotation<Props = EmptyObject, Rest extends Record<string, FC<any>> = EmptyObject>(comp: FC<Props>, rest: Rest): FC<Props> & Rest;
618
619
 
619
- export { type AnyFC, type AnyObject, type ArrayItemType, type ArrayType, type AsyncFC, type AsyncReturnType, type AsyncVariableFC, type DataAttributes, type Defined, type EmptyObject, type FCProps, type FcProps, type Fn, type FunctionalChildren, type InjectDeep, type Jsonish, type Lenient, type LenientAutocomplete, type MatchType, type MergeTypes, type Modify, type NextErrorParams, type NextParams, type NextSearchParams, type Nullable, type OneOf, type OnlyFirst, type Optional, type Preid, type Prettify, type PrettifyDeep, type RecordKey, type RecordValue, type ReplaceReturnType, type SelectivePartial, type SetState, type StrictOmit, type Synchronous, type Undefinable, type VariableFC, type VariableProps, type VersionData, type WeakOmit, type Writeable, type WriteableDeep, capitalize, jsxDotNotation, minmax, parseVersion, pipe, transliterate, uncapitalize };
620
+ export { capitalize, jsxDotNotation, minmax, parseVersion, pipe, transliterate, uncapitalize };
621
+ export type { AnyFC, AnyObject, ArrayItemType, ArrayType, AsyncFC, AsyncReturnType, AsyncVariableFC, DataAttributes, Defined, EmptyObject, FCProps, FcProps, Fn, FunctionalChildren, InjectDeep, Jsonish, Lenient, LenientAutocomplete, MatchType, MergeTypes, Modify, NextErrorParams, NextParams, NextSearchParams, Nullable, OneOf, OnlyFirst, Optional, Preid, Prettify, PrettifyDeep, RecordKey, RecordValue, ReplaceReturnType, SelectivePartial, SetState, StrictOmit, Synchronous, Undefinable, VariableFC, VariableProps, VersionData, WeakOmit, Writeable, WriteableDeep };
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { P as PromiseOr } from './shared/xenopomp-essentials.B-Vt61jj.js';
1
2
  import { ElementType, ComponentProps, FC, ReactNode, Dispatch, SetStateAction } from 'react';
2
3
  import { Jsonifiable } from 'type-fest';
3
4
  import * as transliteration from 'transliteration';
@@ -616,4 +617,5 @@ declare const minmax: (num: number, [min, max]: [min: number | undefined, max: n
616
617
  */
617
618
  declare function jsxDotNotation<Props = EmptyObject, Rest extends Record<string, FC<any>> = EmptyObject>(comp: FC<Props>, rest: Rest): FC<Props> & Rest;
618
619
 
619
- export { type AnyFC, type AnyObject, type ArrayItemType, type ArrayType, type AsyncFC, type AsyncReturnType, type AsyncVariableFC, type DataAttributes, type Defined, type EmptyObject, type FCProps, type FcProps, type Fn, type FunctionalChildren, type InjectDeep, type Jsonish, type Lenient, type LenientAutocomplete, type MatchType, type MergeTypes, type Modify, type NextErrorParams, type NextParams, type NextSearchParams, type Nullable, type OneOf, type OnlyFirst, type Optional, type Preid, type Prettify, type PrettifyDeep, type RecordKey, type RecordValue, type ReplaceReturnType, type SelectivePartial, type SetState, type StrictOmit, type Synchronous, type Undefinable, type VariableFC, type VariableProps, type VersionData, type WeakOmit, type Writeable, type WriteableDeep, capitalize, jsxDotNotation, minmax, parseVersion, pipe, transliterate, uncapitalize };
620
+ export { capitalize, jsxDotNotation, minmax, parseVersion, pipe, transliterate, uncapitalize };
621
+ export type { AnyFC, AnyObject, ArrayItemType, ArrayType, AsyncFC, AsyncReturnType, AsyncVariableFC, DataAttributes, Defined, EmptyObject, FCProps, FcProps, Fn, FunctionalChildren, InjectDeep, Jsonish, Lenient, LenientAutocomplete, MatchType, MergeTypes, Modify, NextErrorParams, NextParams, NextSearchParams, Nullable, OneOf, OnlyFirst, Optional, Preid, Prettify, PrettifyDeep, RecordKey, RecordValue, ReplaceReturnType, SelectivePartial, SetState, StrictOmit, Synchronous, Undefinable, VariableFC, VariableProps, VersionData, WeakOmit, Writeable, WriteableDeep };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xenopomp-essentials",
3
- "version": "0.5.0-canary.1",
3
+ "version": "0.5.0-canary.3",
4
4
  "author": "XenoPOMP <101574433+XenoPOMP@users.noreply.github.com>",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -53,6 +53,8 @@
53
53
  "@typescript-eslint/types": "^8.48.0",
54
54
  "@typescript-eslint/utils": "^8.48.0",
55
55
  "@typescript-eslint/visitor-keys": "^8.48.0",
56
+ "@vitest/spy": "^4.0.14",
57
+ "ansi-colors": "^4.1.3",
56
58
  "deepmerge-ts": "^7.1.5",
57
59
  "eslint": "^9.22.0",
58
60
  "eslint-config-prettier": "^10.1.1",
@@ -88,7 +90,7 @@
88
90
  "prettier": "^3.4.2",
89
91
  "react-dom": "^19.2.0",
90
92
  "tsd": "^0.31.2",
91
- "unbuild": "^3.3.1",
93
+ "unbuild": "^3.6.1",
92
94
  "vite": "^7.2.4",
93
95
  "vite-tsconfig-paths": "^5.1.4"
94
96
  }
@@ -0,0 +1,3 @@
1
+ type PromiseOr<T> = T | Promise<T>;
2
+
3
+ export type { PromiseOr as P };
@@ -0,0 +1,3 @@
1
+ type PromiseOr<T> = T | Promise<T>;
2
+
3
+ export type { PromiseOr as P };
@@ -1,26 +1,93 @@
1
- import { renderHook, render } from '@testing-library/react';
1
+ import { P as PromiseOr } from '../shared/xenopomp-essentials.B-Vt61jj.mjs';
2
+ import { render, renderHook } from '@testing-library/react';
3
+ import * as vitest from 'vitest';
4
+ import * as _vitest_spy from '@vitest/spy';
2
5
 
3
6
  /** Executes function and expects that it won't throw. */
4
- declare const assertNotThrowing: (callable: () => void) => void;
5
-
6
- /**
7
- * Deeply checks if two objects are equal.
8
- *
9
- * @param expected
10
- * @param real
11
- */
12
- declare const expectToDeepEqual: <Type>(expected: Type, real: NoInfer<Type>) => void;
7
+ declare const assertNotThrowing: <T = void>(callable: () => PromiseOr<T>) => void;
13
8
 
14
9
  type RenderArguments = Parameters<typeof render>;
15
10
  type RenderHookArguments = Parameters<typeof renderHook>;
16
11
  type RenderFunc<Args extends unknown[] = RenderArguments> = (...args: Args) => void;
17
- /** Renders component and expects that it won't throw error. */
18
- declare const expectToRender: RenderFunc;
12
+ /**
13
+ * Renders component and expects that it won`t throw.
14
+ *
15
+ * @example
16
+ * test('It renders', () => {
17
+ * test('It renders', () => {
18
+ * assertRendering(<MyComponent />, {
19
+ * wrapper: RQProvider,
20
+ * });
21
+ * });
22
+ * });
23
+ *
24
+ */
25
+ declare const assertRendering: RenderFunc;
19
26
  /**
20
27
  * Renders hook within test React component without having to create that component yourself.
21
28
  * Expects that it won't throw error.
29
+ *
22
30
  * @param props
31
+ *
32
+ * @example
33
+ * test('It renders', () => {
34
+ * assertHookRendering(() => useExampleStore());
35
+ * });
36
+ */
37
+ declare const assertHookRendering: RenderFunc<RenderHookArguments>;
38
+
39
+ /**
40
+ * Mocks .env file.
41
+ *
42
+ * @param additionalMocks key-value record of env variables that also have to be mocked.
43
+ */
44
+ declare const mockEnv: (additionalMocks?: Record<string, string>) => void;
45
+
46
+ /**
47
+ * Clear all mocks from Vitest.
48
+ */
49
+ declare const clearMocks: () => void;
50
+
51
+ /**
52
+ * Mock **next/navigation** package.
53
+ */
54
+ declare const mockRouter: () => void;
55
+
56
+ declare const twApiMock: {
57
+ addBase: vitest.Mock<_vitest_spy.Procedure>;
58
+ addComponents: vitest.Mock<_vitest_spy.Procedure>;
59
+ addUtilities: vitest.Mock<_vitest_spy.Procedure>;
60
+ addVariant: vitest.Mock<_vitest_spy.Procedure>;
61
+ config: vitest.Mock<_vitest_spy.Procedure>;
62
+ corePlugins: vitest.Mock<_vitest_spy.Procedure>;
63
+ e: vitest.Mock<_vitest_spy.Procedure>;
64
+ matchComponents: vitest.Mock<_vitest_spy.Procedure>;
65
+ matchUtilities: vitest.Mock<_vitest_spy.Procedure>;
66
+ matchVariant: vitest.Mock<_vitest_spy.Procedure>;
67
+ theme: vitest.Mock<_vitest_spy.Procedure>;
68
+ };
69
+
70
+ type Caller = (...args: any[]) => void;
71
+ /**
72
+ * Creates custom spy factory object that is callable.
73
+ * @param context
74
+ * @example
75
+ * const { callSpy, expectToBeCalled, expectToBeNotCalled } =
76
+ * spyFactory('spyFactory test');
77
+ *
78
+ * // Call spy with some args
79
+ * const args: any[] = [1, 'some', 'args', 2];
80
+ * callSpy(...args);
81
+ *
82
+ * // Run expectation func
83
+ * expectToBeCalled(...args);
84
+ * expectToBeNotCalled(2, 2, 7);
23
85
  */
24
- declare const expectHookToRender: RenderFunc<RenderHookArguments>;
86
+ declare function spyFactory(context: string): {
87
+ expectToBeCalled: Caller;
88
+ expectToBeNotCalled: Caller;
89
+ spy: vitest.Mock<(...args: any[]) => void>;
90
+ callSpy: Caller;
91
+ };
25
92
 
26
- export { assertNotThrowing, expectHookToRender, expectToDeepEqual, expectToRender };
93
+ export { assertHookRendering, assertNotThrowing, assertRendering, clearMocks, mockEnv, mockRouter, spyFactory, twApiMock };
package/vitest/index.d.ts CHANGED
@@ -1,26 +1,93 @@
1
- import { renderHook, render } from '@testing-library/react';
1
+ import { P as PromiseOr } from '../shared/xenopomp-essentials.B-Vt61jj.js';
2
+ import { render, renderHook } from '@testing-library/react';
3
+ import * as vitest from 'vitest';
4
+ import * as _vitest_spy from '@vitest/spy';
2
5
 
3
6
  /** Executes function and expects that it won't throw. */
4
- declare const assertNotThrowing: (callable: () => void) => void;
5
-
6
- /**
7
- * Deeply checks if two objects are equal.
8
- *
9
- * @param expected
10
- * @param real
11
- */
12
- declare const expectToDeepEqual: <Type>(expected: Type, real: NoInfer<Type>) => void;
7
+ declare const assertNotThrowing: <T = void>(callable: () => PromiseOr<T>) => void;
13
8
 
14
9
  type RenderArguments = Parameters<typeof render>;
15
10
  type RenderHookArguments = Parameters<typeof renderHook>;
16
11
  type RenderFunc<Args extends unknown[] = RenderArguments> = (...args: Args) => void;
17
- /** Renders component and expects that it won't throw error. */
18
- declare const expectToRender: RenderFunc;
12
+ /**
13
+ * Renders component and expects that it won`t throw.
14
+ *
15
+ * @example
16
+ * test('It renders', () => {
17
+ * test('It renders', () => {
18
+ * assertRendering(<MyComponent />, {
19
+ * wrapper: RQProvider,
20
+ * });
21
+ * });
22
+ * });
23
+ *
24
+ */
25
+ declare const assertRendering: RenderFunc;
19
26
  /**
20
27
  * Renders hook within test React component without having to create that component yourself.
21
28
  * Expects that it won't throw error.
29
+ *
22
30
  * @param props
31
+ *
32
+ * @example
33
+ * test('It renders', () => {
34
+ * assertHookRendering(() => useExampleStore());
35
+ * });
36
+ */
37
+ declare const assertHookRendering: RenderFunc<RenderHookArguments>;
38
+
39
+ /**
40
+ * Mocks .env file.
41
+ *
42
+ * @param additionalMocks key-value record of env variables that also have to be mocked.
43
+ */
44
+ declare const mockEnv: (additionalMocks?: Record<string, string>) => void;
45
+
46
+ /**
47
+ * Clear all mocks from Vitest.
48
+ */
49
+ declare const clearMocks: () => void;
50
+
51
+ /**
52
+ * Mock **next/navigation** package.
53
+ */
54
+ declare const mockRouter: () => void;
55
+
56
+ declare const twApiMock: {
57
+ addBase: vitest.Mock<_vitest_spy.Procedure>;
58
+ addComponents: vitest.Mock<_vitest_spy.Procedure>;
59
+ addUtilities: vitest.Mock<_vitest_spy.Procedure>;
60
+ addVariant: vitest.Mock<_vitest_spy.Procedure>;
61
+ config: vitest.Mock<_vitest_spy.Procedure>;
62
+ corePlugins: vitest.Mock<_vitest_spy.Procedure>;
63
+ e: vitest.Mock<_vitest_spy.Procedure>;
64
+ matchComponents: vitest.Mock<_vitest_spy.Procedure>;
65
+ matchUtilities: vitest.Mock<_vitest_spy.Procedure>;
66
+ matchVariant: vitest.Mock<_vitest_spy.Procedure>;
67
+ theme: vitest.Mock<_vitest_spy.Procedure>;
68
+ };
69
+
70
+ type Caller = (...args: any[]) => void;
71
+ /**
72
+ * Creates custom spy factory object that is callable.
73
+ * @param context
74
+ * @example
75
+ * const { callSpy, expectToBeCalled, expectToBeNotCalled } =
76
+ * spyFactory('spyFactory test');
77
+ *
78
+ * // Call spy with some args
79
+ * const args: any[] = [1, 'some', 'args', 2];
80
+ * callSpy(...args);
81
+ *
82
+ * // Run expectation func
83
+ * expectToBeCalled(...args);
84
+ * expectToBeNotCalled(2, 2, 7);
23
85
  */
24
- declare const expectHookToRender: RenderFunc<RenderHookArguments>;
86
+ declare function spyFactory(context: string): {
87
+ expectToBeCalled: Caller;
88
+ expectToBeNotCalled: Caller;
89
+ spy: vitest.Mock<(...args: any[]) => void>;
90
+ callSpy: Caller;
91
+ };
25
92
 
26
- export { assertNotThrowing, expectHookToRender, expectToDeepEqual, expectToRender };
93
+ export { assertHookRendering, assertNotThrowing, assertRendering, clearMocks, mockEnv, mockRouter, spyFactory, twApiMock };
package/vitest/index.mjs CHANGED
@@ -1 +1 @@
1
- import{expect as t}from"vitest";import{render as n,renderHook as p}from"@testing-library/react";const o=e=>{t(()=>e()).not.toThrow()},c=(e,r)=>{t(e).to.deep.equal(r)},d=(...e)=>{o(()=>n(...e))},s=(...e)=>{o(()=>p(...e))};export{o as assertNotThrowing,s as expectHookToRender,c as expectToDeepEqual,d as expectToRender};
1
+ import{expect as c,vi as t}from"vitest";import{render as r,renderHook as i}from"@testing-library/react";import a from"ansi-colors";const l=e=>{c(()=>e()).not.toThrow()},u=(...e)=>{l(()=>r(...e))},d=(...e)=>{l(()=>i(...e))},f=e=>{t.stubEnv("CANONICAL_URL","http://localhost:4242"),t.stubEnv("IS_PRODUCTION","false"),e&&Object.entries(e).forEach(([n,o])=>t.stubEnv(n,o))},h=()=>{t.clearAllMocks(),t.resetAllMocks(),t.unstubAllEnvs(),t.unstubAllGlobals()},m=()=>{t.mock("next/navigation",()=>({useRouter:()=>({push(){}}),usePathname:()=>"/"}))},p={addBase:t.fn(),addComponents:t.fn(),addUtilities:t.fn(),addVariant:t.fn(),config:t.fn(),corePlugins:t.fn(),e:t.fn(),matchComponents:t.fn(),matchUtilities:t.fn(),matchVariant:t.fn(),theme:t.fn()};class C{_executionContext;constructor(n){this._executionContext=n}call(...n){console.debug(`${a.blue(`[${this._executionContext}]`)} ${a.green(`Custom spy is called with these args: ${a.blueBright(n.map(o=>`${o}`).join(", "))}`)}`)}}function x(e){const n=new C(e),o=t.spyOn(n,"call");return{expectToBeCalled:(...s)=>c(o).toHaveBeenCalledWith(s),expectToBeNotCalled:(...s)=>c(o).not.toHaveBeenCalledWith(s),spy:o,callSpy:(...s)=>n.call(s)}}export{d as assertHookRendering,l as assertNotThrowing,u as assertRendering,h as clearMocks,f as mockEnv,m as mockRouter,x as spyFactory,p as twApiMock};