@quenty/scoredactionservice 16.55.1 → 16.57.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [16.57.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@16.56.0...@quenty/scoredactionservice@16.57.0) (2026-08-28)
7
+
8
+ **Note:** Version bump only for package @quenty/scoredactionservice
9
+
10
+ # [16.56.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@16.55.1...@quenty/scoredactionservice@16.56.0) (2026-08-28)
11
+
12
+ **Note:** Version bump only for package @quenty/scoredactionservice
13
+
6
14
  ## [16.55.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@16.55.0...@quenty/scoredactionservice@16.55.1) (2026-08-24)
7
15
 
8
16
  **Note:** Version bump only for package @quenty/scoredactionservice
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/scoredactionservice",
3
- "version": "16.55.1",
3
+ "version": "16.57.0",
4
4
  "description": "Scores actions and picks the highest rated one every frame",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -29,24 +29,25 @@
29
29
  "Quenty"
30
30
  ],
31
31
  "dependencies": {
32
- "@quenty/baseobject": "10.15.1",
33
- "@quenty/brio": "14.35.2",
34
- "@quenty/inputkeymaputils": "14.54.1",
35
- "@quenty/inputmode": "13.40.2",
32
+ "@quenty/baseobject": "10.16.0",
33
+ "@quenty/brio": "14.37.0",
34
+ "@quenty/inputkeymaputils": "14.56.0",
35
+ "@quenty/inputmode": "13.42.0",
36
+ "@quenty/jestutils": "1.1.0",
36
37
  "@quenty/loader": "10.11.1",
37
- "@quenty/maid": "3.11.1",
38
- "@quenty/nevermore-test-runner": "1.5.1",
39
- "@quenty/rx": "13.33.1",
40
- "@quenty/servicebag": "11.20.1",
38
+ "@quenty/maid": "3.12.0",
39
+ "@quenty/nevermore-test-runner": "1.6.0",
40
+ "@quenty/rx": "13.34.0",
41
+ "@quenty/servicebag": "11.21.0",
41
42
  "@quenty/signal": "7.13.2",
42
- "@quenty/statestack": "14.37.2",
43
- "@quenty/steputils": "3.7.2",
43
+ "@quenty/statestack": "14.39.0",
44
+ "@quenty/steputils": "3.9.0",
44
45
  "@quenty/table": "3.9.2",
45
- "@quenty/valueobject": "13.36.2",
46
+ "@quenty/valueobject": "13.38.0",
46
47
  "@quentystudios/jest-lua": "3.10.0-quenty.2"
47
48
  },
48
49
  "publishConfig": {
49
50
  "access": "public"
50
51
  },
51
- "gitHead": "1a2c0cc735d06b4adcd324f60302b950e12d68b0"
52
+ "gitHead": "346201e192e467cb71160f43029863853be855b5"
52
53
  }
@@ -12,6 +12,7 @@ local InputModeServiceClient = require("InputModeServiceClient")
12
12
  local InputModeType = require("InputModeType")
13
13
  local InputModeTypes = require("InputModeTypes")
14
14
  local Jest = require("Jest")
15
+ local JestUtils = require("JestUtils")
15
16
  local Maid = require("Maid")
16
17
  local ScoredAction = require("ScoredAction")
17
18
  local ScoredActionPickerProvider = require("ScoredActionPickerProvider")
@@ -74,11 +75,13 @@ local function setup(): any
74
75
  return picker:HasActions()
75
76
  end,
76
77
 
77
- destroy = function()
78
+ Destroy = function(_self)
78
79
  maid:DoCleaning()
79
80
  end,
80
81
  }
81
82
 
83
+ maid:GiveTask(JestUtils.afterThis(controller))
84
+
82
85
  return controller
83
86
  end
84
87
 
@@ -100,7 +103,7 @@ describe("InputListScoreHelper.new", function()
100
103
  expect(provider:FindPicker(Enum.KeyCode.ButtonX)).toBeNil()
101
104
  expect(action:IsPreferred()).toBe(true)
102
105
 
103
- controller.destroy()
106
+ controller:Destroy()
104
107
  end)
105
108
 
106
109
  it("registers every key in the active input mode", function()
@@ -117,7 +120,7 @@ describe("InputListScoreHelper.new", function()
117
120
  expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(true)
118
121
  expect(controller.pickerHasActions(provider, Enum.KeyCode.Q)).toBe(true)
119
122
 
120
- controller.destroy()
123
+ controller:Destroy()
121
124
  end)
122
125
 
123
126
  it("registers nothing for an empty key list", function()
@@ -133,7 +136,7 @@ describe("InputListScoreHelper.new", function()
133
136
 
134
137
  expect(provider:FindPicker(Enum.KeyCode.E)).toBeNil()
135
138
 
136
- controller.destroy()
139
+ controller:Destroy()
137
140
  end)
138
141
 
139
142
  it("throws without a serviceBag", function()
@@ -144,7 +147,7 @@ describe("InputListScoreHelper.new", function()
144
147
  (InputListScoreHelper :: any).new(nil, controller.newProvider(), controller.newAction(), list)
145
148
  end).toThrow()
146
149
 
147
- controller.destroy()
150
+ controller:Destroy()
148
151
  end)
149
152
 
150
153
  it("throws without a provider", function()
@@ -155,7 +158,7 @@ describe("InputListScoreHelper.new", function()
155
158
  (InputListScoreHelper :: any).new(controller.serviceBag, nil, controller.newAction(), list)
156
159
  end).toThrow()
157
160
 
158
- controller.destroy()
161
+ controller:Destroy()
159
162
  end)
160
163
 
161
164
  it("throws without a scoredAction", function()
@@ -166,7 +169,7 @@ describe("InputListScoreHelper.new", function()
166
169
  (InputListScoreHelper :: any).new(controller.serviceBag, controller.newProvider(), nil, list)
167
170
  end).toThrow()
168
171
 
169
- controller.destroy()
172
+ controller:Destroy()
170
173
  end)
171
174
 
172
175
  it("throws on something that is not an inputKeyMapList", function()
@@ -181,7 +184,7 @@ describe("InputListScoreHelper.new", function()
181
184
  )
182
185
  end).toThrow()
183
186
 
184
- controller.destroy()
187
+ controller:Destroy()
185
188
  end)
186
189
  end)
