@quenty/saveslot 2.10.0 → 2.11.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.
@@ -12,6 +12,7 @@ local require = require(script.Parent.loader).load(script)
12
12
  local DataStoreMock = require("DataStoreMock")
13
13
  local DataStoreTestUtils = require("DataStoreTestUtils")
14
14
  local Jest = require("Jest")
15
+ local JestUtils = require("JestUtils")
15
16
  local Maid = require("Maid")
16
17
  local Observable = require("Observable")
17
18
  local PlayerDataStoreService = require("PlayerDataStoreService")
@@ -32,6 +33,8 @@ local it = Jest.Globals.it
32
33
  local FAKE_USER_ID = 424242
33
34
 
34
35
  local function setup(mock: DataStoreMock.DataStoreMock?)
36
+ local maid = Maid.new()
37
+
35
38
  mock = mock or DataStoreMock.new()
36
39
 
37
40
  local serviceBag = ServiceBag.new()
@@ -50,23 +53,30 @@ local function setup(mock: DataStoreMock.DataStoreMock?)
50
53
  local hasSaveSlots = assert(binder:Bind(fakePlayer), "Failed to bind HasSaveSlots")
51
54
  hasSaveSlots.MaxSlotCount.Value = 5
52
55
 
53
- local function destroy()
54
- -- The store the spec loaded is only destroyed by a removal, and a PlayerMock never fires the
55
- -- real Players.PlayerRemoving, so shut down the way Roblox does or its auto-save loop outlives
56
- -- this spec and fires inside a later package's window.
56
+ -- A PlayerMock never fires the real Players.PlayerRemoving, and the store the spec loaded is only
57
+ -- destroyed by a removal, so shut it down the way Roblox does or its auto-save loop outlives this spec.
58
+ maid:GiveTask(function()
57
59
  DataStoreTestUtils.awaitServiceShutdown(playerDataStoreService)
58
60
  fakePlayer:Destroy()
59
61
  serviceBag:Destroy()
62
+ end)
63
+
64
+ local function Destroy(_self)
65
+ maid:DoCleaning()
60
66
  end
61
67
 
62
- return {
68
+ local controller = {
63
69
  serviceBag = serviceBag,
64
70
  binder = binder,
65
71
  fakePlayer = fakePlayer,
66
72
  hasSaveSlots = hasSaveSlots,
67
73
  mock = mock,
68
- destroy = destroy,
74
+ Destroy = Destroy,
69
75
  }
76
+
77
+ maid:GiveTask(JestUtils.afterThis(controller))
78
+
79
+ return controller
70
80
  end
71
81
 
72
82
  describe("HasSaveSlots against a fake player (healthy datastore)", function()
@@ -77,12 +87,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
77
87
  local promise = context.hasSaveSlots:PromiseSlotsLoaded()
78
88
  if not PromiseTestUtils.awaitSettled(promise, 10) then
79
89
  expect("slots load hung").toEqual("slots load settled")
80
- context.destroy()
90
+ context:Destroy()
81
91
  return
82
92
  end
83
93
  expect((promise:Yield())).toEqual(true)
84
94
 
85
- context.destroy()
95
+ context:Destroy()
86
96
  end)
87
97
 
88
98
  it("should create a slot and find it", function()
@@ -91,7 +101,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
91
101
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
92
102
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
93
103
  expect("create hung").toEqual("create settled")
94
- context.destroy()
104
+ context:Destroy()
95
105
  return
96
106
  end
97
107
  local ok, slotId = createPromise:Yield()
@@ -101,7 +111,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
101
111
  local hasPromise = context.hasSaveSlots:PromiseHasSlot(slotId)
102
112
  if not PromiseTestUtils.awaitSettled(hasPromise, 10) then
103
113
  expect("hasSlot hung").toEqual("hasSlot settled")
104
- context.destroy()
114
+ context:Destroy()
105
115
  return
106
116
  end
107
117
  expect((hasPromise:Wait())).toEqual(true)
@@ -109,12 +119,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
109
119
  local indexPromise = context.hasSaveSlots:PromiseSlotIdFromIndex(1)
110
120
  if not PromiseTestUtils.awaitSettled(indexPromise, 10) then
111
121
  expect("slotIdFromIndex hung").toEqual("slotIdFromIndex settled")
112
- context.destroy()
122
+ context:Destroy()
113
123
  return
114
124
  end
115
125
  expect((indexPromise:Wait())).toEqual(slotId)
116
126
 
117
- context.destroy()
127
+ context:Destroy()
118
128
  end)
119
129
 
120
130
  it("should select a slot and report it active", function()
@@ -123,7 +133,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
123
133
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
124
134
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
125
135
  expect("create hung").toEqual("create settled")
126
- context.destroy()
136
+ context:Destroy()
127
137
  return
128
138
  end
129
139
  local _, slotId = createPromise:Yield()
@@ -131,7 +141,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
131
141
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
132
142
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
133
143
  expect("select hung").toEqual("select settled")
134
- context.destroy()
144
+ context:Destroy()
135
145
  return
136
146
  end
137
147
  expect((selectPromise:Yield())).toEqual(true)
@@ -141,12 +151,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
141
151
  local lastPromise = context.hasSaveSlots:PromiseLastActiveSlotId()
142
152
  if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
143
153
  expect("lastActive hung").toEqual("lastActive settled")
144
- context.destroy()
154
+ context:Destroy()
145
155
  return
146
156
  end
147
157
  expect((lastPromise:Wait())).toEqual(slotId)
148
158
 
149
- context.destroy()
159
+ context:Destroy()
150
160
  end)
151
161
 
152
162
  it("should observe the active slot store after selection", function()
@@ -155,7 +165,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
155
165
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
156
166
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
157
167
  expect("create hung").toEqual("create settled")
158
- context.destroy()
168
+ context:Destroy()
159
169
  return
160
170
  end
161
171
  local _, slotId = createPromise:Yield()
@@ -163,7 +173,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
163
173
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
164
174
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
165
175
  expect("select hung").toEqual("select settled")
166
- context.destroy()
176
+ context:Destroy()
167
177
  return
168
178
  end
169
179
  selectPromise:Yield()
@@ -182,7 +192,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
182
192
 
183
193
  expect(emitted).toEqual(true)
184
194
 
185
- context.destroy()
195
+ context:Destroy()
186
196
  end)
187
197
 
188
198
  it("ObserveActiveSlotStoreBrio tears its brio down once the active slot is deselected", function()
@@ -191,7 +201,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
191
201
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
192
202
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
193
203
  expect("create hung").toEqual("create settled")
194
- context.destroy()
204
+ context:Destroy()
195
205
  return
196
206
  end
197
207
  local _, slotId = createPromise:Yield()
@@ -199,7 +209,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
199
209
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
200
210
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
201
211
  expect("select hung").toEqual("select settled")
202
- context.destroy()
212
+ context:Destroy()
203
213
  return
204
214
  end
205
215
  selectPromise:Yield()
@@ -221,7 +231,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
221
231
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
222
232
  expect("deselect hung").toEqual("deselect settled")
223
233
  subscription:Destroy()
224
- context.destroy()
234
+ context:Destroy()
225
235
  return
226
236
  end
227
237
  deselectPromise:Yield()
@@ -229,7 +239,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
229
239
  expect(activeBrio:IsDead()).toEqual(true)
230
240
 
231
241
  subscription:Destroy()
232
- context.destroy()
242
+ context:Destroy()
233
243
  end)
234
244
 
235
245
  it("ObserveActiveSlotStoreBrio swaps its brio when switching to another slot", function()
@@ -238,7 +248,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
238
248
  local firstCreate = context.hasSaveSlots:PromiseCreateSlot(1)
239
249
  if not PromiseTestUtils.awaitSettled(firstCreate, 10) then
240
250
  expect("first create hung").toEqual("first create settled")
241
- context.destroy()
251
+ context:Destroy()
242
252
  return
243
253
  end
244
254
  local _, firstSlotId = firstCreate:Yield()
@@ -246,7 +256,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
246
256
  local secondCreate = context.hasSaveSlots:PromiseCreateSlot(2)
247
257
  if not PromiseTestUtils.awaitSettled(secondCreate, 10) then
248
258
  expect("second create hung").toEqual("second create settled")
249
- context.destroy()
259
+ context:Destroy()
250
260
  return
251
261
  end
252
262
  local _, secondSlotId = secondCreate:Yield()
@@ -254,7 +264,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
254
264
  local selectFirst = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
255
265
  if not PromiseTestUtils.awaitSettled(selectFirst, 10) then
256
266
  expect("select hung").toEqual("select settled")
257
- context.destroy()
267
+ context:Destroy()
258
268
  return
259
269
  end
260
270
  selectFirst:Yield()
@@ -271,7 +281,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
271
281
  end, 10) then
272
282
  expect("first brio hung").toEqual("first brio emitted")
273
283
  subscription:Destroy()
274
- context.destroy()
284
+ context:Destroy()
275
285
  return
276
286
  end
277
287
  local firstBrio = currentBrio
@@ -280,7 +290,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
280
290
  if not PromiseTestUtils.awaitSettled(selectSecond, 10) then
281
291
  expect("switch hung").toEqual("switch settled")
282
292
  subscription:Destroy()
283
- context.destroy()
293
+ context:Destroy()
284
294
  return
285
295
  end
286
296
  selectSecond:Yield()
@@ -290,7 +300,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
290
300
  end, 10) then
