@vnejs/plugins.views.screens.loading 0.1.13 → 0.1.15

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/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- import "@vnejs/plugins.views.screens.loading.contract";
1
+ import "@vnejs/contracts.views.screens.loading";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import "@vnejs/plugins.views.screens.loading.contract";
1
+ import "@vnejs/contracts.views.screens.loading";
2
2
  import { regPlugin } from "@vnejs/shared";
3
- import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.loading.contract";
3
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.screens.loading";
4
4
  import { LoadingController } from "./modules/controller.js";
5
5
  import { Loading } from "./modules/loading.js";
6
6
  import { LoadingView } from "./modules/view.js";
package/dist/types.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
- import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
3
- import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
4
- import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
5
- import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/plugins.text.locs.contract";
6
- import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.loading.contract";
2
+ import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/contracts.core.logs";
3
+ import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
4
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
5
+ import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/contracts.text.locs";
6
+ import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.screens.loading";
7
7
  export type LoadingPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<LogsPluginName, LogsSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<LocsPluginName, LocsSubscribeEvents>;
8
8
  export type LoadingPluginConstants = ModuleComponentsConstants;
9
9
  export type LoadingPluginSettings = ModuleComponentsSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.screens.loading",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "tsconfig.json"
19
19
  ],
20
20
  "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1",
21
+ "test": "npx @vnejs/monorepo test",
22
22
  "build": "npx @vnejs/monorepo package",
23
23
  "publish:major:plugin": "npm run publish:major",
24
24
  "publish:minor:plugin": "npm run publish:minor",
@@ -30,16 +30,24 @@
30
30
  "author": "",
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
- "@vnejs/plugins.views.screens.loading.contract": "~0.1.0"
33
+ "@vnejs/contracts.views.screens.loading": "~0.1.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@vnejs/module.core": "~0.1.0",
37
37
  "@vnejs/module.components": "~0.1.0",
38
- "@vnejs/plugins.text.locs.contract": "~0.1.0",
38
+ "@vnejs/contracts.text.locs": "~0.1.0",
39
39
  "@vnejs/shared": "~0.1.0",
40
40
  "@vnejs/uis.react": "~0.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@vnejs/configs.ts-common": "~0.1.0"
43
+ "@vnejs/configs.ts-common": "~0.1.0",
44
+ "@vnejs/configs.vitest": "~0.1.0",
45
+ "@vnejs/test-utils": "~0.1.0",
46
+ "@vnejs/contracts.text.locs": "~0.1.0",
47
+ "@vnejs/contracts.views.screens.loading": "~0.1.0",
48
+ "@vnejs/module.core": "~0.1.0",
49
+ "@vnejs/module.components": "~0.1.0",
50
+ "@vnejs/shared": "~0.1.0",
51
+ "@vnejs/uis.react": "~0.1.0"
44
52
  }
45
53
  }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import "@vnejs/plugins.views.screens.loading.contract";
1
+ import "@vnejs/contracts.views.screens.loading";
2
2
 
3
3
  import { regPlugin } from "@vnejs/shared";
4
- import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.loading.contract";
4
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.screens.loading";
5
5
 
6
6
  import { LoadingController } from "./modules/controller.js";
7
7
  import { Loading } from "./modules/loading.js";
@@ -0,0 +1,30 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { Loading } from "../modules/loading.js";
6
+ import { createLoadingTestModule, registerLoadingPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
7
+
8
+ describe("Loading", () => {
9
+ beforeEach(() => {
10
+ registerLoadingPluginVne();
11
+ vi.useFakeTimers();
12
+ });
13
+
14
+ it("EMIT shows, runs promise, and hides", async () => {
15
+ const { observer } = createLoadingTestModule(Loading);
16
+ const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
17
+ const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
18
+ const promiseFunc = vi.fn(async () => undefined);
19
+
20
+ const emitPromise = observer.emit(SUBSCRIBE_EVENTS.EMIT, { promiseFunc });
21
+
22
+ expect(show).toHaveBeenCalledOnce();
23
+
24
+ await vi.runAllTimersAsync();
25
+ await emitPromise;
26
+
27
+ expect(promiseFunc).toHaveBeenCalledOnce();
28
+ expect(hide).toHaveBeenCalledOnce();
29
+ });
30
+ });
@@ -0,0 +1,33 @@
1
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.screens.loading";
2
+ import {
3
+ createTestModule as baseCreateTestModule,
4
+ registerCoreVne,
5
+ registerVnePlugin,
6
+ stubSilentEvent,
7
+ } from "@vnejs/test-utils";
8
+
9
+ export const registerLoadingPluginVne = () => {
10
+ registerCoreVne();
11
+ registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS });
12
+ };
13
+
14
+ export const createLoadingTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
15
+ ModuleClass: T,
16
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
17
+ ) => {
18
+ const result = baseCreateTestModule(ModuleClass, {
19
+ state: {
20
+ loading: { isShow: false },
21
+ ...(options.state ?? {}),
22
+ },
23
+ ...options,
24
+ });
25
+
26
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.SHOW);
27
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.HIDE);
28
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE);
29
+
30
+ return result;
31
+ };
32
+
33
+ export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME };
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
- import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
3
- import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
4
- import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
5
- import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/plugins.text.locs.contract";
6
- import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.loading.contract";
2
+ import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/contracts.core.logs";
3
+ import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
4
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
5
+ import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/contracts.text.locs";
6
+ import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.screens.loading";
7
7
 
8
8
  export type LoadingPluginEvents = ModuleComponentsEvents &
9
9
  Record<PluginName, SubscribeEvents> &
package/tsconfig.json CHANGED
@@ -6,5 +6,5 @@
6
6
  "jsx": "react-jsx"
7
7
  },
8
8
  "include": ["src/**/*.ts", "src/**/*.tsx"],
9
- "exclude": ["dist", "node_modules"]
9
+ "exclude": ["dist", "node_modules", "src/tests"]
10
10
  }