187
190
 
@@ -203,7 +206,7 @@ describe("InputListScoreHelper input mode changes", function()
203
206
  expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
204
207
  expect(controller.pickerHasActions(provider, Enum.KeyCode.ButtonX)).toBe(true)
205
208
 
206
- controller.destroy()
209
+ controller:Destroy()
207
210
  end)
208
211
 
209
212
  it("keeps a key that both input modes share", function()
@@ -223,7 +226,7 @@ describe("InputListScoreHelper input mode changes", function()
223
226
  expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(true)
224
227
  expect(action:IsPreferred()).toBe(true)
225
228
 
226
- controller.destroy()
229
+ controller:Destroy()
227
230
  end)
228
231
 
229
232
  it("follows a rebind of the active input mode", function()
@@ -241,7 +244,7 @@ describe("InputListScoreHelper input mode changes", function()
241
244
  expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
242
245
  expect(controller.pickerHasActions(provider, Enum.KeyCode.Q)).toBe(true)
243
246
 
244
- controller.destroy()
247
+ controller:Destroy()
245
248
  end)
246
249
 
247
250
  it("unregisters the action when the list loses its only input mode", function()
@@ -260,7 +263,7 @@ describe("InputListScoreHelper input mode changes", function()
260
263
  expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
261
264
  expect(action:IsPreferred()).toBe(false)
262
265
 
263
- controller.destroy()
266
+ controller:Destroy()
264
267
  end)
265
268
  end)
266
269
 
@@ -282,7 +285,7 @@ describe("InputListScoreHelper.Destroy", function()
282
285
  expect(controller.pickerHasActions(provider, Enum.KeyCode.Q)).toBe(false)
283
286
  expect(action:IsPreferred()).toBe(false)
284
287
 
285
- controller.destroy()
288
+ controller:Destroy()
286
289
  end)
287
290
 
288
291
  it("tolerates a provider destroyed first", function()
@@ -301,6 +304,6 @@ describe("InputListScoreHelper.Destroy", function()
301
304
  helper:Destroy()
302
305
  end).never.toThrow()
303
306
 
304
- controller.destroy()
307
+ controller:Destroy()
305
308
  end)
306
309
  end)
@@ -6,6 +6,7 @@
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local Jest = require("Jest")
9
+ local JestUtils = require("JestUtils")
9
10
  local Maid = require("Maid")
10
11
  local ScoredAction = require("ScoredAction")
11
12
  local ScoredActionPicker = require("ScoredActionPicker")
@@ -38,11 +39,13 @@ local function setup(): any
38
39
 
39
40
  newLooseAction = makeAction,
40
41
 
41
- destroy = function()
42
+ Destroy = function(_self)
42
43
  maid:DoCleaning()
43
44
  end,
44
45
  }
45
46
 
47
+ maid:GiveTask(JestUtils.afterThis(controller))
48
+
46
49
  return controller
47
50
  end
48
51
 
@@ -60,7 +63,7 @@ describe("ScoredActionPicker.Update", function()
60
63
  expect(high:IsPreferred()).toBe(true)
61
64
  expect(low:IsPreferred()).toBe(false)
62
65
 
63
- controller.destroy()
66
+ controller:Destroy()
64
67
  end)
65
68
 
