@vnejs/plugins.time.time 0.2.0 → 0.2.1

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@vnejs/contracts.time.time";
2
2
  import { regPlugin } from "@vnejs/shared";
3
3
  import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.time.time";
4
- import { TimeModule } from "./modules/time.js";
5
- regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS }, [TimeModule]);
4
+ import { Time } from "./modules/time.js";
5
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS }, [Time]);
@@ -2,7 +2,7 @@ import { ModuleCore } from "@vnejs/module.core";
2
2
  import type { LineExecHandlerArg } from "@vnejs/module.core";
3
3
  import type { TimePluginConstants, TimePluginEvents, TimePluginParams, TimePluginSettings } from "../types.js";
4
4
  import type { TimeState, TimeValuePayload } from "../utils/time.js";
5
- export declare class TimeModule extends ModuleCore<TimePluginEvents, TimePluginConstants, TimePluginSettings, TimePluginParams, TimeState> {
5
+ export declare class Time extends ModuleCore<TimePluginEvents, TimePluginConstants, TimePluginSettings, TimePluginParams, TimeState> {
6
6
  name: string;
7
7
  subscribe: () => void;
8
8
  init: () => Promise<unknown[]> | undefined;
@@ -1,6 +1,6 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
  import { tokenizeExecLine } from "@vnejs/helpers";
3
- export class TimeModule extends ModuleCore {
3
+ export class Time extends ModuleCore {
4
4
  name = "time";
5
5
  subscribe = () => {
6
6
  this.on(this.EVENTS.TIME.SET, this.onTimeSet);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.time.time",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -3,6 +3,6 @@ import "@vnejs/contracts.time.time";
3
3
  import { regPlugin } from "@vnejs/shared";
4
4
  import { CONSTANTS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.time.time";
5
5
 
6
- import { TimeModule } from "./modules/time.js";
6
+ import { Time } from "./modules/time.js";
7
7
 
8
- regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS }, [TimeModule]);
8
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS }, [Time]);
@@ -6,7 +6,7 @@ import type { LineExecHandlerArg } from "@vnejs/module.core";
6
6
  import type { TimePluginConstants, TimePluginEvents, TimePluginParams, TimePluginSettings } from "../types.js";
7
7
  import type { TimeState, TimeValuePayload } from "../utils/time.js";
8
8
 
9
- export class TimeModule extends ModuleCore<TimePluginEvents, TimePluginConstants, TimePluginSettings, TimePluginParams, TimeState> {
9
+ export class Time extends ModuleCore<TimePluginEvents, TimePluginConstants, TimePluginSettings, TimePluginParams, TimeState> {
10
10
  name = "time";
11
11
 
12
12
  subscribe = () => {
@@ -3,54 +3,54 @@ import { beforeEach, describe, expect, it } from "vitest";
3
3
  import { SUBSCRIBE_EVENTS as SCENARIO_EVENTS } from "@vnejs/contracts.core.scenario";
4
4
  import { spyEvent } from "@vnejs/test-utils";
5
5
 
6
- import { TimeModule } from "../modules/time.js";
6
+ import { Time } from "../modules/time.js";
7
7
  import { CONSTANTS, createTimeTestModule, registerTimePluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
8
8
 
9
- describe("TimeModule", () => {
9
+ describe("Time", () => {
10
10
  beforeEach(() => {
11
11
  registerTimePluginVne();
12
12
  });
13
13
 
14
14
  it("SET replaces time state and emits CHANGED", async () => {
15
- const { module, observer } = createTimeTestModule(TimeModule);
15
+ const { module, observer } = createTimeTestModule(Time);
16
16
  const changed = spyEvent(observer, SUBSCRIBE_EVENTS.CHANGED);
17
17
 
18
18
  await observer.emit(SUBSCRIBE_EVENTS.SET, { hours: 10, minutes: 30, seconds: 15 });
19
19
 
20
- expect((module as TimeModule).state).toEqual({ hours: 10, minutes: 30, seconds: 15 });
20
+ expect((module as Time).state).toEqual({ hours: 10, minutes: 30, seconds: 15 });
21
21
  expect(changed).toHaveBeenCalledOnce();
22
22
  });
23
23
 
24
24
  it("ADD carries seconds and minutes", async () => {
25
- const { module, observer } = createTimeTestModule(TimeModule);
25
+ const { module, observer } = createTimeTestModule(Time);
26
26
 
27
- (module as TimeModule).setState({ hours: 1, minutes: 59, seconds: 50 });
27
+ (module as Time).setState({ hours: 1, minutes: 59, seconds: 50 });
28
28
 
29
29
  await observer.emit(SUBSCRIBE_EVENTS.ADD, { hours: 0, minutes: 0, seconds: 20 });
30
30
 
31
- expect((module as TimeModule).state).toEqual({ hours: 2, minutes: 0, seconds: 10 });
31
+ expect((module as Time).state).toEqual({ hours: 2, minutes: 0, seconds: 10 });
32
32
  });
33
33
 
34
34
  it("ADD emits ROLLOVER when hours reach 24", async () => {
35
- const { module, observer } = createTimeTestModule(TimeModule);
35
+ const { module, observer } = createTimeTestModule(Time);
36
36
  const rollover = spyEvent(observer, SUBSCRIBE_EVENTS.ROLLOVER);
37
37
 
38
- (module as TimeModule).setState({ hours: 23, minutes: 0, seconds: 0 });
38
+ (module as Time).setState({ hours: 23, minutes: 0, seconds: 0 });
39
39
 
40
40
  await observer.emit(SUBSCRIBE_EVENTS.ADD, { hours: 2, minutes: 0, seconds: 0 });
41
41
 
42
42
  expect(rollover).toHaveBeenCalledExactlyOnceWith({ count: 1 });
43
- expect((module as TimeModule).state.hours).toBe(1);
43
+ expect((module as Time).state.hours).toBe(1);
44
44
  });
45
45
 
46
46
  it("onLineExec routes set action and emits NEXT", async () => {
47
- const { module, observer } = createTimeTestModule(TimeModule);
47
+ const { module, observer } = createTimeTestModule(Time);
48
48
  const next = spyEvent(observer, SCENARIO_EVENTS.NEXT);
49
49
 
50
- await (module as TimeModule).init();
51
- await (module as TimeModule).onLineExec({ line: `${CONSTANTS.ACTIONS.SET} 5 10 0` });
50
+ await (module as Time).init();
51
+ await (module as Time).onLineExec({ line: `${CONSTANTS.ACTIONS.SET} 5 10 0` });
52
52
 
53
- expect((module as TimeModule).state).toEqual({ hours: 5, minutes: 10, seconds: 0 });
53
+ expect((module as Time).state).toEqual({ hours: 5, minutes: 10, seconds: 0 });
54
54
  expect(next).toHaveBeenCalledOnce();
55
55
  });
56
56
  });