@vnejs/plugins.vars.counters 0.1.18 → 0.1.20

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.vars.counters.contract";
1
+ import "@vnejs/contracts.vars.counters";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import "@vnejs/plugins.vars.counters.contract";
1
+ import "@vnejs/contracts.vars.counters";
2
2
  import { regPlugin } from "@vnejs/shared";
3
- import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.vars.counters.contract";
3
+ import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.vars.counters";
4
4
  import { Counters } from "./modules/counters.js";
5
5
  import { CountersExec } from "./modules/exec.js";
6
6
  regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS }, [Counters, CountersExec]);
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
- import type { PluginName as VarsPluginName, SubscribeEvents as VarsSubscribeEvents } from "@vnejs/plugins.vars.contract";
3
- import type { Constants, PluginName, SubscribeEvents } from "@vnejs/plugins.vars.counters.contract";
2
+ import type { PluginName as VarsPluginName, SubscribeEvents as VarsSubscribeEvents } from "@vnejs/contracts.vars";
3
+ import type { Constants, PluginName, SubscribeEvents } from "@vnejs/contracts.vars.counters";
4
4
  export type CountersPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents> & Record<VarsPluginName, VarsSubscribeEvents>;
5
5
  export type CountersPluginConstants = ModuleCoreConstants & Record<PluginName, Constants>;
6
6
  export type CountersPluginSettings = ModuleCoreSettings;
@@ -1,5 +1,5 @@
1
1
  import type { ModuleGlobalStateRegistry } from "@vnejs/module.core";
2
- import type { VarValue, VarsGetPayload } from "@vnejs/plugins.vars.contract";
2
+ import type { VarValue, VarsGetPayload } from "@vnejs/contracts.vars";
3
3
  export type CountersSetPayload = {
4
4
  name?: string;
5
5
  isGlobal?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.vars.counters",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
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,15 +30,18 @@
30
30
  "author": "",
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
- "@vnejs/plugins.vars.counters.contract": "~0.1.0"
33
+ "@vnejs/contracts.vars.counters": "~0.1.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@vnejs/helpers": "~0.1.0",
37
37
  "@vnejs/module.core": "~0.1.0",
38
- "@vnejs/plugins.vars.contract": "~0.1.0",
38
+ "@vnejs/contracts.vars": "~0.1.0",
39
39
  "@vnejs/shared": "~0.1.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@vnejs/configs.ts-common": "~0.1.0"
42
+ "@vnejs/configs.ts-common": "~0.1.0",
43
+ "@vnejs/configs.vitest": "~0.1.0",
44
+ "@vnejs/test-utils": "~0.1.0",
45
+ "@vnejs/contracts.vars": "~0.1.0"
43
46
  }
44
47
  }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import "@vnejs/plugins.vars.counters.contract";
1
+ import "@vnejs/contracts.vars.counters";
2
2
 
3
3
  import { regPlugin } from "@vnejs/shared";
4
- import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.vars.counters.contract";
4
+ import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.vars.counters";
5
5
 
6
6
  import { Counters } from "./modules/counters.js";
7
7
  import { CountersExec } from "./modules/exec.js";
@@ -0,0 +1,46 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { SUBSCRIBE_EVENTS as VARS_EVENTS } from "@vnejs/contracts.vars";
4
+ import { spyEvent } from "@vnejs/test-utils";
5
+
6
+ import { Counters } from "../modules/counters.js";
7
+ import { CONSTANTS, createCountersTestModule, registerCountersPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
8
+
9
+ describe("Counters", () => {
10
+ beforeEach(() => {
11
+ registerCountersPluginVne();
12
+ });
13
+
14
+ it("CHANGE applies increment action", async () => {
15
+ const { observer } = createCountersTestModule(Counters);
16
+
17
+ const [result] = await observer.emit(SUBSCRIBE_EVENTS.CHANGE, {
18
+ value: 5,
19
+ execValue: 0,
20
+ action: CONSTANTS.CHANGE_ACTIONS.INC,
21
+ });
22
+
23
+ expect(result).toBe(6);
24
+ });
25
+
26
+ it("COMPARE uses configured comparator", async () => {
27
+ const { observer } = createCountersTestModule(Counters);
28
+
29
+ const [result] = await observer.emit(SUBSCRIBE_EVENTS.COMPARE, {
30
+ value: 10,
31
+ execValue: 5,
32
+ action: CONSTANTS.COMPARE_ACTIONS.MORE,
33
+ });
34
+
35
+ expect(result).toBe(true);
36
+ });
37
+
38
+ it("SET delegates to VARS.SET with counter type", async () => {
39
+ const { observer } = createCountersTestModule(Counters);
40
+ const set = spyEvent(observer, VARS_EVENTS.SET);
41
+
42
+ await observer.emit(SUBSCRIBE_EVENTS.SET, { name: "gold", value: 3 });
43
+
44
+ expect(set).toHaveBeenCalledExactlyOnceWith({ name: "gold", type: CONSTANTS.TYPE, value: 3, isGlobal: false });
45
+ });
46
+ });
@@ -0,0 +1,11 @@
1
+ import { CONSTANTS as VARS_CONST, PLUGIN_NAME as VARS, SUBSCRIBE_EVENTS as VARS_EVENTS } from "@vnejs/contracts.vars";
2
+ import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.vars.counters";
3
+ import { createTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
4
+
5
+ export const registerCountersPluginVne = () => {
6
+ registerCoreVne();
7
+ registerVnePlugin(VARS, { events: VARS_EVENTS });
8
+ registerVnePlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS });
9
+ };
10
+
11
+ export { createTestModule as createCountersTestModule, SUBSCRIBE_EVENTS, CONSTANTS, VARS_EVENTS, PLUGIN_NAME };
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
- import type { PluginName as VarsPluginName, SubscribeEvents as VarsSubscribeEvents } from "@vnejs/plugins.vars.contract";
3
- import type { Constants, PluginName, SubscribeEvents } from "@vnejs/plugins.vars.counters.contract";
2
+ import type { PluginName as VarsPluginName, SubscribeEvents as VarsSubscribeEvents } from "@vnejs/contracts.vars";
3
+ import type { Constants, PluginName, SubscribeEvents } from "@vnejs/contracts.vars.counters";
4
4
 
5
5
  export type CountersPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents> & Record<VarsPluginName, VarsSubscribeEvents>;
6
6
 
@@ -1,5 +1,5 @@
1
1
  import type { ModuleGlobalStateRegistry } from "@vnejs/module.core";
2
- import type { VarValue, VarsGetPayload } from "@vnejs/plugins.vars.contract";
2
+ import type { VarValue, VarsGetPayload } from "@vnejs/contracts.vars";
3
3
 
4
4
  export type CountersSetPayload = {
5
5
  name?: string;
package/tsconfig.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "outDir": "dist"
6
6
  },
7
7
  "include": ["src/**/*.ts"],
8
- "exclude": ["dist", "node_modules"]
8
+ "exclude": ["dist", "node_modules", "src/tests"]
9
9
  }