@axiapps/gw2-data 0.1.1 → 0.1.2
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/data/overrides.json +24 -0
- package/package.json +3 -1
- package/src/engine/attributes.js +102 -23
- package/src/engine/boons.js +19 -1
- package/src/engine/constants.js +27 -2
- package/src/engine/index.js +4 -4
- package/src/engine/modifiers.js +57 -21
- package/src/wiki/parser.js +17 -9
- package/scripts/generate-fixtures.js +0 -242
- package/tests/api-client.test.js +0 -138
- package/tests/cache.test.js +0 -108
- package/tests/engine/attributes.test.js +0 -252
- package/tests/engine/boons.test.js +0 -129
- package/tests/engine/combos.test.js +0 -76
- package/tests/engine/constants.test.js +0 -576
- package/tests/engine/fixtures/berserker-thief.json +0 -61
- package/tests/engine/fixtures/berserker-warrior.json +0 -113
- package/tests/engine/fixtures/celestial-firebrand-wvw.json +0 -94
- package/tests/engine/fixtures/harrier-druid.json +0 -119
- package/tests/engine/fixtures/viper-mirage.json +0 -104
- package/tests/engine/graph.test.js +0 -30
- package/tests/engine/integration.test.js +0 -111
- package/tests/engine/modifiers.test.js +0 -473
- package/tests/engine/overrides.test.js +0 -70
- package/tests/engine/snapshot.test.js +0 -53
- package/tests/engine/test-utils.js +0 -20
- package/tests/engine/tooltips.test.js +0 -62
- package/tests/fixtures/capture.js +0 -160
- package/tests/fixtures/fixtures.json +0 -839
- package/tests/integration.test.js +0 -100
- package/tests/match.test.js +0 -176
- package/tests/merge.test.js +0 -128
- package/tests/normalize.test.js +0 -78
- package/tests/parser.test.js +0 -506
- package/tests/real-data.test.js +0 -296
- package/tests/relations.test.js +0 -80
- package/tests/resolver.test.js +0 -721
- package/tests/validate-live.js +0 -191
- package/tests/wiki-client.test.js +0 -468
- package/tests/wiki-integration.test.js +0 -177
- package/tests/wiki-live-validation.test.js +0 -61
- package/tests/wiki-snapshots.test.js +0 -166
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { WikiClient } = require("../src/wiki/client");
|
|
4
|
-
const { mergeFacts } = require("../src/facts/merge");
|
|
5
|
-
const { MemoryCache } = require("../src/wiki/cache");
|
|
6
|
-
|
|
7
|
-
describe("End-to-end fact resolution", () => {
|
|
8
|
-
test("resolves WvW facts for a skill with balance split", () => {
|
|
9
|
-
// Simulate: Fireball has different damage in WvW
|
|
10
|
-
const wikitext = [
|
|
11
|
-
"{{skill infobox",
|
|
12
|
-
"| id = 5489",
|
|
13
|
-
"| name = Fireball",
|
|
14
|
-
"| split = pve, wvw, pvp",
|
|
15
|
-
"}}",
|
|
16
|
-
"{{skill fact|damage|1.2|game mode=pve}}",
|
|
17
|
-
"{{skill fact|damage|0.8|game mode=wvw}}",
|
|
18
|
-
"{{skill fact|recharge|10}}",
|
|
19
|
-
"{{skill fact|burning|3|stacks=2|game mode=wvw}}",
|
|
20
|
-
].join("\n");
|
|
21
|
-
|
|
22
|
-
// API base facts (PvE values)
|
|
23
|
-
const apiFacts = [
|
|
24
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.2, hit_count: 1 },
|
|
25
|
-
{ type: "Recharge", text: "Recharge", value: 10 },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
// Parse wiki facts
|
|
29
|
-
const client = new WikiClient({ cache: new MemoryCache() });
|
|
30
|
-
const parsed = client.parseFacts(wikitext);
|
|
31
|
-
|
|
32
|
-
expect(parsed.splitGrouping.wvwHasSplit).toBe(true);
|
|
33
|
-
|
|
34
|
-
// Merge API + wiki
|
|
35
|
-
const resolved = mergeFacts(apiFacts, parsed.facts, { complete: false });
|
|
36
|
-
|
|
37
|
-
// Damage should use WvW value
|
|
38
|
-
const damageFact = resolved.find((f) => f.type === "Damage");
|
|
39
|
-
expect(damageFact.dmg_multiplier).toBe(0.8);
|
|
40
|
-
expect(damageFact._splitFact).toBe(true);
|
|
41
|
-
expect(damageFact.text).toBe("Damage"); // Preserves API label
|
|
42
|
-
|
|
43
|
-
// Recharge should be unchanged (universal fact)
|
|
44
|
-
const rechargeFact = resolved.find((f) => f.type === "Recharge");
|
|
45
|
-
expect(rechargeFact.value).toBe(10);
|
|
46
|
-
|
|
47
|
-
// Burning is a new WvW-only fact
|
|
48
|
-
const burnFact = resolved.find((f) => f.status === "Burning");
|
|
49
|
-
expect(burnFact).toBeTruthy();
|
|
50
|
-
expect(burnFact._newFact).toBe(true);
|
|
51
|
-
expect(burnFact.duration).toBe(3);
|
|
52
|
-
expect(burnFact.apply_count).toBe(2);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("resolves facts for skill with WvW grouped with PvP", () => {
|
|
56
|
-
const wikitext = [
|
|
57
|
-
"{{skill infobox",
|
|
58
|
-
"| split = pve, wvw pvp",
|
|
59
|
-
"}}",
|
|
60
|
-
"{{skill fact|damage|0.6|game mode=pvp}}",
|
|
61
|
-
"{{skill fact|damage|1.0|game mode=pve}}",
|
|
62
|
-
].join("\n");
|
|
63
|
-
|
|
64
|
-
const apiFacts = [
|
|
65
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0, hit_count: 1 },
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
const client = new WikiClient({ cache: new MemoryCache() });
|
|
69
|
-
const parsed = client.parseFacts(wikitext);
|
|
70
|
-
|
|
71
|
-
expect(parsed.splitGrouping.wvwGroupedWithPvp).toBe(true);
|
|
72
|
-
|
|
73
|
-
const resolved = mergeFacts(apiFacts, parsed.facts, { complete: false });
|
|
74
|
-
const damageFact = resolved.find((f) => f.type === "Damage");
|
|
75
|
-
expect(damageFact.dmg_multiplier).toBe(0.6); // Uses PvP value for WvW
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("handles skill with no balance split (PvE only)", () => {
|
|
79
|
-
const wikitext = [
|
|
80
|
-
"{{skill infobox",
|
|
81
|
-
"| id = 9999",
|
|
82
|
-
"}}",
|
|
83
|
-
"{{skill fact|damage|1.5}}",
|
|
84
|
-
].join("\n");
|
|
85
|
-
|
|
86
|
-
const apiFacts = [
|
|
87
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.5, hit_count: 1 },
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
const client = new WikiClient({ cache: new MemoryCache() });
|
|
91
|
-
const parsed = client.parseFacts(wikitext);
|
|
92
|
-
|
|
93
|
-
expect(parsed.splitGrouping).toBeNull();
|
|
94
|
-
|
|
95
|
-
// No split — merge with universal facts
|
|
96
|
-
const resolved = mergeFacts(apiFacts, parsed.facts, { complete: false });
|
|
97
|
-
expect(resolved).toHaveLength(1);
|
|
98
|
-
expect(resolved[0].dmg_multiplier).toBe(1.5);
|
|
99
|
-
});
|
|
100
|
-
});
|
package/tests/match.test.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
buildMatchTables,
|
|
5
|
-
splitGroupKey,
|
|
6
|
-
valueChanged,
|
|
7
|
-
VALUE_KEYS,
|
|
8
|
-
} = require("../src/facts/match");
|
|
9
|
-
|
|
10
|
-
describe("splitGroupKey", () => {
|
|
11
|
-
test("uses normalized type and target for AttributeAdjust", () => {
|
|
12
|
-
expect(splitGroupKey({ type: "AttributeAdjust", target: "Power" })).toBe(
|
|
13
|
-
"AttributeAdjust:Power"
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("uses normalized type and status for Buff", () => {
|
|
18
|
-
expect(splitGroupKey({ type: "Buff", status: "Might" })).toBe("Buff:Might");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("normalizes Distance to Radius", () => {
|
|
22
|
-
expect(splitGroupKey({ type: "Distance", distance: 240 })).toBe("Radius:");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("uses empty string when no target/status", () => {
|
|
26
|
-
expect(splitGroupKey({ type: "Damage" })).toBe("Damage:");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("valueChanged", () => {
|
|
31
|
-
test("returns false when values are identical", () => {
|
|
32
|
-
const a = { type: "Damage", dmg_multiplier: 1.0, hit_count: 1 };
|
|
33
|
-
const b = { type: "Damage", dmg_multiplier: 1.0, hit_count: 1 };
|
|
34
|
-
expect(valueChanged(a, b)).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("returns true when dmg_multiplier differs", () => {
|
|
38
|
-
const a = { type: "Damage", dmg_multiplier: 1.0 };
|
|
39
|
-
const b = { type: "Damage", dmg_multiplier: 0.5 };
|
|
40
|
-
expect(valueChanged(a, b)).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("returns true when duration differs", () => {
|
|
44
|
-
const a = { type: "Buff", status: "Might", duration: 5 };
|
|
45
|
-
const b = { type: "Buff", status: "Might", duration: 3 };
|
|
46
|
-
expect(valueChanged(a, b)).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("ignores hit_count if base does not have it", () => {
|
|
50
|
-
const a = { type: "Damage", dmg_multiplier: 1.0 };
|
|
51
|
-
const b = { type: "Damage", dmg_multiplier: 1.0, hit_count: 1 };
|
|
52
|
-
expect(valueChanged(a, b)).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("detects hit_count change when base has it", () => {
|
|
56
|
-
const a = { type: "Damage", dmg_multiplier: 1.0, hit_count: 1 };
|
|
57
|
-
const b = { type: "Damage", dmg_multiplier: 1.0, hit_count: 3 };
|
|
58
|
-
expect(valueChanged(a, b)).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("detects apply_count change", () => {
|
|
62
|
-
const a = { type: "Buff", status: "Might", apply_count: 1 };
|
|
63
|
-
const b = { type: "Buff", status: "Might", apply_count: 3 };
|
|
64
|
-
expect(valueChanged(a, b)).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test("detects percent change", () => {
|
|
68
|
-
const a = { type: "Percent", percent: 10 };
|
|
69
|
-
const b = { type: "Percent", percent: 20 };
|
|
70
|
-
expect(valueChanged(a, b)).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("returns false when all VALUE_KEYS match", () => {
|
|
74
|
-
const a = { type: "Buff", status: "Might", duration: 5, apply_count: 2, value: 0 };
|
|
75
|
-
const b = { type: "Buff", status: "Might", duration: 5, apply_count: 2, value: 0 };
|
|
76
|
-
expect(valueChanged(a, b)).toBe(false);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe("buildMatchTables", () => {
|
|
81
|
-
test("pass 1: matches by exact text and type", () => {
|
|
82
|
-
const base = [
|
|
83
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
84
|
-
{ type: "Buff", text: "Might", status: "Might", duration: 5 },
|
|
85
|
-
];
|
|
86
|
-
const split = [
|
|
87
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5 },
|
|
88
|
-
{ type: "Buff", text: "Might", status: "Might", duration: 3 },
|
|
89
|
-
];
|
|
90
|
-
const { baseToSplit, splitToBase } = buildMatchTables(base, split);
|
|
91
|
-
expect(baseToSplit.get(0)).toBe(0);
|
|
92
|
-
expect(baseToSplit.get(1)).toBe(1);
|
|
93
|
-
expect(splitToBase.get(0)).toBe(0);
|
|
94
|
-
expect(splitToBase.get(1)).toBe(1);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("pass 1.5: matches by exact text across different types", () => {
|
|
98
|
-
const base = [{ type: "Number", text: "Maximum Count", value: 3 }];
|
|
99
|
-
const split = [{ type: "Buff", text: "Maximum Count", value: 2 }];
|
|
100
|
-
const { baseToSplit } = buildMatchTables(base, split);
|
|
101
|
-
expect(baseToSplit.get(0)).toBe(0);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test("pass 2: positional match within same type group", () => {
|
|
105
|
-
const base = [
|
|
106
|
-
{ type: "AttributeAdjust", text: "Healing", target: "Healing", value: 500 },
|
|
107
|
-
{ type: "AttributeAdjust", text: "Barrier", target: "Healing", value: 300 },
|
|
108
|
-
];
|
|
109
|
-
const split = [
|
|
110
|
-
{ type: "AttributeAdjust", text: "Healing", target: "Healing", value: 400 },
|
|
111
|
-
{ type: "AttributeAdjust", text: "Barrier Strength", target: "Healing", value: 200 },
|
|
112
|
-
];
|
|
113
|
-
const { baseToSplit } = buildMatchTables(base, split);
|
|
114
|
-
expect(baseToSplit.get(0)).toBe(0);
|
|
115
|
-
expect(baseToSplit.get(1)).toBe(1);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test("pass 3: keyword overlap match", () => {
|
|
119
|
-
const base = [
|
|
120
|
-
{ type: "Buff", text: "Conditions Removed", status: "Conditions Removed", value: 3 },
|
|
121
|
-
];
|
|
122
|
-
const split = [
|
|
123
|
-
{ type: "Number", text: "Conditions Successfully Removed", value: 2 },
|
|
124
|
-
];
|
|
125
|
-
const { baseToSplit } = buildMatchTables(base, split);
|
|
126
|
-
expect(baseToSplit.get(0)).toBe(0);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test("returns empty maps when no matches", () => {
|
|
130
|
-
const base = [{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 }];
|
|
131
|
-
const split = [{ type: "Buff", text: "Fury", status: "Fury", duration: 5 }];
|
|
132
|
-
const { baseToSplit, splitToBase } = buildMatchTables(base, split);
|
|
133
|
-
expect(baseToSplit.size).toBe(0);
|
|
134
|
-
expect(splitToBase.size).toBe(0);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test("prevents double-matching", () => {
|
|
138
|
-
const base = [
|
|
139
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
140
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.8 },
|
|
141
|
-
];
|
|
142
|
-
const split = [
|
|
143
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5 },
|
|
144
|
-
];
|
|
145
|
-
const { baseToSplit } = buildMatchTables(base, split);
|
|
146
|
-
expect(baseToSplit.size).toBe(1);
|
|
147
|
-
expect(baseToSplit.get(0)).toBe(0);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test("pass 3: does not match when keywords have no overlap", () => {
|
|
151
|
-
const base = [
|
|
152
|
-
{ type: "Number", text: "Maximum Count", value: 3 },
|
|
153
|
-
];
|
|
154
|
-
const split = [
|
|
155
|
-
{ type: "Buff", text: "Fury Duration Increase", status: "Fury", duration: 5 },
|
|
156
|
-
];
|
|
157
|
-
const { baseToSplit } = buildMatchTables(base, split);
|
|
158
|
-
expect(baseToSplit.size).toBe(0);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test("pass 2: positional match within group when texts differ", () => {
|
|
162
|
-
// Two Damage facts with different text but same group key
|
|
163
|
-
const base = [
|
|
164
|
-
{ type: "Damage", text: "Initial Hit", dmg_multiplier: 1.0 },
|
|
165
|
-
{ type: "Damage", text: "Final Hit", dmg_multiplier: 2.0 },
|
|
166
|
-
];
|
|
167
|
-
const split = [
|
|
168
|
-
{ type: "Damage", text: "First Strike", dmg_multiplier: 0.5 },
|
|
169
|
-
{ type: "Damage", text: "Last Strike", dmg_multiplier: 1.0 },
|
|
170
|
-
];
|
|
171
|
-
const { baseToSplit } = buildMatchTables(base, split);
|
|
172
|
-
// Positional: base[0]→split[0], base[1]→split[1]
|
|
173
|
-
expect(baseToSplit.get(0)).toBe(0);
|
|
174
|
-
expect(baseToSplit.get(1)).toBe(1);
|
|
175
|
-
});
|
|
176
|
-
});
|
package/tests/merge.test.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { mergeFacts } = require("../src/facts/merge");
|
|
4
|
-
|
|
5
|
-
describe("mergeFacts", () => {
|
|
6
|
-
test("replaces base fact values with split values (complete mode)", () => {
|
|
7
|
-
const baseFacts = [
|
|
8
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0, hit_count: 1 },
|
|
9
|
-
{ type: "Recharge", text: "Recharge", value: 20 },
|
|
10
|
-
];
|
|
11
|
-
const splitFacts = [
|
|
12
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5, hit_count: 1 },
|
|
13
|
-
{ type: "Recharge", text: "Recharge", value: 25 },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const result = mergeFacts(baseFacts, splitFacts, { complete: true });
|
|
17
|
-
expect(result).toHaveLength(2);
|
|
18
|
-
expect(result[0].dmg_multiplier).toBe(0.5);
|
|
19
|
-
expect(result[0]._splitFact).toBe(true);
|
|
20
|
-
expect(result[1].value).toBe(25);
|
|
21
|
-
expect(result[1]._splitFact).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("preserves base fact labels when merging split values", () => {
|
|
25
|
-
const baseFacts = [
|
|
26
|
-
{ type: "Damage", text: "Base Damage Label", dmg_multiplier: 1.0 },
|
|
27
|
-
];
|
|
28
|
-
const splitFacts = [
|
|
29
|
-
{ type: "Damage", text: "Wiki Damage Label", dmg_multiplier: 0.5 },
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const result = mergeFacts(baseFacts, splitFacts, { complete: true });
|
|
33
|
-
expect(result[0].text).toBe("Base Damage Label");
|
|
34
|
-
expect(result[0].dmg_multiplier).toBe(0.5);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("drops unmatched base facts in complete mode", () => {
|
|
38
|
-
const baseFacts = [
|
|
39
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
40
|
-
{ type: "Buff", text: "Might", status: "Might", duration: 5 },
|
|
41
|
-
];
|
|
42
|
-
const splitFacts = [
|
|
43
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5 },
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
const result = mergeFacts(baseFacts, splitFacts, { complete: true });
|
|
47
|
-
expect(result).toHaveLength(1);
|
|
48
|
-
expect(result[0].type).toBe("Damage");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("keeps unmatched base facts in partial mode", () => {
|
|
52
|
-
const baseFacts = [
|
|
53
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
54
|
-
{ type: "Buff", text: "Might", status: "Might", duration: 5 },
|
|
55
|
-
];
|
|
56
|
-
const splitFacts = [
|
|
57
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5 },
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
const result = mergeFacts(baseFacts, splitFacts, { complete: false });
|
|
61
|
-
expect(result).toHaveLength(2);
|
|
62
|
-
expect(result[0].dmg_multiplier).toBe(0.5);
|
|
63
|
-
expect(result[0]._splitFact).toBe(true);
|
|
64
|
-
expect(result[1].status).toBe("Might");
|
|
65
|
-
expect(result[1]._splitFact).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("adds unmatched split facts as new facts", () => {
|
|
69
|
-
const baseFacts = [
|
|
70
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
71
|
-
];
|
|
72
|
-
const splitFacts = [
|
|
73
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5 },
|
|
74
|
-
{ type: "Buff", text: "Fury", status: "Fury", duration: 3 },
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
const result = mergeFacts(baseFacts, splitFacts, { complete: true });
|
|
78
|
-
expect(result).toHaveLength(2);
|
|
79
|
-
const newFact = result.find((f) => f.status === "Fury");
|
|
80
|
-
expect(newFact._newFact).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("marks facts with changed values as split facts", () => {
|
|
84
|
-
const baseFacts = [
|
|
85
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
86
|
-
];
|
|
87
|
-
const splitFacts = [
|
|
88
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
const result = mergeFacts(baseFacts, splitFacts, { complete: true });
|
|
92
|
-
expect(result[0]._splitFact).toBeUndefined();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("returns base facts unchanged when split facts is empty", () => {
|
|
96
|
-
const baseFacts = [
|
|
97
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
const result = mergeFacts(baseFacts, [], { complete: false });
|
|
101
|
-
expect(result).toEqual(baseFacts);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test("returns base facts unchanged when split facts is null", () => {
|
|
105
|
-
const baseFacts = [
|
|
106
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
const result = mergeFacts(baseFacts, null, { complete: false });
|
|
110
|
-
expect(result).toEqual(baseFacts);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test("defaults complete to false when options omitted", () => {
|
|
114
|
-
const baseFacts = [
|
|
115
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 1.0 },
|
|
116
|
-
{ type: "Buff", text: "Might", status: "Might", duration: 5 },
|
|
117
|
-
];
|
|
118
|
-
const splitFacts = [
|
|
119
|
-
{ type: "Damage", text: "Damage", dmg_multiplier: 0.5 },
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
// No options arg — should behave like complete: false (keep unmatched base)
|
|
123
|
-
const result = mergeFacts(baseFacts, splitFacts);
|
|
124
|
-
expect(result).toHaveLength(2);
|
|
125
|
-
expect(result[0].dmg_multiplier).toBe(0.5);
|
|
126
|
-
expect(result[1].status).toBe("Might");
|
|
127
|
-
});
|
|
128
|
-
});
|
package/tests/normalize.test.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
normalizeFactType,
|
|
5
|
-
stripGw2Markup,
|
|
6
|
-
stripWikiMarkup,
|
|
7
|
-
} = require("../src/facts/normalize");
|
|
8
|
-
|
|
9
|
-
describe("normalizeFactType", () => {
|
|
10
|
-
test("normalizes Distance to Radius", () => {
|
|
11
|
-
expect(normalizeFactType("Distance")).toBe("Radius");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test("normalizes PrefixedBuff to Buff", () => {
|
|
15
|
-
expect(normalizeFactType("PrefixedBuff")).toBe("Buff");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("normalizes ApplyBuffCondition to Buff", () => {
|
|
19
|
-
expect(normalizeFactType("ApplyBuffCondition")).toBe("Buff");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("passes through standard types unchanged", () => {
|
|
23
|
-
expect(normalizeFactType("Damage")).toBe("Damage");
|
|
24
|
-
expect(normalizeFactType("Buff")).toBe("Buff");
|
|
25
|
-
expect(normalizeFactType("Recharge")).toBe("Recharge");
|
|
26
|
-
expect(normalizeFactType("AttributeAdjust")).toBe("AttributeAdjust");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("stripGw2Markup", () => {
|
|
31
|
-
test("strips color tags", () => {
|
|
32
|
-
expect(stripGw2Markup("<c=@abilitytype>Fireball</c>")).toBe("Fireball");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("strips nested color tags", () => {
|
|
36
|
-
expect(stripGw2Markup("Deals <c=@abilitytype>damage</c> to foes")).toBe(
|
|
37
|
-
"Deals damage to foes"
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("returns plain text unchanged", () => {
|
|
42
|
-
expect(stripGw2Markup("No markup here")).toBe("No markup here");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("returns null/empty unchanged", () => {
|
|
46
|
-
expect(stripGw2Markup("")).toBe("");
|
|
47
|
-
expect(stripGw2Markup(null)).toBeNull();
|
|
48
|
-
expect(stripGw2Markup(undefined)).toBeUndefined();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("stripWikiMarkup", () => {
|
|
53
|
-
test("strips wiki links with display text", () => {
|
|
54
|
-
expect(stripWikiMarkup("[[Burning|burning]]")).toBe("burning");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("strips wiki links without display text", () => {
|
|
58
|
-
expect(stripWikiMarkup("[[Burning]]")).toBe("Burning");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("strips wiki links with anchors", () => {
|
|
62
|
-
expect(stripWikiMarkup("[[Might#Effect|Might]]")).toBe("Might");
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("converts fraction templates to numbers", () => {
|
|
66
|
-
expect(stripWikiMarkup("{{fraction|7.5}}")).toBe("7.5");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("strips other templates", () => {
|
|
70
|
-
expect(stripWikiMarkup("{{some template}}")).toBe("");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("handles combined markup", () => {
|
|
74
|
-
expect(
|
|
75
|
-
stripWikiMarkup("Inflicts [[Bleeding|bleeding]] for {{fraction|2.5}}s")
|
|
76
|
-
).toBe("Inflicts bleeding for 2.5s");
|
|
77
|
-
});
|
|
78
|
-
});
|