291
301
  expect("second brio hung").toEqual("second brio emitted")
292
302
  subscription:Destroy()
293
- context.destroy()
303
+ context:Destroy()
294
304
  return
295
305
  end
296
306
 
@@ -298,7 +308,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
298
308
  expect(currentBrio:IsDead()).toEqual(false)
299
309
 
300
310
  subscription:Destroy()
301
- context.destroy()
311
+ context:Destroy()
302
312
  end)
303
313
 
304
314
  it("should reject creating a slot beyond the max slot count", function()
@@ -308,12 +318,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
308
318
  local promise = context.hasSaveSlots:PromiseCreateSlot(2)
309
319
  if not PromiseTestUtils.awaitSettled(promise, 10) then
310
320
  expect("create hung").toEqual("create settled")
311
- context.destroy()
321
+ context:Destroy()
312
322
  return
313
323
  end
314
324
  expect((promise:Yield())).toEqual(false)
315
325
 
316
- context.destroy()
326
+ context:Destroy()
317
327
  end)
318
328
 
319
329
  it("should reject creating a duplicate slot index", function()
@@ -322,7 +332,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
322
332
  local firstPromise = context.hasSaveSlots:PromiseCreateSlot(1)
323
333
  if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
324
334
  expect("first create hung").toEqual("first create settled")
325
- context.destroy()
335
+ context:Destroy()
326
336
  return
327
337
  end
328
338
  firstPromise:Yield()
@@ -330,12 +340,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
330
340
  local secondPromise = context.hasSaveSlots:PromiseCreateSlot(1)
331
341
  if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
332
342
  expect("second create hung").toEqual("second create settled")
333
- context.destroy()
343
+ context:Destroy()
334
344
  return
335
345
  end
336
346
  expect((secondPromise:Yield())).toEqual(false)
337
347
 
338
- context.destroy()
348
+ context:Destroy()
339
349
  end)
340
350
 
341
351
  it("should reject deleting the active slot", function()
@@ -344,7 +354,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
344
354
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
345
355
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
346
356
  expect("create hung").toEqual("create settled")
347
- context.destroy()
357
+ context:Destroy()
348
358
  return
349
359
  end
350
360
  local _, slotId = createPromise:Yield()
@@ -352,7 +362,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
352
362
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
353
363
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
354
364
  expect("select hung").toEqual("select settled")
355
- context.destroy()
365
+ context:Destroy()
356
366
  return
357
367
  end
358
368
  selectPromise:Yield()
@@ -360,12 +370,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
360
370
  local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(slotId)
361
371
  if not PromiseTestUtils.awaitSettled(deletePromise, 10) then
362
372
  expect("delete hung").toEqual("delete settled")
363
- context.destroy()
373
+ context:Destroy()
364
374
  return
365
375
  end
366
376
  expect((deletePromise:Yield())).toEqual(false)
367
377
 
368
- context.destroy()
378
+ context:Destroy()
369
379
  end)
370
380
 
371
381
  it("should replicate the last active slot after selection", function()
@@ -374,7 +384,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
374
384
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
375
385
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
376
386
  expect("create hung").toEqual("create settled")
377
- context.destroy()
387
+ context:Destroy()
378
388
  return
379
389
  end
380
390
  local _, slotId = createPromise:Yield()
@@ -382,14 +392,14 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
382
392
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
383
393
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
384
394
  expect("select hung").toEqual("select settled")
385
- context.destroy()
395
+ context:Destroy()
386
396
  return
387
397
  end
388
398
  selectPromise:Yield()
389
399
 
390
400
  expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
391
401
 
392
- context.destroy()
402
+ context:Destroy()
393
403
  end)
394
404
 
395
405
  it("PromiseDeselectSlot clears the active slot but remembers the last active", function()
@@ -398,7 +408,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
398
408
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
399
409
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
400
410
  expect("create hung").toEqual("create settled")
401
- context.destroy()
411
+ context:Destroy()
402
412
  return
403
413
  end
404
414
  local _, slotId = createPromise:Yield()
@@ -406,7 +416,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
406
416
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
407
417
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
408
418
  expect("select hung").toEqual("select settled")
409
- context.destroy()
419
+ context:Destroy()
410
420
  return
411
421
  end
412
422
  selectPromise:Yield()
@@ -414,7 +424,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
414
424
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
415
425
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
416
426
  expect("deselect hung").toEqual("deselect settled")
417
- context.destroy()
427
+ context:Destroy()
418
428
  return
419
429
  end
420
430
  expect((deselectPromise:Yield())).toEqual(true)
@@ -425,12 +435,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
425
435
  local lastPromise = context.hasSaveSlots:PromiseLastActiveSlotId()
426
436
  if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
427
437
  expect("lastActive hung").toEqual("lastActive settled")
428
- context.destroy()
438
+ context:Destroy()
429
439
  return
430
440
  end
431
441
  expect((lastPromise:Wait())).toEqual(slotId)
432
442
 
433
- context.destroy()
443
+ context:Destroy()
434
444
  end)