66
69
  it("never prefers an action scored at -math.huge", function()
@@ -73,7 +76,7 @@ describe("ScoredActionPicker.Update", function()
73
76
 
74
77
  expect(action:IsPreferred()).toBe(false)
75
78
 
76
- controller.destroy()
79
+ controller:Destroy()
77
80
  end)
78
81
 
79
82
  it("drops the preference when the only action is disabled", function()
@@ -91,7 +94,7 @@ describe("ScoredActionPicker.Update", function()
91
94
 
92
95
  expect(action:IsPreferred()).toBe(false)
93
96
 
94
- controller.destroy()
97
+ controller:Destroy()
95
98
  end)
96
99
 
97
100
  it("hands the preference to the best still-enabled action", function()
@@ -110,7 +113,7 @@ describe("ScoredActionPicker.Update", function()
110
113
  expect(high:IsPreferred()).toBe(false)
111
114
  expect(low:IsPreferred()).toBe(true)
112
115
 
113
- controller.destroy()
116
+ controller:Destroy()
114
117
  end)
115
118
 
116
119
  it("gives the preference back when the action is re-enabled", function()
@@ -128,7 +131,7 @@ describe("ScoredActionPicker.Update", function()
128
131
  picker:Update()
129
132
  expect(action:IsPreferred()).toBe(true)
130
133
 
131
- controller.destroy()
134
+ controller:Destroy()
132
135
  end)
133
136
 
134
137
  it("drops the preference when the preferred action is removed", function()
@@ -144,7 +147,7 @@ describe("ScoredActionPicker.Update", function()
144
147
  expect(action:IsPreferred()).toBe(false)
145
148
  expect(picker:HasActions()).toBe(false)
146
149
 
147
- controller.destroy()
150
+ controller:Destroy()
148
151
  end)
149
152
 
150
153
  it("breaks score ties in favor of the older action", function()
@@ -160,7 +163,7 @@ describe("ScoredActionPicker.Update", function()
160
163
  expect(older:IsPreferred()).toBe(true)
161
164
  expect(newer:IsPreferred()).toBe(false)
162
165
 
163
- controller.destroy()
166
+ controller:Destroy()
164
167
  end)
165
168
 
166
169
  it("skips past unscored actions to reach a scored one", function()
@@ -176,7 +179,7 @@ describe("ScoredActionPicker.Update", function()
176
179
  expect(scored:IsPreferred()).toBe(true)
177
180
  expect(unscored:IsPreferred()).toBe(false)
178
181
 
179
- controller.destroy()
182
+ controller:Destroy()
180
183
  end)
181
184
 
182
185
  it("moves the preference when a score change reorders the actions", function()
@@ -196,7 +199,7 @@ describe("ScoredActionPicker.Update", function()
196
199
  expect(first:IsPreferred()).toBe(false)
197
200
  expect(second:IsPreferred()).toBe(true)
198
201
 
199
- controller.destroy()
202
+ controller:Destroy()
200
203
  end)
201
204
 
202
205
  it("tolerates an action destroyed without being removed", function()
@@ -211,7 +214,7 @@ describe("ScoredActionPicker.Update", function()
211
214
  picker:Update()
212
215
  end).never.toThrow()
213
216
 
214
- controller.destroy()
217
+ controller:Destroy()
215
218
  end)
216
219
  end)
217
220
 
@@ -226,7 +229,7 @@ describe("ScoredActionPicker.AddAction", function()
226
229
  expect(action:IsPreferred()).toBe(true)
227
230
  expect(picker:HasActions()).toBe(true)
228
231
 
229
- controller.destroy()
232
+ controller:Destroy()
230
233
  end)
231
234
 
232
235
  it("re-evaluates when an action's enabled state changes", function()
@@ -243,7 +246,7 @@ describe("ScoredActionPicker.AddAction", function()
243
246
  expect(high:IsPreferred()).toBe(false)
244
247
  expect(low:IsPreferred()).toBe(true)
245
248
 
246
- controller.destroy()
249
+ controller:Destroy()
247
250
  end)
248
251
 
249
252
  it("ignores a repeated add of the same action", function()
@@ -257,7 +260,7 @@ describe("ScoredActionPicker.AddAction", function()
257
260
 
258
261
  expect(picker:HasActions()).toBe(false)
259
262
 
260
- controller.destroy()
263
+ controller:Destroy()
261
264
  end)
262
265
 
263
266
  it("throws on a non-table action", function()
@@ -268,7 +271,7 @@ describe("ScoredActionPicker.AddAction", function()
268
271
  (picker :: any):AddAction("action")
269
272
  end).toThrow()
270
273
 
271
- controller.destroy()
274
+ controller:Destroy()
272
275
  end)
273
276
  end)
274
277
 
@@ -286,7 +289,7 @@ describe("ScoredActionPicker.RemoveAction", function()
286
289
 
287
290
  expect(low:IsPreferred()).toBe(true)
288
291
 
289
- controller.destroy()
292
+ controller:Destroy()
290
293
  end)
291
294
 
292
295
  it("stops tracking the enabled state of a removed action", function()
@@ -303,7 +306,7 @@ describe("ScoredActionPicker.RemoveAction", function()
303
306
 
304
307
  expect(remaining:IsPreferred()).toBe(true)
305
308
 
306
- controller.destroy()
309
+ controller:Destroy()
307
310
  end)
308
311
 
309
312
  it("ignores an action that was never added", function()
@@ -315,7 +318,7 @@ describe("ScoredActionPicker.RemoveAction", function()
315
318
  picker:RemoveAction(action)
316
319
  end).never.toThrow()
317
320
 
318
- controller.destroy()
321
+ controller:Destroy()
319
322
  end)
320
323
 
321
324
  it("throws on a non-table action", function()
@@ -326,7 +329,7 @@ describe("ScoredActionPicker.RemoveAction", function()
326
329
  (picker :: any):RemoveAction("action")
327
330
  end).toThrow()
328
331
 
329
- controller.destroy()
332
+ controller:Destroy()
330
333
  end)
331
334
  end)
332
335
 
@@ -343,6 +346,6 @@ describe("ScoredActionPicker.Destroy", function()
343
346
 
344
347
  expect(action:IsPreferred()).toBe(false)
345
348
 
346
- controller.destroy()
349
+ controller:Destroy()
347
350
  end)
348
351
  end)
@@ -6,6 +6,7 @@
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local Jest = require("Jest")
9
+ local JestUtils = require("JestUtils")
9
10
  local Maid = require("Maid")
10
11
  local ScoredAction = require("ScoredAction")
11
12
  local ScoredActionPickerProvider = require("ScoredActionPickerProvider")
@@ -20,7 +21,7 @@ type Controller = {
20
21
  newLooseProvider: () -> ScoredActionPickerProvider.ScoredActionPickerProvider,
21
22
  newAction: (number) -> ScoredAction.ScoredAction,
22
23
  slot: (string) -> any,
23
- destroy: () -> (),
24
+ Destroy: (self: Controller) -> (),
24
25
  }
25
26
 
26
27
  local function setup(): Controller
@@ -45,11 +46,13 @@ local function setup(): Controller
45
46
  return SlottedTouchButtonUtils.createSlottedTouchButton(slotId)
46
47
  end,
47
48
 
48
- destroy = function()
49
+ Destroy = function(_self)
49
50
  maid:DoCleaning()
50
51
  end,
51
52
  }
52
53
 
54
+ maid:GiveTask(JestUtils.afterThis(controller))
55
+
53
56
  return controller
54
57
  end
55
58
 
@@ -63,7 +66,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
63
66
 
64
67
  expect(second).toBe(first)
65
68
 
66
- controller.destroy()
69
+ controller:Destroy()
67
70
  end)
68
71
 
69
72
  it("creates a separate picker per input type", function()
@@ -75,7 +78,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
75
78
 
76
79
  expect(gamepad).never.toBe(keyboard)
77
80
 
78
- controller.destroy()
81
+ controller:Destroy()
79
82
  end)
80
83
 
81
84
  it("creates a competing picker for a key code", function()
@@ -86,7 +89,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
86
89
 
87
90
  expect((picker :: any).ClassName).toBe("ScoredActionPicker")
88
91
 
89
- controller.destroy()
92
+ controller:Destroy()
90
93
  end)
91
94
 
92
95
  it("creates a non-competing picker for a Roblox touch button", function()
@@ -97,7 +100,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
97
100
 
98
101
  expect((picker :: any).ClassName).toBe("TouchButtonScoredActionPicker")
99
102
 
100
- controller.destroy()
103
+ controller:Destroy()
101
104
  end)
102
105
 
103
106
  it("reuses the picker for slotted touch buttons sharing a slot", function()
@@ -109,7 +112,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
109
112
 
110
113
  expect(second).toBe(first)
111
114
 
112
- controller.destroy()
115
+ controller:Destroy()
113
116
  end)
114
117
 
115
118
  it("creates a separate picker per slot", function()
@@ -121,7 +124,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
121
124
 
122
125
  expect(second).never.toBe(first)
123
126
 
124
- controller.destroy()
127
+ controller:Destroy()
125
128
  end)
126
129
 
127
130
  it("throws on a nil input type", function()
@@ -132,7 +135,7 @@ describe("ScoredActionPickerProvider.GetOrCreatePicker", function()
132
135
  (provider :: any):GetOrCreatePicker(nil)
133
136
  end).toThrow()
134
137
 
135
- controller.destroy()
138
+ controller:Destroy()
136
139
  end)
137
140
  end)
138
141
 
@@ -143,7 +146,7 @@ describe("ScoredActionPickerProvider.FindPicker", function()
143
146
 
144
147
  expect(provider:FindPicker(Enum.KeyCode.E)).toBeNil()
145
148
 
146
- controller.destroy()
149
+ controller:Destroy()
147
150
  end)
148
151
 
149
152
  it("finds a created picker", function()
@@ -154,7 +157,7 @@ describe("ScoredActionPickerProvider.FindPicker", function()
154
157
 
155
158
  expect(provider:FindPicker(Enum.KeyCode.E)).toBe(picker)
156
159
 
157
- controller.destroy()
160
+ controller:Destroy()
158
161
  end)
159
162
 
160
163
  it("finds a slotted touch button picker by an equivalent slot", function()
@@ -165,7 +168,7 @@ describe("ScoredActionPickerProvider.FindPicker", function()
165
168
 
166
169
  expect(provider:FindPicker(controller.slot("inner1"))).toBe(picker)
167
170
 
168
- controller.destroy()
171
+ controller:Destroy()
169
172
  end)
170
173
  end)
171
174
 
@@ -179,7 +182,7 @@ describe("ScoredActionPickerProvider.Update", function()
179
182
 
180
183
  expect(provider:FindPicker(Enum.KeyCode.E)).toBeNil()
181
184
 
182
- controller.destroy()
185
+ controller:Destroy()
183
186
  end)
184
187
 
185
188
  it("keeps a picker that still has actions", function()
@@ -192,7 +195,7 @@ describe("ScoredActionPickerProvider.Update", function()
192
195
 
193
196
  expect(provider:FindPicker(Enum.KeyCode.E)).toBe(picker)
194
197
 
195
- controller.destroy()
198
+ controller:Destroy()
196
199
  end)
197
200
 
198
201
  it("updates the pickers it keeps", function()
@@ -208,7 +211,7 @@ describe("ScoredActionPickerProvider.Update", function()
208
211
 
209
212
  expect(action:IsPreferred()).toBe(true)
210
213
 
211
- controller.destroy()
214
+ controller:Destroy()
212
215
  end)
213
216
 
214
217
  it("discards a picker once its last action is removed", function()
@@ -225,7 +228,7 @@ describe("ScoredActionPickerProvider.Update", function()
225
228
 
226
229
  expect(provider:FindPicker(Enum.KeyCode.E)).toBeNil()
227
230
 
228
- controller.destroy()
231
+ controller:Destroy()
229
232
  end)
230
233
 
231
234
  it("discards a touch button picker that has no actions", function()
@@ -237,7 +240,7 @@ describe("ScoredActionPickerProvider.Update", function()
237
240
 
238
241
  expect(provider:FindPicker("TouchButton")).toBeNil()
239
242
 
240
- controller.destroy()
243
+ controller:Destroy()
241
244
  end)
242
245
 
243
246
  it("does nothing when there are no pickers", function()
@@ -248,7 +251,7 @@ describe("ScoredActionPickerProvider.Update", function()
248
251
  provider:Update()
249
252
  end).never.toThrow()
250
253
 
251
- controller.destroy()
254
+ controller:Destroy()
252
255
  end)
253
256
  end)
254
257
 
@@ -266,6 +269,6 @@ describe("ScoredActionPickerProvider.Destroy", function()
266
269
 
267
270
  expect(action:IsPreferred()).toBe(false)
268
271
 
269
- controller.destroy()
272
+ controller:Destroy()
270
273
  end)
271
274
  end)
@@ -6,6 +6,7 @@
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local Jest = require("Jest")
9
+ local JestUtils = require("JestUtils")
9
10
  local Maid = require("Maid")
10
11
  local ScoredAction = require("ScoredAction")
11
12
  local TouchButtonScoredActionPicker = require("TouchButtonScoredActionPicker")
@@ -19,7 +20,7 @@ type Controller = {
19
20
  newLoosePicker: () -> TouchButtonScoredActionPicker.TouchButtonScoredActionPicker,
20
21
  newAction: (number) -> ScoredAction.ScoredAction,
21
22
  newLooseAction: (number) -> ScoredAction.ScoredAction,
22
- destroy: () -> (),
23
+ Destroy: (self: Controller) -> (),
23
24
  }
24
25
 
25
26
  local function setup(): Controller
@@ -46,11 +47,13 @@ local function setup(): Controller
46
47
 
47
48
  newLooseAction = makeAction,
48
49
 
49
- destroy = function()
50
+ Destroy = function(_self)
50
51
  maid:DoCleaning()
51
52
  end,
52
53
  }
53
54
 
55
+ maid:GiveTask(JestUtils.afterThis(controller))
56
+
54
57
  return controller
55
58
  end
56
59
 
@@ -69,7 +72,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
69
72
  expect(first:IsPreferred()).toBe(true)
70
73
  expect(second:IsPreferred()).toBe(true)
71
74
 
72
- controller.destroy()
75
+ controller:Destroy()
73
76
  end)
74
77
 
75
78
  it("never prefers an action scored at -math.huge", function()
@@ -82,7 +85,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
82
85
 
83
86
  expect(action:IsPreferred()).toBe(false)
84
87
 
85
- controller.destroy()
88
+ controller:Destroy()
86
89
  end)
87
90
 
88
91
  it("does not prefer an action that is already disabled", function()
@@ -95,7 +98,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
95
98
 
96
99
  expect(action:IsPreferred()).toBe(false)
97
100
 
98
- controller.destroy()
101
+ controller:Destroy()
99
102
  end)
100
103
 
101
104
  it("drops the preference when the action is disabled", function()
@@ -111,7 +114,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
111
114
 
112
115
  expect(action:IsPreferred()).toBe(false)
113
116
 
114
- controller.destroy()
117
+ controller:Destroy()
115
118
  end)
116
119
 
117
120
  it("gives the preference back when the action is re-enabled", function()
@@ -129,7 +132,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
129
132
  picker:Update()
130
133
  expect(action:IsPreferred()).toBe(true)
131
134
 
132
- controller.destroy()
135
+ controller:Destroy()
133
136
  end)
134
137
 
135
138
  it("leaves the other actions alone when one is disabled", function()
@@ -147,7 +150,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
147
150
  expect(disabled:IsPreferred()).toBe(false)
148
151
  expect(enabled:IsPreferred()).toBe(true)
149
152
 
150
- controller.destroy()
153
+ controller:Destroy()
151
154
  end)
152
155
 
153
156
  it("drops the preference when the action is removed", function()
@@ -163,7 +166,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
163
166
  expect(action:IsPreferred()).toBe(false)
164
167
  expect(picker:HasActions()).toBe(false)
165
168
 
166
- controller.destroy()
169
+ controller:Destroy()
167
170
  end)
168
171
 
169
172
  it("prefers an action that gained a score", function()
@@ -178,7 +181,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
178
181
 
179
182
  expect(action:IsPreferred()).toBe(true)
180
183
 
181
- controller.destroy()
184
+ controller:Destroy()
182
185
  end)
183
186
 
184
187
  it("holds a single preference across repeated updates", function()
@@ -194,7 +197,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
194
197
 
195
198
  expect(action:IsPreferred()).toBe(false)
196
199
 
197
- controller.destroy()
200
+ controller:Destroy()
198
201
  end)
199
202
 
200
203
  it("tolerates an action destroyed without being removed", function()
@@ -209,7 +212,7 @@ describe("TouchButtonScoredActionPicker.Update", function()
209
212
  picker:Update()
210
213
  end).never.toThrow()
211
214
 
212
- controller.destroy()
215
+ controller:Destroy()
213
216
  end)
214
217
  end)
215
218
 
@@ -226,7 +229,7 @@ describe("TouchButtonScoredActionPicker.AddAction", function()
226
229
  expect(action:IsPreferred()).toBe(false)
227
230
  expect(picker:HasActions()).toBe(false)
228
231
 
229
- controller.destroy()
232
+ controller:Destroy()
230
233
  end)
231
234
  end)
232
235
 
@@ -245,7 +248,7 @@ describe("TouchButtonScoredActionPicker.RemoveAction", function()
245
248
  expect(removed:IsPreferred()).toBe(false)
246
249
  expect(remaining:IsPreferred()).toBe(true)
247
250
 
248
- controller.destroy()
251
+ controller:Destroy()
249
252
  end)
250
253
  end)
251
254
 
@@ -256,7 +259,7 @@ describe("TouchButtonScoredActionPicker.HasActions", function()
256
259
 
257
260
  expect(picker:HasActions()).toBe(false)
258
261
 
259
- controller.destroy()
262
+ controller:Destroy()
260
263
  end)
261
264
  end)
262
265
 
@@ -273,6 +276,6 @@ describe("TouchButtonScoredActionPicker.Destroy", function()
273
276
 
274
277
  expect(action:IsPreferred()).toBe(false)
275
278
 
276
- controller.destroy()
279
+ controller:Destroy()
277
280
  end)
278
281
  end)
