@vnejs/plugins.scenario.point_and_click 0.2.5 → 0.2.7
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/modules/emit.js
CHANGED
|
@@ -14,8 +14,8 @@ export class PointAndClickEmit extends ModuleCore {
|
|
|
14
14
|
return this.emit(this.EVENTS.POINT_AND_CLICK.SHOW);
|
|
15
15
|
};
|
|
16
16
|
mapOptions = async ({ optionLine: { line = "", args = {} }, index }) => {
|
|
17
|
-
const [, , icon, x, y] = tokenizeExecLine(line).map(String);
|
|
18
|
-
const result = { index, coords: [x, y].map(Number), icon, ...args };
|
|
17
|
+
const [, , icon, iconHover, x, y] = tokenizeExecLine(line).map(String);
|
|
18
|
+
const result = { index, coords: [x, y].map(Number), icon, iconHover, ...args };
|
|
19
19
|
await Promise.all(Object.keys(args).map(async (key) => {
|
|
20
20
|
if (typeof args[key] !== "string" || !args[key].startsWith(this.CONST.SCENARIO.LINE_PREFIXES.MODULE))
|
|
21
21
|
return;
|
package/package.json
CHANGED
package/src/modules/emit.ts
CHANGED
|
@@ -29,8 +29,8 @@ export class PointAndClickEmit extends ModuleCore<
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
mapOptions = async ({ optionLine: { line = "", args = {} }, index }: NonNullable<PointAndClickEmitPayload["options"]>[number]) => {
|
|
32
|
-
const [, , icon, x, y] = tokenizeExecLine(line).map(String);
|
|
33
|
-
const result: PointAndClickOption = { index, coords: [x, y].map(Number), icon, ...args };
|
|
32
|
+
const [, , icon, iconHover, x, y] = tokenizeExecLine(line).map(String);
|
|
33
|
+
const result: PointAndClickOption = { index, coords: [x, y].map(Number), icon, iconHover, ...args };
|
|
34
34
|
|
|
35
35
|
await Promise.all(
|
|
36
36
|
Object.keys(args).map(async (key) => {
|
package/src/tests/logs.test.ts
CHANGED
|
@@ -14,7 +14,7 @@ describe("PointAndClickLogs", () => {
|
|
|
14
14
|
it("EMIT emits LOGS.EMIT with emit action", async () => {
|
|
15
15
|
const { observer } = createPointAndClickTestModule(PointAndClickLogs);
|
|
16
16
|
const logs = spyEvent(observer, LOGS_EVENTS.EMIT);
|
|
17
|
-
const options = [{ index: 0, optionLine: { line: "% point-and-click.option star 1 2", args: {} } }];
|
|
17
|
+
const options = [{ index: 0, optionLine: { line: "% point-and-click.option star star-hover 1 2", args: {} } }];
|
|
18
18
|
|
|
19
19
|
await observer.emit(SUBSCRIBE_EVENTS.EMIT, { options, args: { a: 1 } });
|
|
20
20
|
|
|
@@ -30,15 +30,36 @@ describe("PointAndClick flow", () => {
|
|
|
30
30
|
const skip = spyEvent(observer, SUBSCRIBE_EVENTS.SKIP);
|
|
31
31
|
|
|
32
32
|
await observer.emit(SUBSCRIBE_EVENTS.EMIT, {
|
|
33
|
-
options: [{ index: 0, optionLine: { line: "% point-and-click.option star 100 200", args: {} } }],
|
|
33
|
+
options: [{ index: 0, optionLine: { line: "% point-and-click.option star star-hover 100 200", args: {} } }],
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
expect(stateModule.state.isShow).toBe(true);
|
|
37
|
-
expect(stateModule.state.options[0]).toMatchObject({ index: 0, icon: "star", coords: [100, 200] });
|
|
37
|
+
expect(stateModule.state.options[0]).toMatchObject({ index: 0, icon: "star", iconHover: "star-hover", coords: [100, 200] });
|
|
38
38
|
expect(show).toHaveBeenCalledOnce();
|
|
39
39
|
expect(skip).not.toHaveBeenCalled();
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
it("EMIT forwards imgWidth and imgHeight args onto the option", async () => {
|
|
43
|
+
const { stateModule, observer } = createPointAndClickFlowModules();
|
|
44
|
+
|
|
45
|
+
await observer.emit(SUBSCRIBE_EVENTS.EMIT, {
|
|
46
|
+
options: [
|
|
47
|
+
{
|
|
48
|
+
index: 0,
|
|
49
|
+
optionLine: { line: "% point-and-click.option star star-hover 100 200", args: { imgWidth: 60, imgHeight: 60 } },
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(stateModule.state.options[0]).toMatchObject({
|
|
55
|
+
icon: "star",
|
|
56
|
+
iconHover: "star-hover",
|
|
57
|
+
coords: [100, 200],
|
|
58
|
+
imgWidth: 60,
|
|
59
|
+
imgHeight: 60,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
42
63
|
it("EMIT with all hided options emits SKIP and advances past the block", async () => {
|
|
43
64
|
const { stateModule, observer, state } = createPointAndClickFlowModules();
|
|
44
65
|
const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
|
|
@@ -46,7 +67,7 @@ describe("PointAndClick flow", () => {
|
|
|
46
67
|
const next = spyEvent(observer, SCENARIO_EVENTS.NEXT);
|
|
47
68
|
const lines = [
|
|
48
69
|
{ line: "% point-and-click", indent: 0 },
|
|
49
|
-
{ line: "% point-and-click.option star 100 200", indent: 2 },
|
|
70
|
+
{ line: "% point-and-click.option star star-hover 100 200", indent: 2 },
|
|
50
71
|
{ line: '"after"', indent: 0 },
|
|
51
72
|
];
|
|
52
73
|
|
|
@@ -54,7 +75,7 @@ describe("PointAndClick flow", () => {
|
|
|
54
75
|
state.scenario.curLine = 0;
|
|
55
76
|
|
|
56
77
|
await observer.emit(SUBSCRIBE_EVENTS.EMIT, {
|
|
57
|
-
options: [{ index: 1, optionLine: { line: "% point-and-click.option star 100 200", args: { hided: true } } }],
|
|
78
|
+
options: [{ index: 1, optionLine: { line: "% point-and-click.option star star-hover 100 200", args: { hided: true } } }],
|
|
58
79
|
});
|
|
59
80
|
|
|
60
81
|
expect(skip).toHaveBeenCalledOnce();
|
|
@@ -88,7 +109,7 @@ describe("PointAndClick flow", () => {
|
|
|
88
109
|
const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
|
|
89
110
|
|
|
90
111
|
stateModule.setState({
|
|
91
|
-
options: [{ index: 3, icon: "star", coords: [0, 0] }],
|
|
112
|
+
options: [{ index: 3, icon: "star", iconHover: "star-hover", coords: [0, 0] }],
|
|
92
113
|
args: {},
|
|
93
114
|
isShow: true,
|
|
94
115
|
});
|
|
@@ -28,7 +28,7 @@ describe("PointAndClickScenario", () => {
|
|
|
28
28
|
const emit = spyEvent(observer, SUBSCRIBE_EVENTS.EMIT);
|
|
29
29
|
const lines = [
|
|
30
30
|
{ line: "point-and-click", indent: 0 },
|
|
31
|
-
{ line: "% point-and-click.option star 10 20", indent: 2 },
|
|
31
|
+
{ line: "% point-and-click.option star star-hover 10 20", indent: 2 },
|
|
32
32
|
];
|
|
33
33
|
|
|
34
34
|
observer.subscribe(SCENARIO_EVENTS.LINES_GET, () => lines);
|
|
@@ -78,7 +78,7 @@ describe("PointAndClickScenarioModule", () => {
|
|
|
78
78
|
const next = spyEvent(observer, SCENARIO_EVENTS.NEXT);
|
|
79
79
|
const lines = [
|
|
80
80
|
{ line: "% point-and-click", indent: 0 },
|
|
81
|
-
{ line: "% point-and-click.option star 10 20", indent: 2 },
|
|
81
|
+
{ line: "% point-and-click.option star star-hover 10 20", indent: 2 },
|
|
82
82
|
{ line: '"text"', indent: 2 },
|
|
83
83
|
{ line: "$ point-and-click repeat", indent: 2 },
|
|
84
84
|
];
|