435
445
 
436
446
  it("deleting the last-active slot clears the continue pointer", function()
@@ -441,7 +451,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
441
451
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
442
452
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
443
453
  expect("create hung").toEqual("create settled")
444
- context.destroy()
454
+ context:Destroy()
445
455
  return
446
456
  end
447
457
  local _, slotId = createPromise:Yield()
@@ -449,7 +459,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
449
459
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
450
460
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
451
461
  expect("select hung").toEqual("select settled")
452
- context.destroy()
462
+ context:Destroy()
453
463
  return
454
464
  end
455
465
  selectPromise:Yield()
@@ -457,7 +467,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
457
467
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
458
468
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
459
469
  expect("deselect hung").toEqual("deselect settled")
460
- context.destroy()
470
+ context:Destroy()
461
471
  return
462
472
  end
463
473
  deselectPromise:Yield()
@@ -467,7 +477,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
467
477
  local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(slotId)
468
478
  if not PromiseTestUtils.awaitSettled(deletePromise, 10) then
469
479
  expect("delete hung").toEqual("delete settled")
470
- context.destroy()
480
+ context:Destroy()
471
481
  return
472
482
  end
473
483
  deletePromise:Yield()
@@ -477,12 +487,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
477
487
  local lastPromise = context.hasSaveSlots:PromiseLastActiveSlotId()
478
488
  if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
479
489
  expect("lastActive hung").toEqual("lastActive settled")
480
- context.destroy()
490
+ context:Destroy()
481
491
  return
482
492
  end
483
493
  expect((lastPromise:Wait())).toBeNil()
484
494
 
485
- context.destroy()
495
+ context:Destroy()
486
496
  end)
487
497
 
488
498
  it("deleting a non-last-active slot leaves the continue pointer intact", function()
@@ -491,7 +501,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
491
501
  local firstPromise = context.hasSaveSlots:PromiseCreateSlot(1)
492
502
  if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
493
503
  expect("first create hung").toEqual("first create settled")
494
- context.destroy()
504
+ context:Destroy()
495
505
  return
496
506
  end
497
507
  local _, firstSlotId = firstPromise:Yield()
@@ -499,7 +509,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
499
509
  local secondPromise = context.hasSaveSlots:PromiseCreateSlot(2)
500
510
  if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
501
511
  expect("second create hung").toEqual("second create settled")
502
- context.destroy()
512
+ context:Destroy()
503
513
  return
504
514
  end
505
515
  local _, secondSlotId = secondPromise:Yield()
@@ -507,7 +517,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
507
517
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
508
518
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
509
519
  expect("select hung").toEqual("select settled")
510
- context.destroy()
520
+ context:Destroy()
511
521
  return
512
522
  end
513
523
  selectPromise:Yield()
@@ -515,7 +525,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
515
525
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
516
526
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
517
527
  expect("deselect hung").toEqual("deselect settled")
518
- context.destroy()
528
+ context:Destroy()
519
529
  return
520
530
  end
521
531
  deselectPromise:Yield()
@@ -523,14 +533,14 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
523
533
  local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(secondSlotId)
524
534
  if not PromiseTestUtils.awaitSettled(deletePromise, 10) then
525
535
  expect("delete hung").toEqual("delete settled")
526
- context.destroy()
536
+ context:Destroy()
527
537
  return
528
538
  end
529
539
  deletePromise:Yield()
530
540
 
531
541
  expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(firstSlotId)
532
542
 
533
- context.destroy()
543
+ context:Destroy()
534
544
  end)
535
545
 
536
546
  it("PromiseDeselectSlot is a no-op when no slot is active", function()
@@ -539,13 +549,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
539
549
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
540
550
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
541
551
  expect("deselect hung").toEqual("deselect settled")
542
- context.destroy()
552
+ context:Destroy()
543
553
  return
544
554
  end
545
555
  expect((deselectPromise:Yield())).toEqual(true)
546
556
  expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
547
557
 
548
- context.destroy()
558
+ context:Destroy()
549
559
  end)
550
560
 
551
561
  it("PromiseDeselectSlot then PromiseSelectLastSaveSlot round-trips back into the slot", function()
@@ -554,7 +564,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
554
564
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
555
565
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
556
566
  expect("create hung").toEqual("create settled")
557
- context.destroy()
567
+ context:Destroy()
558
568
  return
559
569
  end
560
570
  local _, slotId = createPromise:Yield()
@@ -562,7 +572,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
562
572
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
563
573
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
564
574
  expect("select hung").toEqual("select settled")
565
- context.destroy()
575
+ context:Destroy()
566
576
  return
567
577
  end
568
578
  selectPromise:Yield()
@@ -570,7 +580,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
570
580
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
571
581
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
572
582
  expect("deselect hung").toEqual("deselect settled")
573
- context.destroy()
583
+ context:Destroy()
574
584
  return
575
585
  end
576
586
  deselectPromise:Yield()
@@ -579,13 +589,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
579
589
  local continuePromise = context.hasSaveSlots:PromiseSelectLastSaveSlot()
580
590
  if not PromiseTestUtils.awaitSettled(continuePromise, 10) then
581
591
  expect("continue hung").toEqual("continue settled")
582
- context.destroy()
592
+ context:Destroy()
583
593
  return
584
594
  end
585
595
  expect((continuePromise:Wait())).toEqual(slotId)
586
596
  expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
587
597
 
588
- context.destroy()
598
+ context:Destroy()
589
599
  end)
590
600
 
591
601
  it("PromiseSelectLastSaveSlot re-selects the last active slot after the active slot is cleared", function()
@@ -594,7 +604,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
594
604
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
595
605
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
596
606
  expect("create hung").toEqual("create settled")
597
- context.destroy()
607
+ context:Destroy()
598
608
  return
599
609
  end
600
610
  local _, slotId = createPromise:Yield()
@@ -602,7 +612,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
602
612
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
603
613
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
604
614
  expect("select hung").toEqual("select settled")
605
- context.destroy()
615
+ context:Destroy()
606
616
  return
607
617
  end
608
618
  selectPromise:Yield()
@@ -613,13 +623,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
613
623
  local continuePromise = context.hasSaveSlots:PromiseSelectLastSaveSlot()
614
624
  if not PromiseTestUtils.awaitSettled(continuePromise, 10) then
615
625
  expect("continue hung").toEqual("continue settled")
616
- context.destroy()
626
+ context:Destroy()
617
627
  return
618
628
  end
619
629
  expect((continuePromise:Wait())).toEqual(slotId)
620
630
  expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
621
631
 
622
- context.destroy()
632
+ context:Destroy()
623
633
  end)
624
634
 
625
635
  it("PromiseSelectLastSaveSlot resolves nil when there is nothing to continue", function()
@@ -628,13 +638,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
628
638
  local continuePromise = context.hasSaveSlots:PromiseSelectLastSaveSlot()
629
639
  if not PromiseTestUtils.awaitSettled(continuePromise, 10) then
630
640
  expect("continue hung").toEqual("continue settled")
631
- context.destroy()
641
+ context:Destroy()
632
642
  return
633
643
  end
634
644
  expect((continuePromise:Wait())).toBeNil()
635
645
  expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
636
646
 
637
- context.destroy()
647
+ context:Destroy()
638
648
  end)