@@ -6,6 +6,7 @@
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local Jest = require("Jest")
9
+ local JestUtils = require("JestUtils")
9
10
  local Maid = require("Maid")
10
11
  local ScoredAction = require("ScoredAction")
11
12
  local ValueObject = require("ValueObject")
@@ -19,7 +20,7 @@ type Controller = {
19
20
  newLooseAction: () -> ScoredAction.ScoredAction,
20
21
  newValue: (boolean) -> ValueObject.ValueObject<boolean>,
21
22
  collect: (any) -> { any },
22
- destroy: () -> (),
23
+ Destroy: (self: Controller) -> (),
23
24
  }
24
25
 
25
26
  local function setup(): Controller
@@ -46,11 +47,13 @@ local function setup(): Controller
46
47
  return results
47
48
  end,
48
49
 
49
- destroy = function()
50
+ Destroy = function(_self)
50
51
  maid:DoCleaning()
51
52
  end,
52
53
  }
53
54
 
55
+ maid:GiveTask(JestUtils.afterThis(controller))
56
+
54
57
  return controller
55
58
  end
56
59
 
@@ -63,7 +66,7 @@ describe("ScoredAction.new", function()
63
66
  expect(action:IsEnabled()).toBe(true)
64
67
  expect(action:IsPreferred()).toBe(false)
65
68
 
66
- controller.destroy()
69
+ controller:Destroy()
67
70
  end)