639
649
 
640
650
  it("PromiseSelectNewSaveSlot creates and selects a fresh slot each time", function()
@@ -643,7 +653,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
643
653
  local firstPromise = context.hasSaveSlots:PromiseSelectNewSaveSlot()
644
654
  if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
645
655
  expect("new game hung").toEqual("new game settled")
646
- context.destroy()
656
+ context:Destroy()
647
657
  return
648
658
  end
649
659
  local firstSlotId = firstPromise:Wait()
@@ -653,14 +663,14 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
653
663
  local secondPromise = context.hasSaveSlots:PromiseSelectNewSaveSlot()
654
664
  if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
655
665
  expect("second new game hung").toEqual("second new game settled")
656
- context.destroy()
666
+ context:Destroy()
657
667
  return
658
668
  end
659
669
  local secondSlotId = secondPromise:Wait()
660
670
  expect(type(secondSlotId)).toEqual("string")
661
671
  expect(secondSlotId ~= firstSlotId).toEqual(true)
662
672
 
663
- context.destroy()
673
+ context:Destroy()
664
674
  end)
665
675
 
666
676
  it("PromiseDeleteAllSlots wipes every slot and clears the selection", function()
@@ -669,7 +679,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
669
679
  local firstPromise = context.hasSaveSlots:PromiseCreateSlot(1)
670
680
  if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
671
681
  expect("first create hung").toEqual("first create settled")
672
- context.destroy()
682
+ context:Destroy()
673
683
  return
674
684
  end
675
685
  local _, firstSlotId = firstPromise:Yield()
@@ -677,7 +687,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
677
687
  local secondPromise = context.hasSaveSlots:PromiseCreateSlot(2)
678
688
  if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
679
689
  expect("second create hung").toEqual("second create settled")
680
- context.destroy()
690
+ context:Destroy()
681
691
  return
682
692
  end
683
693
  secondPromise:Yield()
@@ -685,7 +695,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
685
695
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
686
696
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
687
697
  expect("select hung").toEqual("select settled")
688
- context.destroy()
698
+ context:Destroy()
689
699
  return
690
700
  end
691
701
  selectPromise:Yield()
@@ -693,7 +703,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
693
703
  local wipePromise = context.hasSaveSlots:PromiseDeleteAllSlots()
694
704
  if not PromiseTestUtils.awaitSettled(wipePromise, 10) then
695
705
  expect("wipe hung").toEqual("wipe settled")
696
- context.destroy()
706
+ context:Destroy()
697
707
  return
698
708
  end
699
709
  wipePromise:Yield()
@@ -704,12 +714,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
704
714
  local hasPromise = context.hasSaveSlots:PromiseHasSlot(firstSlotId)
705
715
  if not PromiseTestUtils.awaitSettled(hasPromise, 10) then
706
716
  expect("hasSlot hung").toEqual("hasSlot settled")
707
- context.destroy()
717
+ context:Destroy()
708
718
  return
709
719
  end
710
720
  expect((hasPromise:Wait())).toEqual(false)
711
721
 
712
- context.destroy()
722
+ context:Destroy()
713
723
  end)
714
724
 
715
725
  it("PromiseSelectNewSaveSlot reuses the lowest free index after a deletion", function()
@@ -720,7 +730,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
720
730
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(index)
721
731
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
722
732
  expect("create hung").toEqual("create settled")
723
- context.destroy()
733
+ context:Destroy()
724
734
  return
725
735
  end
726
736
  local _, slotId = createPromise:Yield()
@@ -730,7 +740,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
730
740
  local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(slotIdsByIndex[2])
731
741
  if not PromiseTestUtils.awaitSettled(deletePromise, 10) then
732
742
  expect("delete hung").toEqual("delete settled")
733
- context.destroy()
743
+ context:Destroy()
734
744
  return
735
745
  end
736
746
  deletePromise:Yield()
@@ -738,7 +748,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
738
748
  local newPromise = context.hasSaveSlots:PromiseSelectNewSaveSlot()
739
749
  if not PromiseTestUtils.awaitSettled(newPromise, 10) then
740
750
  expect("new game hung").toEqual("new game settled")
741
- context.destroy()
751
+ context:Destroy()
742
752
  return
743
753
  end
744
754
  local newSlotId = newPromise:Wait()
@@ -747,12 +757,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
747
757
  local metadataPromise = context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId)
748
758
  if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
749
759
  expect("metadata hung").toEqual("metadata settled")
750
- context.destroy()
760
+ context:Destroy()
751
761
  return
752
762
  end
753
763
  expect((metadataPromise:Wait()).SlotIndex).toEqual(2)
754
764
 
755
- context.destroy()
765
+ context:Destroy()
756
766
  end)
757
767
 
758
768
  it("PromiseDuplicateSlot copies saved data into a fresh slot and marks the name", function()
@@ -761,7 +771,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
761
771
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1, { SlotName = "Adventure" })
762
772
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
763
773
  expect("create hung").toEqual("create settled")
764
- context.destroy()
774
+ context:Destroy()
765
775
  return
766
776
  end
767
777
  local _, slotId = createPromise:Yield()
@@ -772,7 +782,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
772
782
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
773
783
  if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
774
784
  expect("duplicate hung").toEqual("duplicate settled")
775
- context.destroy()
785
+ context:Destroy()
776
786
  return
777
787
  end
778
788
  local newSlotId = duplicatePromise:Wait()
@@ -782,7 +792,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
782
792
  local metadataPromise = context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId)
783
793
  if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
784
794
  expect("metadata hung").toEqual("metadata settled")
785
- context.destroy()
795
+ context:Destroy()
786
796
  return
787
797
  end
788
798
  local metadata = metadataPromise:Wait()
@@ -792,12 +802,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
792
802
  local dataPromise = tracker:_getSlotStore(newSlotId):Load("Coins")
793
803
  if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
794
804
  expect("data hung").toEqual("data settled")
795
- context.destroy()
805
+ context:Destroy()
796
806
  return
797
807
  end
798
808
  expect((dataPromise:Wait())).toEqual(500)
799
809
 
800
- context.destroy()
810
+ context:Destroy()
801
811
  end)
802
812
 
803
813
  it("PromiseDuplicateSlot into the default slot preserves the system store", function()
@@ -806,7 +816,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
806
816
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Save" })
807
817
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
808
818
  expect("create hung").toEqual("create settled")
809
- context.destroy()
819
+ context:Destroy()
810
820
  return
811
821
  end
812
822
  local _, slotId = createPromise:Yield()
@@ -817,7 +827,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
817
827
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
818
828
  if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
819
829
  expect("duplicate hung").toEqual("duplicate settled")
820
- context.destroy()
830
+ context:Destroy()
821
831
  return
822
832
  end
823
833
  local newSlotId = duplicatePromise:Wait()
@@ -825,7 +835,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
825
835
  local metadataPromise = context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId)
826
836
  if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
827
837
  expect("metadata hung").toEqual("metadata settled")
828
- context.destroy()
838
+ context:Destroy()
829
839
  return
830
840
  end
831
841
  expect((metadataPromise:Wait()).SlotIndex).toEqual(1)
@@ -833,7 +843,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
833
843
  local sourceStillThere = context.hasSaveSlots:PromiseSlotIdFromIndex(2)
834
844
  if not PromiseTestUtils.awaitSettled(sourceStillThere, 10) then
835
845
  expect("lookup hung").toEqual("lookup settled")
836
- context.destroy()
846
+ context:Destroy()
837
847
  return
838
848
  end
839
849
  expect((sourceStillThere:Wait())).toEqual(slotId)
@@ -841,12 +851,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
841
851
  local dataPromise = tracker:_getSlotStore(newSlotId):Load("Coins")
842
852
  if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
843
853
  expect("data hung").toEqual("data settled")
844
- context.destroy()
854
+ context:Destroy()
845
855
  return
846
856
  end
847
857
  expect((dataPromise:Wait())).toEqual(750)
848
858
 
849
- context.destroy()
859
+ context:Destroy()
850
860
  end)
851
861
 
852
862
  it("PromiseDuplicateSlot rejects when the source slot is missing", function()
@@ -855,12 +865,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
855
865
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot("does-not-exist")
856
866
  if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
857
867
  expect("duplicate hung").toEqual("duplicate settled")
858
- context.destroy()
868
+ context:Destroy()
859
869
  return
860
870
  end
861
871
  expect((duplicatePromise:Yield())).toEqual(false)
862
872
 
863
- context.destroy()
873
+ context:Destroy()
864
874
  end)
865
875
 
866
876
  it("PromiseResetActiveSlot wipes saved data but keeps the slot's index and name", function()
@@ -869,7 +879,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
869
879
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Adventure" })
870
880
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
871
881
  expect("create hung").toEqual("create settled")
872
- context.destroy()
882
+ context:Destroy()
873
883
  return
874
884
  end
875
885
  local _, slotId = createPromise:Yield()
@@ -877,7 +887,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
877
887
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
878
888
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
879
889
  expect("select hung").toEqual("select settled")
880
- context.destroy()
890
+ context:Destroy()
881
891
  return
882
892
  end
883
893
  selectPromise:Yield()
@@ -888,7 +898,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
888
898
  local resetPromise = context.hasSaveSlots:PromiseResetActiveSlot()
889
899
  if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
890
900
  expect("reset hung").toEqual("reset settled")
891
- context.destroy()
901
+ context:Destroy()
892
902
  return
893
903
  end
894
904
  local newSlotId = resetPromise:Wait()
@@ -899,7 +909,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
899
909
  local hasOldPromise = context.hasSaveSlots:PromiseHasSlot(slotId)
900
910
  if not PromiseTestUtils.awaitSettled(hasOldPromise, 10) then
901
911
  expect("hasSlot hung").toEqual("hasSlot settled")
902
- context.destroy()
912
+ context:Destroy()
903
913
  return
904
914
  end
905
915
  expect((hasOldPromise:Wait())).toEqual(false)
@@ -907,7 +917,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
907
917
  local metadataPromise = context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId)
908
918
  if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
909
919
  expect("metadata hung").toEqual("metadata settled")
910
- context.destroy()
920
+ context:Destroy()
911
921
  return
912
922
  end
913
923
  local metadata = metadataPromise:Wait()
@@ -917,12 +927,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
917
927
  local dataPromise = tracker:_getSlotStore(newSlotId):Load("Coins")
918
928
  if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
919
929
  expect("data hung").toEqual("data settled")
920
- context.destroy()
930
+ context:Destroy()
921
931
  return
922
932
  end
923
933
  expect((dataPromise:Wait())).toBeNil()
924
934
 
925
- context.destroy()
935
+ context:Destroy()
926
936
  end)
927
937
 
928
938
  it("PromiseResetActiveSlot resets the default slot in place, preserving the system store", function()
@@ -931,7 +941,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
931
941
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1, { SlotName = "Save" })
932
942
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
933
943
  expect("create hung").toEqual("create settled")
934
- context.destroy()
944
+ context:Destroy()
935
945
  return
936
946
  end
937
947
  local _, slotId = createPromise:Yield()
@@ -939,7 +949,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
939
949
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
940
950
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
941
951
  expect("select hung").toEqual("select settled")
942
- context.destroy()
952
+ context:Destroy()
943
953
  return
944
954
  end
945
955
  selectPromise:Yield()
@@ -950,7 +960,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
950
960
  local resetPromise = context.hasSaveSlots:PromiseResetActiveSlot()
951
961
  if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
952
962
  expect("reset hung").toEqual("reset settled")
953
- context.destroy()
963
+ context:Destroy()
954
964
  return
955
965
  end
956
966
  local newSlotId = resetPromise:Wait()
@@ -958,7 +968,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
958
968
  local lookupPromise = context.hasSaveSlots:PromiseSlotIdFromIndex(1)
959
969
  if not PromiseTestUtils.awaitSettled(lookupPromise, 10) then
960
970
  expect("lookup hung").toEqual("lookup settled")
961
- context.destroy()
971
+ context:Destroy()
962
972
  return
963
973
  end
964
974
  expect((lookupPromise:Wait())).toEqual(newSlotId)
@@ -966,12 +976,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
966
976
  local dataPromise = tracker:_getSlotStore(newSlotId):Load("Coins")
967
977
  if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
968
978
  expect("data hung").toEqual("data settled")
969
- context.destroy()
979
+ context:Destroy()
970
980
  return
971
981
  end
972
982
  expect((dataPromise:Wait())).toBeNil()
973
983
 
974
- context.destroy()
984
+ context:Destroy()
975
985
  end)
976
986
 
977
987
  it("PromiseResetActiveSlot is a no-op resolving nil when no slot is active", function()
@@ -980,13 +990,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
980
990
  local resetPromise = context.hasSaveSlots:PromiseResetActiveSlot()
981
991
  if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
982
992
  expect("reset hung").toEqual("reset settled")
983
- context.destroy()
993
+ context:Destroy()
984
994
  return
985
995
  end
986
996
  expect((resetPromise:Wait())).toBeNil()
987
997
  expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
988
998
 
989
- context.destroy()
999
+ context:Destroy()
990
1000
  end)
991
1001
 
992
1002
  it("PromiseResetSlot wipes a non-active slot without touching the active selection", function()
@@ -995,7 +1005,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
995
1005
  local activePromise = context.hasSaveSlots:PromiseCreateSlot(1)
996
1006
  if not PromiseTestUtils.awaitSettled(activePromise, 10) then
997
1007
  expect("active create hung").toEqual("active create settled")
998
- context.destroy()
1008
+ context:Destroy()
999
1009
  return
1000
1010
  end
1001
1011
  local _, activeSlotId = activePromise:Yield()
@@ -1003,7 +1013,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1003
1013
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(activeSlotId)
1004
1014
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
1005
1015
  expect("select hung").toEqual("select settled")
1006
- context.destroy()
1016
+ context:Destroy()
1007
1017
  return
1008
1018
  end
1009
1019
  selectPromise:Yield()
@@ -1011,7 +1021,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1011
1021
  local targetPromise = context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Adventure" })
1012
1022
  if not PromiseTestUtils.awaitSettled(targetPromise, 10) then
1013
1023
  expect("target create hung").toEqual("target create settled")
1014
- context.destroy()
1024
+ context:Destroy()
1015
1025
  return
1016
1026
  end
1017
1027
  local _, targetSlotId = targetPromise:Yield()
@@ -1022,7 +1032,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1022
1032
  local resetPromise = context.hasSaveSlots:PromiseResetSlot(targetSlotId)
1023
1033
  if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
1024
1034
  expect("reset hung").toEqual("reset settled")
1025
- context.destroy()
1035
+ context:Destroy()
1026
1036
  return
1027
1037
  end
1028
1038
  local newSlotId = resetPromise:Wait()
@@ -1034,7 +1044,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1034
1044
  local metadataPromise = context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId)