68
71
  end)
69
72
 
@@ -76,7 +79,7 @@ describe("ScoredAction.SetScore", function()
76
79
 
77
80
  expect(action:GetScore()).toBe(5)
78
81
 
79
- controller.destroy()
82
+ controller:Destroy()
80
83
  end)
81
84
 
82
85
  it("throws on a non-number score", function()
@@ -87,7 +90,7 @@ describe("ScoredAction.SetScore", function()
87
90
  (action :: any):SetScore("5")
88
91
  end).toThrow()
89
92
 
90
- controller.destroy()
93
+ controller:Destroy()
91
94
  end)
92
95
  end)
93
96
 
@@ -100,7 +103,7 @@ describe("ScoredAction.SetIsEnabled", function()
100
103
 
101
104
  expect(action:IsEnabled()).toBe(false)
102
105
 
103
- controller.destroy()
106
+ controller:Destroy()
104
107
  end)
105
108
 
106
109
  it("tracks an observable source", function()
@@ -113,7 +116,7 @@ describe("ScoredAction.SetIsEnabled", function()
113
116
 
114
117
  expect(action:IsEnabled()).toBe(false)
115
118
 
116
- controller.destroy()
119
+ controller:Destroy()
117
120
  end)
118
121
 
119
122
  it("stops tracking the observable source once unmounted", function()
@@ -127,7 +130,7 @@ describe("ScoredAction.SetIsEnabled", function()
127
130
 
128
131
  expect(action:IsEnabled()).toBe(true)
129
132
 
130
- controller.destroy()
133
+ controller:Destroy()
131
134
  end)
132
135
 
133
136
  it("fires EnabledChanged with the new state", function()
@@ -140,7 +143,7 @@ describe("ScoredAction.SetIsEnabled", function()
140
143
 
141
144
  expect(states).toEqual({ true, false, true })
142
145
 
143
- controller.destroy()
146
+ controller:Destroy()
144
147
  end)
145
148
  end)
146
149
 
@@ -154,7 +157,7 @@ describe("ScoredAction.ObserveIsEnabled", function()
154
157
 
155
158
  expect(states).toEqual({ true, false })
156
159
 
157
- controller.destroy()
160
+ controller:Destroy()
158
161
  end)
159
162
  end)
160
163
 
@@ -169,7 +172,7 @@ describe("ScoredAction.PushPreferred", function()
169
172
  pop()
170
173
  expect(action:IsPreferred()).toBe(false)
171
174
 
172
- controller.destroy()
175
+ controller:Destroy()
173
176
  end)
174
177
 
175
178
  it("stays preferred until every push is popped", function()
@@ -185,7 +188,7 @@ describe("ScoredAction.PushPreferred", function()
185
188
  popSecond()
186
189
  expect(action:IsPreferred()).toBe(false)
187
190
 
188
- controller.destroy()
191
+ controller:Destroy()
189
192
  end)
190
193
 
191
194
  it("fires PreferredChanged with the new state", function()
@@ -201,7 +204,7 @@ describe("ScoredAction.PushPreferred", function()
201
204
 
202
205
  expect(states).toEqual({ true, false })
203
206
 
204
- controller.destroy()
207
+ controller:Destroy()
205
208
  end)
206
209
 
207
210
  it("does not require a score", function()
@@ -213,7 +216,7 @@ describe("ScoredAction.PushPreferred", function()
213
216
  expect(action:GetScore()).toBe(-math.huge)
214
217
  expect(action:IsPreferred()).toBe(true)
215
218
 
216
- controller.destroy()
219
+ controller:Destroy()
217
220
  end)
218
221
  end)
219
222
 
@@ -227,7 +230,7 @@ describe("ScoredAction.ObservePreferred", function()
227
230
 
228
231
  expect(states).toEqual({ false, true, false })
229
232
 
230
- controller.destroy()
233
+ controller:Destroy()
231
234
  end)
232
235
  end)
233
236
 
@@ -245,7 +248,7 @@ describe("ScoredAction.Destroy", function()
245
248
 
246
249
  expect(fired).toBe(true)
247
250
 
248
- controller.destroy()
251
+ controller:Destroy()
249
252
  end)
250
253
 
251
254
  it("clears the metatable so pickers can detect a stale action", function()
@@ -257,6 +260,6 @@ describe("ScoredAction.Destroy", function()
257
260
 
258
261
  expect((action :: any).Destroy).toBeNil()
259
262
 
260
- controller.destroy()
263
+ controller:Destroy()
261
264
  end)
262
265
  end)
@@ -10,6 +10,7 @@ local InputKeyMapList = require("InputKeyMapList")
10
10
  local InputModeServiceClient = require("InputModeServiceClient")
11
11
  local InputModeTypes = require("InputModeTypes")
12
12
  local Jest = require("Jest")
13
+ local JestUtils = require("JestUtils")
13
14
  local Maid = require("Maid")
14
15
  local Observable = require("Observable")
15
16
  local ScoredActionServiceClient = require("ScoredActionServiceClient")
@@ -97,11 +98,13 @@ local function setup(): any
97
98
  service:Destroy()
98
99
  end,
99
100
 
100
- destroy = function()
101
+ Destroy = function(_self)
101
102
  maid:DoCleaning()
102
103
  end,
103
104
  }
104
105
 
106
+ maid:GiveTask(JestUtils.afterThis(controller))
107
+
105
108
  return controller
106
109
  end
107
110
 
@@ -115,7 +118,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
115
118
  expect(action:IsEnabled()).toBe(true)
116
119
  expect(action:IsPreferred()).toBe(false)
117
120
 
118
- controller.destroy()
121
+ controller:Destroy()
119
122
  end)
120
123
 
121
124
  it("throws on something that is not an inputKeyMapList", function()
@@ -125,7 +128,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
125
128
  (controller.service :: any):GetScoredAction({})
126
129
  end).toThrow()
127
130
 
128
- controller.destroy()
131
+ controller:Destroy()
129
132
  end)
130
133
 
131
134
  it("prefers the highest scoring action bound to the same key", function()
@@ -141,7 +144,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
141
144
  expect(high:IsPreferred()).toBe(true)
142
145
  expect(low:IsPreferred()).toBe(false)
143
146
 
144
- controller.destroy()
147
+ controller:Destroy()
145
148
  end)
146
149
 
147
150
  it("hands the preference over when the winner is disabled", function()
@@ -159,7 +162,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
159
162
  expect(high:IsPreferred()).toBe(false)
160
163
  expect(low:IsPreferred()).toBe(true)
161
164
 
162
- controller.destroy()
165
+ controller:Destroy()
163
166
  end)
164
167
 
165
168
  it("does not make actions on different keys compete", function()
@@ -174,7 +177,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
174
177
  expect(first:IsPreferred()).toBe(true)
175
178
  expect(second:IsPreferred()).toBe(true)
176
179
 
177
- controller.destroy()
180
+ controller:Destroy()
178
181
  end)