1035
1045
  if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
1036
1046
  expect("metadata hung").toEqual("metadata settled")
1037
- context.destroy()
1047
+ context:Destroy()
1038
1048
  return
1039
1049
  end
1040
1050
  local metadata = metadataPromise:Wait()
@@ -1044,12 +1054,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1044
1054
  local dataPromise = tracker:_getSlotStore(newSlotId):Load("Coins")
1045
1055
  if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
1046
1056
  expect("data hung").toEqual("data settled")
1047
- context.destroy()
1057
+ context:Destroy()
1048
1058
  return
1049
1059
  end
1050
1060
  expect((dataPromise:Wait())).toBeNil()
1051
1061
 
1052
- context.destroy()
1062
+ context:Destroy()
1053
1063
  end)
1054
1064
 
1055
1065
  it("PromiseResetSlot keeps the continue pointer on the reset slot when it was last-active", function()
@@ -1058,7 +1068,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1058
1068
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
1059
1069
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
1060
1070
  expect("create hung").toEqual("create settled")
1061
- context.destroy()
1071
+ context:Destroy()
1062
1072
  return
1063
1073
  end
1064
1074
  local _, slotId = createPromise:Yield()
@@ -1066,7 +1076,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1066
1076
  local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
1067
1077
  if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
1068
1078
  expect("select hung").toEqual("select settled")
1069
- context.destroy()
1079
+ context:Destroy()
1070
1080
  return
1071
1081
  end
1072
1082
  selectPromise:Yield()
@@ -1074,7 +1084,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1074
1084
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
1075
1085
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
1076
1086
  expect("deselect hung").toEqual("deselect settled")
1077
- context.destroy()
1087
+ context:Destroy()
1078
1088
  return
1079
1089
  end
1080
1090
  deselectPromise:Yield()
@@ -1083,7 +1093,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1083
1093
  local resetPromise = context.hasSaveSlots:PromiseResetSlot(slotId)
1084
1094
  if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
1085
1095
  expect("reset hung").toEqual("reset settled")
1086
- context.destroy()
1096
+ context:Destroy()
1087
1097
  return
1088
1098
  end
1089
1099
  local newSlotId = resetPromise:Wait()
@@ -1094,12 +1104,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1094
1104
  local lastPromise = context.hasSaveSlots:PromiseLastActiveSlotId()
1095
1105
  if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
1096
1106
  expect("lastActive hung").toEqual("lastActive settled")
1097
- context.destroy()
1107
+ context:Destroy()
1098
1108
  return
1099
1109
  end
1100
1110
  expect((lastPromise:Wait())).toEqual(newSlotId)
1101
1111
 
1102
- context.destroy()
1112
+ context:Destroy()
1103
1113
  end)
1104
1114
 
1105
1115
  it("PromiseResetSlot rejects when the slot is missing", function()
@@ -1108,12 +1118,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1108
1118
  local resetPromise = context.hasSaveSlots:PromiseResetSlot("does-not-exist")
1109
1119
  if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
1110
1120
  expect("reset hung").toEqual("reset settled")
1111
- context.destroy()
1121
+ context:Destroy()
1112
1122
  return
1113
1123
  end
1114
1124
  expect((resetPromise:Yield())).toEqual(false)
1115
1125
 
1116
- context.destroy()
1126
+ context:Destroy()
1117
1127
  end)
1118
1128
 
1119
1129
  it("allows creating a slot past a finite cap when the count is unbounded", function()
@@ -1123,14 +1133,14 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1123
1133
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(6)
1124
1134
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
1125
1135
  expect("create hung").toEqual("create settled")
1126
- context.destroy()
1136
+ context:Destroy()
1127
1137
  return
1128
1138
  end
1129
1139
  local ok, slotId = createPromise:Yield()
1130
1140
  expect(ok).toEqual(true)
1131
1141
  expect(type(slotId)).toEqual("string")
1132
1142
 
1133
- context.destroy()
1143
+ context:Destroy()
1134
1144
  end)
1135
1145
 
1136
1146
  it("PromiseSelectNewSaveSlot never runs out of slots when unbounded", function()
@@ -1141,13 +1151,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1141
1151
  local newPromise = context.hasSaveSlots:PromiseSelectNewSaveSlot()
1142
1152
  if not PromiseTestUtils.awaitSettled(newPromise, 10) then
1143
1153
  expect("new game hung").toEqual("new game settled")
1144
- context.destroy()
1154
+ context:Destroy()
1145
1155
  return
1146
1156
  end
1147
1157
  expect(type(newPromise:Wait())).toEqual("string")
1148
1158
  end
1149
1159
 
1150
- context.destroy()
1160
+ context:Destroy()
1151
1161
  end)
1152
1162
  end)
1153
1163
 
@@ -1185,7 +1195,7 @@ describe("HasSaveSlots playtime tracking", function()
1185
1195
  local slotId = createAndSelect(context, 1)
1186
1196
  expect(getMetadata(context, slotId).PlayCount).toEqual(1)
1187
1197
 
1188
- context.destroy()
1198
+ context:Destroy()
1189
1199
  end)
1190
1200
 