179
182
 
180
183
  it("releases the preference when the action is destroyed", function()
@@ -189,7 +192,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
189
192
 
190
193
  expect((action :: any).Destroy).toBeNil()
191
194
 
192
- controller.destroy()
195
+ controller:Destroy()
193
196
  end)
194
197
 
195
198
  it("lets a later action win the key a destroyed action held", function()
@@ -205,7 +208,7 @@ describe("ScoredActionServiceClient.GetScoredAction", function()
205
208
 
206
209
  expect(second:IsPreferred()).toBe(true)
207
210
 
208
- controller.destroy()
211
+ controller:Destroy()
209
212
  end)
210
213
  end)
211
214
 
@@ -217,7 +220,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
217
220
  (controller.service :: any):ObserveNewFromInputKeyMapList({})
218
221
  end).toThrow()
219
222
 
220
- controller.destroy()
223
+ controller:Destroy()
221
224
  end)
222
225
 
223
226
  it("emits an action carrying the current score", function()
@@ -229,7 +232,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
229
232
  expect(#actions).toBe(1)
230
233
  expect(actions[1]:GetScore()).toBe(5)
231
234
 
232
- controller.destroy()
235
+ controller:Destroy()
233
236
  end)
234
237
 
235
238
  it("follows later changes to the score value", function()
@@ -242,7 +245,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
242
245
 
243
246
  expect(actions[1]:GetScore()).toBe(9)
244
247
 
245
- controller.destroy()
248
+ controller:Destroy()
246
249
  end)
247
250
 
248
251
  it("emits once for a repeated inputKeyMapList", function()
@@ -253,7 +256,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
253
256
 
254
257
  expect(#actions).toBe(1)
255
258
 
256
- controller.destroy()
259
+ controller:Destroy()
257
260
  end)
258
261
 
259
262
  it("emits again for a different inputKeyMapList", function()
@@ -266,7 +269,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
266
269
  expect(#actions).toBe(2)
267
270
  expect(actions[2]).never.toBe(actions[1])
268
271
 
269
- controller.destroy()
272
+ controller:Destroy()
270
273
  end)
271
274
 
272
275
  it("destroys the previous action when a new one is emitted", function()
@@ -279,7 +282,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
279
282
  expect(actions[1].Destroy).toBeNil()
280
283
  expect(actions[2].Destroy).never.toBeNil()
281
284
 
282
- controller.destroy()
285
+ controller:Destroy()
283
286
  end)
284
287
 
285
288
  it("destroys the emitted action when the subscription ends", function()
@@ -291,7 +294,7 @@ describe("ScoredActionServiceClient.ObserveNewFromInputKeyMapList", function()
291
294
 
292
295
  expect(actions[1].Destroy).toBeNil()
293
296
 
294
- controller.destroy()
297
+ controller:Destroy()
295
298
  end)
296
299
  end)
297
300
 
@@ -307,7 +310,7 @@ describe("ScoredActionServiceClient.Start", function()
307
310
 
308
311
  expect(action:IsPreferred()).toBe(true)
309
312
 
310
- controller.destroy()
313
+ controller:Destroy()
311
314
  end)
312
315
 
313
316
  it("stops re-ranking once the service is destroyed", function()
@@ -321,7 +324,7 @@ describe("ScoredActionServiceClient.Start", function()
321
324
 
322
325
  expect(action:IsPreferred()).toBe(false)
323
326
 
324
- controller.destroy()
327
+ controller:Destroy()
325
328
  end)
326
329
  end)
327
330
 
@@ -338,6 +341,6 @@ describe("ScoredActionServiceClient.Destroy", function()
338
341
 
339
342
  expect(action:IsPreferred()).toBe(false)
340
343
 
341
- controller.destroy()
344
+ controller:Destroy()
342
345
  end)
343
346
  end)
@@ -6,6 +6,7 @@
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local Jest = require("Jest")
9
+ local JestUtils = require("JestUtils")
9
10
  local Maid = require("Maid")
10
11
  local ScoredAction = require("ScoredAction")
11
12
  local ScoredActionUtils = require("ScoredActionUtils")
@@ -18,7 +19,7 @@ type Controller = {
18
19
  newAction: () -> ScoredAction.ScoredAction,
19
20
  connect: (ScoredAction.ScoredAction, (Maid.Maid) -> ()) -> Maid.Maid,
20
21
  connectLoose: (ScoredAction.ScoredAction, (Maid.Maid) -> ()) -> Maid.Maid,
21
- destroy: () -> (),
22
+ Destroy: (self: Controller) -> (),
22
23
  }
23
24
 
24
25
  local function setup(): Controller
@@ -37,11 +38,13 @@ local function setup(): Controller
37
38
  return ScoredActionUtils.connectToPreferred(action, callback)
38
39
  end,
39
40
 
40
- destroy = function()
41
+ Destroy = function(_self)
41
42
  maid:DoCleaning()
42
43
  end,
43
44
  }
44
45
 
46
+ maid:GiveTask(JestUtils.afterThis(controller))
47
+
45
48
  return controller
46
49
  end
47
50
 
@@ -57,7 +60,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
57
60
 
58
61
  expect(calls).toBe(0)
59
62
 
60
- controller.destroy()
63
+ controller:Destroy()
61
64
  end)
62
65
 
63
66
  it("invokes the callback immediately for an already preferred action", function()
@@ -72,7 +75,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
72
75
 
73
76
  expect(calls).toBe(1)
74
77
 
75
- controller.destroy()
78
+ controller:Destroy()
76
79
  end)
77
80
 
78
81
  it("invokes the callback when the action becomes preferred", function()
@@ -88,7 +91,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
88
91
 
89
92
  expect(calls).toBe(1)
90
93
 
91
- controller.destroy()
94
+ controller:Destroy()
92
95
  end)
93
96
 
94
97
  it("does not re-invoke the callback for a second push", function()
@@ -105,7 +108,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
105
108
 
106
109
  expect(calls).toBe(1)
107
110
 
108
- controller.destroy()
111
+ controller:Destroy()
109
112
  end)
110
113
 
111
114
  it("invokes the callback again on a later push", function()
@@ -122,7 +125,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
122
125
 
123
126
  expect(calls).toBe(2)
124
127
 
125
- controller.destroy()
128
+ controller:Destroy()
126
129
  end)
127
130
 
128
131
  it("cleans up the callback maid when the action stops being preferred", function()
@@ -143,7 +146,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
143
146
 
144
147
  expect(cleaned).toBe(true)
145
148
 
146
- controller.destroy()
149
+ controller:Destroy()
147
150
  end)
148
151
 
149
152
  it("cleans up the callback maid when the returned maid is destroyed", function()
@@ -162,7 +165,7 @@ describe("ScoredActionUtils.connectToPreferred", function()
162
165
 
163
166
  expect(cleaned).toBe(true)
164
167
 
165
- controller.destroy()
168
+ controller:Destroy()
166
169
  end)
167
170
 
168
171
  it("cleans up a callback maid abandoned by a pop during the callback", function()
@@ -182,6 +185,6 @@ describe("ScoredActionUtils.connectToPreferred", function()
182
185
  expect(action:IsPreferred()).toBe(false)
183
186
  expect(cleaned).toBe(true)
184
187
 
185
- controller.destroy()
188
+ controller:Destroy()
186
189
  end)
187
190
  end)
@@ -7,6 +7,7 @@ local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local InputKeyMapService = require("InputKeyMapService")
9
9
  local Jest = require("Jest")
10
+ local JestUtils = require("JestUtils")
10
11
  local Maid = require("Maid")
11
12
  local ScoredActionService = require("ScoredActionService")
12
13
  local ServiceBag = require("ServiceBag")
@@ -18,7 +19,7 @@ local it = Jest.Globals.it
18
19
  type Controller = {
19
20
  serviceBag: ServiceBag.ServiceBag,
20
21
  service: any,
21
- destroy: () -> (),
22
+ Destroy: (self: Controller) -> (),
22
23
  }
23
24
 
24
25
  local function setup(): Controller
@@ -33,11 +34,13 @@ local function setup(): Controller
33
34
  serviceBag = serviceBag,
34
35
  service = service,
35
36
 
36
- destroy = function()
37
+ Destroy = function(_self)
37
38
  maid:DoCleaning()
38
39
  end,
39
40
  }
40
41
 
42
+ maid:GiveTask(JestUtils.afterThis(controller))
43
+
41
44
  return controller
42
45
  end
43
46
 
@@ -48,7 +51,7 @@ describe("ScoredActionService.Init", function()
48
51
  expect(controller.service).never.toBeNil()
49
52
  expect(ScoredActionService.ServiceName).toBe("ScoredActionService")
50
53
 
51
- controller.destroy()
54
+ controller:Destroy()
52
55
  end)
53
56
 
54
57
  it("registers the input key map service", function()
@@ -56,7 +59,7 @@ describe("ScoredActionService.Init", function()
56
59
 
57
60
  expect(controller.serviceBag:HasService(InputKeyMapService)).toBe(true)
58
61
 
59
- controller.destroy()
62
+ controller:Destroy()
60
63
  end)
61
64
 
62
65
  it("throws when initialized twice", function()
@@ -66,7 +69,7 @@ describe("ScoredActionService.Init", function()
66
69
  controller.service:Init(controller.serviceBag)
67
70
  end).toThrow()
68
71
 
69
- controller.destroy()
72
+ controller:Destroy()
70
73
  end)
71
74
 
72
75
  it("throws without a serviceBag", function()
@@ -76,6 +79,6 @@ describe("ScoredActionService.Init", function()
76
79
  (ScoredActionService :: any):Init(nil)
77
80
  end).toThrow()
78
81
 
79
- controller.destroy()
82
+ controller:Destroy()
80
83
  end)
81
84
  end)