1191
1201
  it("counts a fresh session each time a slot is re-selected", function()
@@ -1197,7 +1207,7 @@ describe("HasSaveSlots playtime tracking", function()
1197
1207
  local reselectPromise = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
1198
1208
  if not PromiseTestUtils.awaitSettled(reselectPromise, 10) then
1199
1209
  expect("reselect hung").toEqual("reselect settled")
1200
- context.destroy()
1210
+ context:Destroy()
1201
1211
  return
1202
1212
  end
1203
1213
  reselectPromise:Yield()
@@ -1205,7 +1215,7 @@ describe("HasSaveSlots playtime tracking", function()
1205
1215
  expect(getMetadata(context, firstSlotId).PlayCount).toEqual(2)
1206
1216
  expect(getMetadata(context, secondSlotId).PlayCount).toEqual(1)
1207
1217
 
1208
- context.destroy()
1218
+ context:Destroy()
1209
1219
  end)
1210
1220
 
1211
1221
  it("accrues elapsed wall time into TimePlayed and LastSessionLength for the active slot", function()
@@ -1224,7 +1234,7 @@ describe("HasSaveSlots playtime tracking", function()
1224
1234
  expect(metadata.TimePlayed ~= nil and metadata.TimePlayed >= 120).toEqual(true)
1225
1235
  expect(metadata.LastSessionLength ~= nil and metadata.LastSessionLength >= 120).toEqual(true)
1226
1236
 
1227
- context.destroy()
1237
+ context:Destroy()
1228
1238
  end)
1229
1239
 
1230
1240
  it("does not accrue time before any slot is selected", function()
@@ -1236,14 +1246,14 @@ describe("HasSaveSlots playtime tracking", function()
1236
1246
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
1237
1247
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
1238
1248
  expect("create hung").toEqual("create settled")
1239
- context.destroy()
1249
+ context:Destroy()
1240
1250
  return
1241
1251
  end
1242
1252
  local _, slotId = createPromise:Yield()
1243
1253
 
1244
1254
  expect(getMetadata(context, slotId).TimePlayed).toBeNil()
1245
1255
 
1246
- context.destroy()
1256
+ context:Destroy()
1247
1257
  end)
1248
1258
 
1249
1259
  it("stops accruing into a slot once it is deselected", function()
@@ -1259,7 +1269,7 @@ describe("HasSaveSlots playtime tracking", function()
1259
1269
  local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
1260
1270
  if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
1261
1271
  expect("deselect hung").toEqual("deselect settled")
1262
- context.destroy()
1272
+ context:Destroy()
1263
1273
  return
1264
1274
  end
1265
1275
  deselectPromise:Yield()
@@ -1271,7 +1281,7 @@ describe("HasSaveSlots playtime tracking", function()
1271
1281
  tracker:_flushPlaytime()
1272
1282
  expect(getMetadata(context, slotId).TimePlayed).toEqual(afterDeselect)
1273
1283
 
1274
- context.destroy()
1284
+ context:Destroy()
1275
1285
  end)
1276
1286
 
1277
1287
  it("carries the source slot's playtime onto a duplicate, live session included", function()
@@ -1287,7 +1297,7 @@ describe("HasSaveSlots playtime tracking", function()
1287
1297
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
1288
1298
  if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
1289
1299
  expect("duplicate hung").toEqual("duplicate settled")
1290
- context.destroy()
1300
+ context:Destroy()
1291
1301
  return
1292
1302
  end
1293
1303
  local newSlotId = duplicatePromise:Wait()
@@ -1295,7 +1305,7 @@ describe("HasSaveSlots playtime tracking", function()
1295
1305
  local copied = getMetadata(context, newSlotId).TimePlayed
1296
1306
  expect(copied ~= nil and copied >= 120).toEqual(true)
1297
1307
 
1298
- context.destroy()
1308
+ context:Destroy()
1299
1309
  end)
1300
1310
 
1301
1311
  it("leaves a duplicate of a never-played slot without playtime", function()
@@ -1304,7 +1314,7 @@ describe("HasSaveSlots playtime tracking", function()
1304
1314
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
1305
1315
  if not PromiseTestUtils.awaitSettled(createPromise, 10) then
1306
1316
  expect("create hung").toEqual("create settled")
1307
- context.destroy()
1317
+ context:Destroy()
1308
1318
  return
1309
1319
  end
1310
1320
  local _, slotId = createPromise:Yield()
@@ -1312,13 +1322,13 @@ describe("HasSaveSlots playtime tracking", function()
1312
1322
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
1313
1323
  if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
1314
1324
  expect("duplicate hung").toEqual("duplicate settled")
1315
- context.destroy()
1325
+ context:Destroy()
1316
1326
  return
1317
1327
  end
1318
1328
 
1319
1329
  expect(getMetadata(context, duplicatePromise:Wait()).TimePlayed).toBeNil()
1320
1330
 
1321
- context.destroy()
1331
+ context:Destroy()
1322
1332
  end)
1323
1333
  end)
1324
1334
 
@@ -1376,7 +1386,7 @@ describe("HasSaveSlots summary providers", function()
1376
1386
  expect(summary.coins).toEqual(100)
1377
1387
  expect(summary.world).toEqual(3)
1378
1388
 
1379
- context.destroy()
1389
+ context:Destroy()
1380
1390
  end)
1381
1391
 
1382
1392
  it("drops a provider's key from the Summary once it is unregistered", function()
@@ -1402,7 +1412,7 @@ describe("HasSaveSlots summary providers", function()
1402
1412
  expect(matched).toEqual(true)
1403
1413
  expect(summary.world).toBeNil()
1404
1414
 
1405
- context.destroy()
1415
+ context:Destroy()
1406
1416
  end)
1407
1417
 
1408
1418
  it("isolates a provider that errors when called so the others still contribute", function()
@@ -1423,7 +1433,7 @@ describe("HasSaveSlots summary providers", function()
1423
1433
  expect(matched).toEqual(true)
1424
1434
  expect(summary.bad).toBeNil()
1425
1435
 
1426
- context.destroy()
1436
+ context:Destroy()
1427
1437
  end)
1428
1438
 
1429
1439
  it("isolates a provider whose stream fails so the others still contribute", function()
@@ -1447,7 +1457,7 @@ describe("HasSaveSlots summary providers", function()
1447
1457
  expect(matched).toEqual(true)
1448
1458
  expect(summary.bad).toBeNil()
1449
1459
 
1450
- context.destroy()
1460
+ context:Destroy()
1451
1461
  end)
1452
1462
 
1453
1463
  it("clears the Summary when every provider is unregistered", function()
@@ -1469,7 +1479,7 @@ describe("HasSaveSlots summary providers", function()
1469
1479
  end, 10)
1470
1480
  expect(cleared).toEqual(true)
1471
1481
 
1472
- context.destroy()
1482
+ context:Destroy()
1473
1483
  end)
1474
1484
  end)
1475
1485
 
@@ -1489,7 +1499,7 @@ describe("HasSaveSlots against a fake player (datastore down)", function()
1489
1499
  expect(ok).toEqual(false)
1490
1500
  end
1491
1501
 
1492
- context.destroy()
1502
+ context:Destroy()
1493
1503
  end)
1494
1504
  end)
1495
1505
 
@@ -1524,7 +1534,7 @@ describe("HasSaveSlots ephemeral slots", function()
1524
1534
  expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
1525
1535
  expect(resolve(context.hasSaveSlots:PromiseHasSlot(slotId))).toEqual(true)
1526
1536
 
1527
- context.destroy()
1537
+ context:Destroy()
1528
1538
  end)
1529
1539
 
1530
1540
  it("marks the slot with the IsEphemeral property, and real slots without it", function()
@@ -1539,7 +1549,7 @@ describe("HasSaveSlots ephemeral slots", function()
1539
1549
  expect(ephemeralMetadata.IsEphemeral).toEqual(true)
1540
1550
  expect(realMetadata.IsEphemeral).never.toEqual(true)
1541
1551
 
1542
- context.destroy()
1552
+ context:Destroy()
1543
1553
  end)
1544
1554
 
1545
1555
  it("keeps the ephemeral slot out of the slot list while still replicating it", function()
@@ -1558,7 +1568,7 @@ describe("HasSaveSlots ephemeral slots", function()
1558
1568
  expect(slotContainerHasChild(context, realId)).toEqual(true)
1559
1569
  expect(slotContainerHasChild(context, ephemeralId)).toEqual(true)
1560
1570
 
1561
- context.destroy()
1571
+ context:Destroy()
1562
1572
  end)
1563
1573
 
1564
1574
  it("replicates the ephemeral slot's metadata so it is readable off the instance tree", function()
@@ -1572,7 +1582,7 @@ describe("HasSaveSlots ephemeral slots", function()
1572
1582
  expect(metadata.SlotName).toEqual("Lobby run")
1573
1583
  expect(metadata.IsEphemeral).toEqual(true)
1574
1584
 
1575
- context.destroy()
1585
+ context:Destroy()
1576
1586
  end)
1577
1587
 
1578
1588
  it("replicates the ephemeral slot's summary as its providers update it", function()
@@ -1600,7 +1610,7 @@ describe("HasSaveSlots ephemeral slots", function()
1600
1610
  end, 10)).toEqual(true)
1601
1611
 
1602
1612
  coins:Destroy()
1603
- context.destroy()
1613
+ context:Destroy()
1604
1614
  end)
1605
1615
 
1606
1616
  it("emits the ephemeral slot through ObserveSlotMetadata, and nil once it is retired", function()
@@ -1629,7 +1639,7 @@ describe("HasSaveSlots ephemeral slots", function()
1629
1639
  end, 10)).toEqual(true)
1630
1640
 
1631
1641
  maid:DoCleaning()
1632
- context.destroy()
1642
+ context:Destroy()
1633
1643
  end)
1634
1644
 
1635
1645
  it("excludes the ephemeral slot from ObserveSlotList without dropping the real slots", function()
@@ -1663,7 +1673,7 @@ describe("HasSaveSlots ephemeral slots", function()
1663
1673
  expect(observedIds[realId]).toEqual(true)
1664
1674
 
1665
1675
  maid:DoCleaning()
1666
- context.destroy()
1676
+ context:Destroy()
1667
1677
  end)
1668
1678
 
1669
1679
  it("persists a real slot's data but never an ephemeral slot's", function()
@@ -1689,7 +1699,7 @@ describe("HasSaveSlots ephemeral slots", function()
1689
1699
  expect(ephemeralIdFound).toEqual(false)
1690
1700
  expect(ephemeralValueFound).toEqual(false)
1691
1701
 
1692
- context.destroy()
1702
+ context:Destroy()
1693
1703
  end)
1694
1704
 
1695
1705
  it("destroys the ephemeral slot's in-memory store when it is retired", function()
@@ -1705,7 +1715,7 @@ describe("HasSaveSlots ephemeral slots", function()
1705
1715
  -- now GC-eligible) when the slot was retired, rather than lingering.
1706
1716
  expect(getmetatable(store)).toBeNil()
1707
1717
 
1708
- context.destroy()
1718
+ context:Destroy()
1709
1719
  end)
1710
1720
 
1711
1721
  it("does not disturb the Continue pointer when an ephemeral slot is selected", function()
@@ -1716,7 +1726,7 @@ describe("HasSaveSlots ephemeral slots", function()
1716
1726
 
1717
1727
  expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(realId)
1718
1728
 
1719
- context.destroy()
1729
+ context:Destroy()
1720
1730
  end)
1721
1731
 
1722
1732
  it("tears the ephemeral slot down once it stops being active", function()
@@ -1731,7 +1741,7 @@ describe("HasSaveSlots ephemeral slots", function()
1731
1741
  expect(resolve(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(false)
1732
1742
  expect(slotContainerHasChild(context, ephemeralId)).toEqual(false)
1733
1743
 
1734
- context.destroy()
1744
+ context:Destroy()
1735
1745
  end)
1736
1746
 
1737
1747
  it("retires the ephemeral slot when switching to a real slot, keeping the real slots", function()
@@ -1748,7 +1758,7 @@ describe("HasSaveSlots ephemeral slots", function()
1748
1758
  expect(resolve(context.hasSaveSlots:PromiseHasSlot(slotA))).toEqual(true)
1749
1759
  expect(resolve(context.hasSaveSlots:PromiseHasSlot(slotB))).toEqual(true)
1750
1760
 
1751
- context.destroy()
1761
+ context:Destroy()
1752
1762
  end)
1753
1763
 
1754
1764
  it("drives summaries through the ephemeral slot's in-memory store", function()
@@ -1766,7 +1776,7 @@ describe("HasSaveSlots ephemeral slots", function()
1766
1776
  end, 10)
1767
1777
  expect(matched).toEqual(true)
1768
1778
 
1769
- context.destroy()
1779
+ context:Destroy()
1770
1780
  end)
1771
1781
 
1772
1782
  it("refuses to reset an ephemeral slot", function()
@@ -1778,7 +1788,7 @@ describe("HasSaveSlots ephemeral slots", function()
1778
1788
  expect(PromiseTestUtils.awaitSettled(resetPromise, 10)).toEqual(true)
1779
1789
  expect((resetPromise:Yield())).toEqual(false)
1780
1790
 
1781
- context.destroy()
1791
+ context:Destroy()
1782
1792
  end)
1783
1793
 
1784
1794
  it("duplicates an ephemeral slot into a real slot carrying its live data", function()
@@ -1800,7 +1810,7 @@ describe("HasSaveSlots ephemeral slots", function()
1800
1810
  -- Duplicating leaves the session running on the ephemeral slot, like any other duplicate.
1801
1811
  expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(ephemeralId)
1802
1812
 
1803
- context.destroy()
1813
+ context:Destroy()
1804
1814
  end)
1805
1815
 
1806
1816
  it("persists the ephemeral slot and continues play on the new real slot", function()
@@ -1826,7 +1836,7 @@ describe("HasSaveSlots ephemeral slots", function()
1826
1836
  expect(data.Coins).toEqual(12)
1827
1837
  expect(data.SaveSlots).never.toBeNil()
1828
1838
 
1829
- context.destroy()
1839
+ context:Destroy()
1830
1840
  end)
1831
1841
 
1832
1842
  it("refuses to persist when the active slot is a real one", function()
@@ -1838,7 +1848,7 @@ describe("HasSaveSlots ephemeral slots", function()
1838
1848
  expect(PromiseTestUtils.awaitSettled(persistPromise, 10)).toEqual(true)
1839
1849
  expect((persistPromise:Yield())).toEqual(false)
1840
1850
 
1841
- context.destroy()
1851
+ context:Destroy()
1842
1852
  end)
1843
1853
 
1844
1854
  it("ends the session when the ephemeral slot is deleted", function()
@@ -1851,7 +1861,7 @@ describe("HasSaveSlots ephemeral slots", function()
1851
1861
  expect(resolve(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(false)
1852
1862
  expect(slotContainerHasChild(context, ephemeralId)).toEqual(false)
1853
1863
 
1854
- context.destroy()
1864
+ context:Destroy()
1855
1865
  end)
1856
1866
 
1857
1867
  it("still resumes the real slot with Continue after an ephemeral session", function()
@@ -1867,6 +1877,6 @@ describe("HasSaveSlots ephemeral slots", function()
1867
1877
  expect(continuedId).toEqual(realId)
1868
1878
  expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(realId)
1869
1879
 
1870
- context.destroy()
1880
+ context:Destroy()
1871
1881
  end)
1872
1882
  end)