@schema-engine/forms 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/dist/actions/index.js +4 -4
  3. package/dist/actions/plugins/index.js +3 -3
  4. package/dist/actions/plugins/registrations.js +3 -3
  5. package/dist/agent-tool/index.js +1 -1
  6. package/dist/{chunk-U2X3IYSD.js → chunk-6EYX257T.js} +1 -1
  7. package/dist/{chunk-HEAKWS27.js → chunk-A5VLMQAK.js} +693 -643
  8. package/dist/chunk-A5VLMQAK.js.map +7 -0
  9. package/dist/{chunk-5QXT7YAJ.js → chunk-CANRZY5A.js} +1 -1
  10. package/dist/{chunk-2VKEOE2L.js → chunk-GQHMU3AR.js} +12 -12
  11. package/dist/{chunk-WS7SLVXL.js → chunk-JA5ET6MC.js} +4 -4
  12. package/dist/{chunk-2PTM54FQ.js → chunk-KH6QWB5Y.js} +2 -2
  13. package/dist/chunk-PCL2KNHC.js.map +7 -0
  14. package/dist/{chunk-56CJ2UZ7.js → chunk-TSKELYW7.js} +2 -2
  15. package/dist/chunk-U3YHTQHR.js +215 -0
  16. package/dist/chunk-U3YHTQHR.js.map +7 -0
  17. package/dist/{chunk-XPQRHO5E.js → chunk-V5H7L5PJ.js} +1 -1
  18. package/dist/engine/build-form-engine.js +7 -7
  19. package/dist/engine/create-form-engine.js +8 -8
  20. package/dist/engine/form-engine.js +7 -7
  21. package/dist/engine/index.js +8 -8
  22. package/dist/engine/step-machine.js +1 -1
  23. package/dist/engine/submission-schema.js +1 -1
  24. package/dist/engine/value-validation.js +1 -1
  25. package/dist/index.js +26 -26
  26. package/dist/lib/validate-form.js +4 -4
  27. package/dist/recipes/index.js +1 -1
  28. package/dist/recipes/view-model.js +1 -1
  29. package/dist/runtime/create-form-runtime.js +7 -7
  30. package/dist/runtime/index.js +7 -7
  31. package/dist/schemas/base-field.js +2 -2
  32. package/dist/schemas/form-config-shape.js +2 -2
  33. package/dist/schemas/form-config.js +2 -2
  34. package/dist/schemas/index.js +5 -5
  35. package/dist/schemas/validation/dependencies.js +1 -1
  36. package/dist/schemas/validation/index.js +5 -5
  37. package/dist/schemas/validation/utils.js +1 -1
  38. package/dist/schemas/validation/validation-registry.js +1 -1
  39. package/dist/server-errors/from-json-api-errors.js +3 -3
  40. package/dist/server-errors/from-problem-details.js +3 -3
  41. package/dist/server-errors/index.js +6 -6
  42. package/dist/server-errors/shared.js +2 -2
  43. package/dist/state-container/create-form-state-container.js +5 -5
  44. package/dist/state-container/index.d.ts +1 -1
  45. package/dist/state-container/index.js +12 -12
  46. package/dist/state-container/selectors.js +1 -1
  47. package/dist/state-container/submission.js +1 -1
  48. package/dist/state-container/types.d.ts +1 -1
  49. package/dist/state-container/types.js +1 -1
  50. package/dist/testing/assert.d.ts +92 -0
  51. package/dist/testing/assert.js +42 -0
  52. package/dist/testing/assert.js.map +7 -0
  53. package/dist/testing/form-state-container-conformance.d.ts +15 -3
  54. package/dist/testing/form-state-container-conformance.js +4 -3
  55. package/dist/testing/index.d.ts +3 -2
  56. package/dist/testing/index.js +4 -3
  57. package/package.json +7 -13
  58. package/skill/reference/forms.md +3 -2
  59. package/dist/chunk-HEAKWS27.js.map +0 -7
  60. package/dist/chunk-PXWVKJGF.js.map +0 -7
  61. package/dist/{chunk-U2X3IYSD.js.map → chunk-6EYX257T.js.map} +0 -0
  62. package/dist/{chunk-5QXT7YAJ.js.map → chunk-CANRZY5A.js.map} +0 -0
  63. package/dist/{chunk-GY657L56.js → chunk-DP7SYLLI.js} +5 -5
  64. /package/dist/{chunk-GY657L56.js.map → chunk-DP7SYLLI.js.map} +0 -0
  65. /package/dist/{chunk-2VKEOE2L.js.map → chunk-GQHMU3AR.js.map} +0 -0
  66. /package/dist/{chunk-WS7SLVXL.js.map → chunk-JA5ET6MC.js.map} +0 -0
  67. /package/dist/{chunk-2PTM54FQ.js.map → chunk-KH6QWB5Y.js.map} +0 -0
  68. /package/dist/{chunk-PXWVKJGF.js → chunk-PCL2KNHC.js} +0 -0
  69. /package/dist/{chunk-56CJ2UZ7.js.map → chunk-TSKELYW7.js.map} +0 -0
  70. /package/dist/{chunk-XPQRHO5E.js.map → chunk-V5H7L5PJ.js.map} +0 -0
@@ -16,13 +16,31 @@ import {
16
16
  } from "./chunk-CRQWKC67.js";
17
17
  import {
18
18
  FORM_ROOT
19
- } from "./chunk-PXWVKJGF.js";
19
+ } from "./chunk-PCL2KNHC.js";
20
20
  import {
21
21
  toHydration
22
22
  } from "./chunk-RB22U6HI.js";
23
+ import {
24
+ assertCallCount,
25
+ assertDefined,
26
+ assertDoesNotThrow,
27
+ assertEqual,
28
+ assertLength,
29
+ assertMatches,
30
+ assertNoProperty,
31
+ assertNotIncludes,
32
+ assertNotMatches,
33
+ assertNotSame,
34
+ assertSame,
35
+ assertThrows,
36
+ assertUndefined,
37
+ createSpy,
38
+ spyOn,
39
+ stubGlobal,
40
+ waitFor
41
+ } from "./chunk-U3YHTQHR.js";
23
42
 
24
43
  // src/testing/form-state-container-conformance.ts
25
- import { describe, expect, test, vi } from "vitest";
26
44
  import * as z from "zod/mini";
27
45
  function createGate() {
28
46
  const waiting = /* @__PURE__ */ new Map();
@@ -263,20 +281,20 @@ var cases = [
263
281
  run(createStore) {
264
282
  const store = createStore(fixture().options);
265
283
  const first = store.getSnapshot();
266
- expect(store.getSnapshot()).toBe(first);
267
- const listener = vi.fn();
284
+ assertSame(store.getSnapshot(), first);
285
+ const listener = createSpy();
268
286
  const unsubscribe = store.subscribe(listener);
269
287
  store.setValue("name", "Grace");
270
- expect(listener).toHaveBeenCalledTimes(1);
288
+ assertCallCount(listener, 1);
271
289
  const second = store.getSnapshot();
272
- expect(second).not.toBe(first);
273
- expect(store.getSnapshot()).toBe(second);
290
+ assertNotSame(second, first);
291
+ assertSame(store.getSnapshot(), second);
274
292
  store.setValue("name", "Grace");
275
- expect(listener).toHaveBeenCalledTimes(1);
276
- expect(store.getSnapshot()).toBe(second);
293
+ assertCallCount(listener, 1);
294
+ assertSame(store.getSnapshot(), second);
277
295
  unsubscribe();
278
296
  store.setValue("name", "Hedy");
279
- expect(listener).toHaveBeenCalledTimes(1);
297
+ assertCallCount(listener, 1);
280
298
  }
281
299
  },
282
300
  {
@@ -285,17 +303,17 @@ var cases = [
285
303
  async run(createStore) {
286
304
  const store = createStore(fixture().options);
287
305
  const start = store.getSnapshot().generation;
288
- expect(store.getServerSnapshot().generation).toBe(start);
306
+ assertSame(store.getServerSnapshot().generation, start);
289
307
  store.setValue("name", "Grace");
290
308
  store.blur("name");
291
309
  await store.validate();
292
310
  await store.submit();
293
- expect(store.getSnapshot().generation).toBe(start);
311
+ assertSame(store.getSnapshot().generation, start);
294
312
  store.reset();
295
- expect(store.getSnapshot().generation).toBe(start + 1);
313
+ assertSame(store.getSnapshot().generation, start + 1);
296
314
  store.reset({ name: "Hedy" });
297
- expect(store.getSnapshot().generation).toBe(start + 2);
298
- expect(store.getServerSnapshot().generation).toBe(start);
315
+ assertSame(store.getSnapshot().generation, start + 2);
316
+ assertSame(store.getServerSnapshot().generation, start);
299
317
  }
300
318
  },
301
319
  {
@@ -303,13 +321,13 @@ var cases = [
303
321
  name: "a reset of a pristine form still notifies, since the generation changed",
304
322
  run(createStore) {
305
323
  const store = createStore(fixture().options);
306
- const listener = vi.fn();
324
+ const listener = createSpy();
307
325
  store.subscribe(listener);
308
326
  const before = store.getSnapshot();
309
327
  store.reset();
310
- expect(listener).toHaveBeenCalledTimes(1);
311
- expect(store.getSnapshot()).not.toBe(before);
312
- expect(store.getSnapshot().values).toEqual(before.values);
328
+ assertCallCount(listener, 1);
329
+ assertNotSame(store.getSnapshot(), before);
330
+ assertEqual(store.getSnapshot().values, before.values);
313
331
  }
314
332
  },
315
333
  {
@@ -318,13 +336,13 @@ var cases = [
318
336
  run(createStore) {
319
337
  const store = createStore(fixture().options);
320
338
  const server = store.getServerSnapshot();
321
- expect(store.getServerSnapshot()).toBe(server);
322
- expect(server.values.name).toBe("Ada");
339
+ assertSame(store.getServerSnapshot(), server);
340
+ assertSame(server.values.name, "Ada");
323
341
  store.setValue("name", "Grace");
324
342
  store.blur("name");
325
- expect(store.getServerSnapshot()).toBe(server);
326
- expect(server.values.name).toBe("Ada");
327
- expect(store.getSnapshot().values.name).toBe("Grace");
343
+ assertSame(store.getServerSnapshot(), server);
344
+ assertSame(server.values.name, "Ada");
345
+ assertSame(store.getSnapshot().values.name, "Grace");
328
346
  }
329
347
  },
330
348
  {
@@ -342,38 +360,38 @@ var cases = [
342
360
  };
343
361
  const store = createStore(fixture({ defaults }).options);
344
362
  const snapshot = store.getSnapshot();
345
- expect(() => {
363
+ assertThrows(() => {
346
364
  snapshot.values.name = "Eve";
347
- }).toThrow(TypeError);
348
- expect(() => {
365
+ }, TypeError);
366
+ assertThrows(() => {
349
367
  snapshot.values.address.street = "Eve";
350
- }).toThrow(TypeError);
351
- expect(() => {
368
+ }, TypeError);
369
+ assertThrows(() => {
352
370
  snapshot.errors.name = serverIssue("x");
353
- }).toThrow(TypeError);
354
- expect(() => {
371
+ }, TypeError);
372
+ assertThrows(() => {
355
373
  snapshot.touched.name = true;
356
- }).toThrow(TypeError);
357
- expect(() => {
374
+ }, TypeError);
375
+ assertThrows(() => {
358
376
  snapshot.dirty.name = true;
359
- }).toThrow(TypeError);
360
- expect(() => {
377
+ }, TypeError);
378
+ assertThrows(() => {
361
379
  snapshot.rowIds.contacts = [];
362
- }).toThrow(TypeError);
363
- expect(() => {
380
+ }, TypeError);
381
+ assertThrows(() => {
364
382
  snapshot.rowIds.contacts.push("x");
365
- }).toThrow(TypeError);
383
+ }, TypeError);
366
384
  defaults.address.street = "changed after create";
367
- expect(store.getSnapshot().values.address.street).toBe("1 Main");
385
+ assertSame(store.getSnapshot().values.address.street, "1 Main");
368
386
  const branch = { street: "2 Side", country: "FR" };
369
387
  store.setValue("address", branch);
370
388
  branch.street = "changed after setValue";
371
- expect(store.getSnapshot().values.address.street).toBe("2 Side");
389
+ assertSame(store.getSnapshot().values.address.street, "2 Side");
372
390
  const given = { name: serverIssue("Taken") };
373
391
  await serverAnswer(store, given);
374
392
  given.name.message = "changed after the answer";
375
- expect(errorsOf(store).name?.message).toBe("Taken");
376
- expect(Object.getPrototypeOf(store.getSnapshot().values)).toBe(Object.prototype);
393
+ assertSame(errorsOf(store).name?.message, "Taken");
394
+ assertSame(Object.getPrototypeOf(store.getSnapshot().values), Object.prototype);
377
395
  }
378
396
  },
379
397
  {
@@ -384,22 +402,22 @@ var cases = [
384
402
  const before = store.getSnapshot();
385
403
  store.setValue("name", "Grace");
386
404
  const after = store.getSnapshot();
387
- expect(after.values.address).toBe(before.values.address);
388
- expect(after.values.contacts).toBe(before.values.contacts);
389
- expect(after.errors).toBe(before.errors);
390
- expect(after.touched).toBe(before.touched);
391
- expect(after.rowIds).toBe(before.rowIds);
405
+ assertSame(after.values.address, before.values.address);
406
+ assertSame(after.values.contacts, before.values.contacts);
407
+ assertSame(after.errors, before.errors);
408
+ assertSame(after.touched, before.touched);
409
+ assertSame(after.rowIds, before.rowIds);
392
410
  store.setValue("contacts.1.email", "new@example.com");
393
411
  const rows = store.getSnapshot().values.contacts;
394
412
  const earlier = after.values.contacts;
395
- expect(rows).not.toBe(earlier);
396
- expect(rows[0]).toBe(earlier[0]);
397
- expect(rows[1]).not.toBe(earlier[1]);
398
- expect(rows[2]).toBe(earlier[2]);
413
+ assertNotSame(rows, earlier);
414
+ assertSame(rows[0], earlier[0]);
415
+ assertNotSame(rows[1], earlier[1]);
416
+ assertSame(rows[2], earlier[2]);
399
417
  const valuesBeforeBlur = store.getSnapshot().values;
400
418
  store.blur("name");
401
- expect(store.getSnapshot().values).toBe(valuesBeforeBlur);
402
- expect(store.getSnapshot().values.contacts).toBe(rows);
419
+ assertSame(store.getSnapshot().values, valuesBeforeBlur);
420
+ assertSame(store.getSnapshot().values.contacts, rows);
403
421
  }
404
422
  },
405
423
  {
@@ -411,11 +429,11 @@ var cases = [
411
429
  store.blur("contacts.1.email");
412
430
  store.setValue("address.street", "2 Side");
413
431
  const { errors, touched, dirty } = store.getSnapshot();
414
- expect(Object.keys(errors).toSorted()).toEqual(["contacts.1.email", "nickname"]);
415
- expect(errors.nickname).toMatchObject({ message: "nick", source: "server" });
416
- expect(touched).toEqual({ "contacts.1.email": true });
417
- expect(dirty).toEqual({ "address.street": true });
418
- expect(Object.keys(store.getSnapshot()).toSorted()).toEqual([
432
+ assertEqual(Object.keys(errors).toSorted(), ["contacts.1.email", "nickname"]);
433
+ assertMatches(errors.nickname, { message: "nick", source: "server" });
434
+ assertEqual(touched, { "contacts.1.email": true });
435
+ assertEqual(dirty, { "address.street": true });
436
+ assertEqual(Object.keys(store.getSnapshot()).toSorted(), [
419
437
  "dirty",
420
438
  "errors",
421
439
  "generation",
@@ -429,9 +447,9 @@ var cases = [
429
447
  ]);
430
448
  store.setValue("name", "Grace");
431
449
  const after = store.getSnapshot();
432
- expect(after.errors).toBe(errors);
433
- expect(after.touched).toBe(touched);
434
- expect(after.dirty).not.toBe(dirty);
450
+ assertSame(after.errors, errors);
451
+ assertSame(after.touched, touched);
452
+ assertNotSame(after.dirty, dirty);
435
453
  }
436
454
  },
437
455
  {
@@ -440,11 +458,11 @@ var cases = [
440
458
  async run(createStore) {
441
459
  const store = createStore(fixture().options);
442
460
  await serverAnswer(store, { contacts: serverIssue("too few"), "contacts.0.email": serverIssue("row") });
443
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["contacts", "contacts.0.email"]);
444
- expect(fieldState(store, "contacts").error?.message).toBe("too few");
445
- expect(fieldState(store, "contacts.0.email").error?.message).toBe("row");
446
- expect(fieldState(store, "contacts.1.email").error).toBeUndefined();
447
- expect(store.getSnapshot().isValid).toBe(false);
461
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["contacts", "contacts.0.email"]);
462
+ assertSame(fieldState(store, "contacts").error?.message, "too few");
463
+ assertSame(fieldState(store, "contacts.0.email").error?.message, "row");
464
+ assertUndefined(fieldState(store, "contacts.1.email").error);
465
+ assertSame(store.getSnapshot().isValid, false);
448
466
  }
449
467
  },
450
468
  {
@@ -453,16 +471,16 @@ var cases = [
453
471
  async run(createStore) {
454
472
  const store = createStore(fixture().options);
455
473
  await serverAnswer(store, { [FORM_ROOT]: serverIssue("Try again later") });
456
- expect(Object.keys(errorsOf(store))).toEqual([FORM_ROOT]);
457
- expect(errorsOf(store)[FORM_ROOT]).toMatchObject({ message: "Try again later" });
458
- expect(fieldState(store, "name").error).toBeUndefined();
459
- expect(fieldState(store, "contacts.0.email").invalid).toBe(false);
460
- expect(store.getSnapshot().isValid).toBe(false);
461
- expect(await store.validate(["name"])).toEqual({ outcome: "passed" });
462
- expect(await store.validate()).toEqual({ outcome: "invalid" });
474
+ assertEqual(Object.keys(errorsOf(store)), [FORM_ROOT]);
475
+ assertMatches(errorsOf(store)[FORM_ROOT], { message: "Try again later" });
476
+ assertUndefined(fieldState(store, "name").error);
477
+ assertSame(fieldState(store, "contacts.0.email").invalid, false);
478
+ assertSame(store.getSnapshot().isValid, false);
479
+ assertEqual(await store.validate(["name"]), { outcome: "passed" });
480
+ assertEqual(await store.validate(), { outcome: "invalid" });
463
481
  store.setValue("name", "Grace");
464
- expect(errorsOf(store)).toEqual({});
465
- expect(store.getSnapshot().isValid).toBe(true);
482
+ assertEqual(errorsOf(store), {});
483
+ assertSame(store.getSnapshot().isValid, true);
466
484
  }
467
485
  },
468
486
  {
@@ -479,7 +497,7 @@ var cases = [
479
497
  nickname: serverIssue("other")
480
498
  });
481
499
  store.setValue("contacts.0.email", "new@example.com");
482
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["contacts.1.email", "nickname"]);
500
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["contacts.1.email", "nickname"]);
483
501
  }
484
502
  },
485
503
  {
@@ -488,12 +506,12 @@ var cases = [
488
506
  run(createStore) {
489
507
  const store = createStore(fixture().options);
490
508
  store.blur("address");
491
- expect(fieldState(store, "address.street").isTouched).toBe(true);
492
- expect(fieldState(store, "address").isTouched).toBe(true);
493
- expect(fieldState(store, "name").isTouched).toBe(false);
509
+ assertSame(fieldState(store, "address.street").isTouched, true);
510
+ assertSame(fieldState(store, "address").isTouched, true);
511
+ assertSame(fieldState(store, "name").isTouched, false);
494
512
  store.setValue("address.street", "2 Side");
495
- expect(fieldState(store, "address").isDirty).toBe(true);
496
- expect(fieldState(store, "address.country").isDirty).toBe(false);
513
+ assertSame(fieldState(store, "address").isDirty, true);
514
+ assertSame(fieldState(store, "address.country").isDirty, false);
497
515
  }
498
516
  },
499
517
  {
@@ -501,7 +519,7 @@ var cases = [
501
519
  name: "selectFieldState reports error, touched and dirty for a path",
502
520
  async run(createStore) {
503
521
  const store = createStore(fixture().options);
504
- expect(fieldState(store, "name")).toEqual({
522
+ assertEqual(fieldState(store, "name"), {
505
523
  error: void 0,
506
524
  warning: void 0,
507
525
  invalid: false,
@@ -515,14 +533,14 @@ var cases = [
515
533
  store.setValue("name", "Grace");
516
534
  store.blur("name");
517
535
  await serverAnswer(store, { name: serverIssue("no") });
518
- expect(fieldState(store, "name")).toMatchObject({
536
+ assertMatches(fieldState(store, "name"), {
519
537
  error: { message: "no" },
520
538
  invalid: true,
521
539
  isTouched: true,
522
540
  isDirty: true
523
541
  });
524
542
  store.setValue("address.street", "2 Side");
525
- expect(fieldState(store, "address")).toMatchObject({ isDirty: true, isTouched: false });
543
+ assertMatches(fieldState(store, "address"), { isDirty: true, isTouched: false });
526
544
  }
527
545
  },
528
546
  {
@@ -531,14 +549,14 @@ var cases = [
531
549
  async run(createStore) {
532
550
  const store = createStore(fixture().options);
533
551
  const before = store.getSnapshot();
534
- expect(selectValue(before, "address")).toBe(before.values.address);
535
- expect(selectValue(before, "contacts.1.email")).toBe("b@example.com");
552
+ assertSame(selectValue(before, "address"), before.values.address);
553
+ assertSame(selectValue(before, "contacts.1.email"), "b@example.com");
536
554
  await serverAnswer(store, { contacts: serverIssue("array") });
537
555
  store.setValue("name", "Grace");
538
556
  const after = store.getSnapshot();
539
- expect(selectValue(after, "address")).toBe(selectValue(before, "address"));
540
- expect(selectFieldState(after, "contacts").error?.message).toBe("array");
541
- expect(selectFieldState(after, "contacts.0.email").error).toBeUndefined();
557
+ assertSame(selectValue(after, "address"), selectValue(before, "address"));
558
+ assertSame(selectFieldState(after, "contacts").error?.message, "array");
559
+ assertUndefined(selectFieldState(after, "contacts.0.email").error);
542
560
  }
543
561
  },
544
562
  {
@@ -547,13 +565,13 @@ var cases = [
547
565
  run(createStore) {
548
566
  const store = createStore(fixture().options);
549
567
  const before = store.getSnapshot();
550
- expect(selectFieldState(before, "name")).toBe(selectFieldState(before, "name"));
551
- expect(fieldState(store, "name")).toBe(selectFieldState(before, "name"));
568
+ assertSame(selectFieldState(before, "name"), selectFieldState(before, "name"));
569
+ assertSame(fieldState(store, "name"), selectFieldState(before, "name"));
552
570
  store.blur("name");
553
571
  const after = store.getSnapshot();
554
- expect(selectFieldState(after, "name")).not.toBe(selectFieldState(before, "name"));
555
- expect(selectFieldState(after, "name").isTouched).toBe(true);
556
- expect(selectFieldState(before, "name").isTouched).toBe(false);
572
+ assertNotSame(selectFieldState(after, "name"), selectFieldState(before, "name"));
573
+ assertSame(selectFieldState(after, "name").isTouched, true);
574
+ assertSame(selectFieldState(before, "name").isTouched, false);
557
575
  }
558
576
  },
559
577
  {
@@ -564,20 +582,20 @@ var cases = [
564
582
  const file = new File(["x"], "a.txt");
565
583
  const files = [file];
566
584
  store.setValue("files", files);
567
- expect(store.getSnapshot().values.files).toBe(files);
568
- expect(store.getValue("files")).toBe(files);
569
- expect(Object.isFrozen(files)).toBe(false);
570
- const listener = vi.fn();
585
+ assertSame(store.getSnapshot().values.files, files);
586
+ assertSame(store.getValue("files"), files);
587
+ assertSame(Object.isFrozen(files), false);
588
+ const listener = createSpy();
571
589
  store.subscribe(listener);
572
590
  store.setValue("files", files);
573
- expect(listener).not.toHaveBeenCalled();
591
+ assertCallCount(listener, 0);
574
592
  store.setValue("files", [file]);
575
- expect(listener).toHaveBeenCalledTimes(1);
576
- expect(store.getSnapshot().values.files).not.toBe(files);
577
- expect(store.getSnapshot().values.files[0]).toBe(file);
578
- expect(store.getSnapshot().dirty.files).toBe(true);
593
+ assertCallCount(listener, 1);
594
+ assertNotSame(store.getSnapshot().values.files, files);
595
+ assertSame(store.getSnapshot().values.files[0], file);
596
+ assertSame(store.getSnapshot().dirty.files, true);
579
597
  store.setValue("profile", { avatar: [file] });
580
- expect(store.getSnapshot().values.profile.avatar[0]).toBe(file);
598
+ assertSame(store.getSnapshot().values.profile.avatar[0], file);
581
599
  }
582
600
  },
583
601
  {
@@ -586,11 +604,11 @@ var cases = [
586
604
  run(createStore) {
587
605
  const store = createStore(fixture().options);
588
606
  store.setValue("address", { street: "9 Elm" });
589
- expect(store.getSnapshot().values.address).toEqual({ street: "9 Elm" });
590
- expect(store.getValue("address.country")).toBeUndefined();
607
+ assertEqual(store.getSnapshot().values.address, { street: "9 Elm" });
608
+ assertUndefined(store.getValue("address.country"));
591
609
  store.setValue("contacts", [{ email: "only@example.com" }]);
592
- expect(contacts(store)).toEqual(["only@example.com"]);
593
- expect(store.getSnapshot().rowIds.contacts).toHaveLength(1);
610
+ assertEqual(contacts(store), ["only@example.com"]);
611
+ assertLength(store.getSnapshot().rowIds.contacts, 1);
594
612
  }
595
613
  },
596
614
  {
@@ -599,14 +617,14 @@ var cases = [
599
617
  run(createStore) {
600
618
  const store = createStore(fixture().options);
601
619
  const before = store.getSnapshot();
602
- const listener = vi.fn();
620
+ const listener = createSpy();
603
621
  store.subscribe(listener);
604
622
  store.setValue("address", { street: "1 Main", country: "IT" });
605
- expect(listener).not.toHaveBeenCalled();
606
- expect(store.getSnapshot()).toBe(before);
623
+ assertCallCount(listener, 0);
624
+ assertSame(store.getSnapshot(), before);
607
625
  store.setValue("address", { street: "1 Main", country: "FR" });
608
626
  const after = store.getSnapshot();
609
- expect(after.values.contacts).toBe(before.values.contacts);
627
+ assertSame(after.values.contacts, before.values.contacts);
610
628
  }
611
629
  },
612
630
  {
@@ -614,19 +632,19 @@ var cases = [
614
632
  name: "notifies once per command even when the command starts a validation",
615
633
  run(createStore) {
616
634
  const change = createStore(fixture({ validationMode: "onChange" }).options);
617
- const onChange = vi.fn();
635
+ const onChange = createSpy();
618
636
  change.subscribe(onChange);
619
637
  change.setValue("name", "");
620
- expect(onChange).toHaveBeenCalledTimes(1);
621
- expect(change.getSnapshot().validating).toEqual({ name: true });
638
+ assertCallCount(onChange, 1);
639
+ assertEqual(change.getSnapshot().validating, { name: true });
622
640
  change.fieldArray("contacts").swap(0, 1);
623
- expect(onChange).toHaveBeenCalledTimes(2);
641
+ assertCallCount(onChange, 2);
624
642
  const blur = createStore(fixture({ validationMode: "onBlur" }).options);
625
- const onBlur = vi.fn();
643
+ const onBlur = createSpy();
626
644
  blur.subscribe(onBlur);
627
645
  blur.blur("name");
628
- expect(onBlur).toHaveBeenCalledTimes(1);
629
- expect(blur.getSnapshot().validating).toEqual({ name: true });
646
+ assertCallCount(onBlur, 1);
647
+ assertEqual(blur.getSnapshot().validating, { name: true });
630
648
  }
631
649
  },
632
650
  {
@@ -635,9 +653,9 @@ var cases = [
635
653
  async run(createStore) {
636
654
  const store = createStore(fixture({ defaults: { name: "", nickname: "" } }).options);
637
655
  const watch = watchValidation(store);
638
- expect(await store.validate([])).toEqual({ outcome: "passed" });
639
- expect(watch.started).toBe(false);
640
- expect(await store.checkValidity()).toBe(false);
656
+ assertEqual(await store.validate([]), { outcome: "passed" });
657
+ assertSame(watch.started, false);
658
+ assertSame(await store.checkValidity(), false);
641
659
  }
642
660
  },
643
661
  {
@@ -648,10 +666,10 @@ var cases = [
648
666
  const store = createStore(options);
649
667
  gate.hold("x");
650
668
  store.fieldArray("invites").append({ code: "x", label: "first" });
651
- await vi.waitFor(() => expect(errorsOf(store).invites?.message).toBe("Add two invites"));
652
- expect(gate.pending("x")).toBe(0);
653
- expect(errorsOf(store)["invites.0.code"]).toBeUndefined();
654
- expect(isValidating(store)).toBe(false);
669
+ await waitFor(() => assertSame(errorsOf(store).invites?.message, "Add two invites"));
670
+ assertSame(gate.pending("x"), 0);
671
+ assertUndefined(errorsOf(store)["invites.0.code"]);
672
+ assertSame(isValidating(store), false);
655
673
  }
656
674
  },
657
675
  {
@@ -663,10 +681,10 @@ var cases = [
663
681
  store.setValue("name", "");
664
682
  store.blur("name");
665
683
  await settle();
666
- expect(watch.started).toBe(false);
667
- expect(errorsOf(store)).toEqual({});
668
- expect(await store.validate()).toEqual({ outcome: "invalid" });
669
- expect(errorsOf(store).name?.message).toBe("Name is required");
684
+ assertSame(watch.started, false);
685
+ assertEqual(errorsOf(store), {});
686
+ assertEqual(await store.validate(), { outcome: "invalid" });
687
+ assertSame(errorsOf(store).name?.message, "Name is required");
670
688
  }
671
689
  },
672
690
  {
@@ -677,11 +695,11 @@ var cases = [
677
695
  const watch = watchValidation(store);
678
696
  store.blur("name");
679
697
  await settle();
680
- expect(watch.started).toBe(false);
681
- expect(errorsOf(store)).toEqual({});
698
+ assertSame(watch.started, false);
699
+ assertEqual(errorsOf(store), {});
682
700
  store.setValue("name", "Ada");
683
701
  store.setValue("name", "");
684
- await vi.waitFor(() => expect(errorsOf(store).name?.message).toBe("Name is required"));
702
+ await waitFor(() => assertSame(errorsOf(store).name?.message, "Name is required"));
685
703
  }
686
704
  },
687
705
  {
@@ -692,10 +710,10 @@ var cases = [
692
710
  const watch = watchValidation(store);
693
711
  store.setValue("name", "");
694
712
  await settle();
695
- expect(watch.started).toBe(false);
696
- expect(errorsOf(store)).toEqual({});
713
+ assertSame(watch.started, false);
714
+ assertEqual(errorsOf(store), {});
697
715
  store.blur("name");
698
- await vi.waitFor(() => expect(errorsOf(store).name?.message).toBe("Name is required"));
716
+ await waitFor(() => assertSame(errorsOf(store).name?.message, "Name is required"));
699
717
  }
700
718
  },
701
719
  {
@@ -704,13 +722,13 @@ var cases = [
704
722
  async run(createStore) {
705
723
  const onChange = createStore(fixture({ validationMode: "all" }).options);
706
724
  onChange.setValue("name", "");
707
- await vi.waitFor(() => expect(errorsOf(onChange).name).toBeDefined());
725
+ await waitFor(() => assertDefined(errorsOf(onChange).name));
708
726
  onChange.setValue("name", "Ada");
709
- await vi.waitFor(() => expect(errorsOf(onChange).name).toBeUndefined());
727
+ await waitFor(() => assertUndefined(errorsOf(onChange).name));
710
728
  const onBlur = createStore(fixture({ validationMode: "all", defaults: { name: "" } }).options);
711
- expect(errorsOf(onBlur)).toEqual({});
729
+ assertEqual(errorsOf(onBlur), {});
712
730
  onBlur.blur("name");
713
- await vi.waitFor(() => expect(errorsOf(onBlur).name?.message).toBe("Name is required"));
731
+ await waitFor(() => assertSame(errorsOf(onBlur).name?.message, "Name is required"));
714
732
  }
715
733
  },
716
734
  {
@@ -721,8 +739,8 @@ var cases = [
721
739
  fixture({ validationMode: "onChange", defaults: { name: "", nickname: "ada" } }).options
722
740
  );
723
741
  store.setValue("nickname", "");
724
- await vi.waitFor(() => expect(errorsOf(store).nickname?.message).toBe("Nickname is required"));
725
- expect(errorsOf(store).name).toBeUndefined();
742
+ await waitFor(() => assertSame(errorsOf(store).nickname?.message, "Nickname is required"));
743
+ assertUndefined(errorsOf(store).name);
726
744
  }
727
745
  },
728
746
  {
@@ -731,11 +749,11 @@ var cases = [
731
749
  async run(createStore) {
732
750
  const store = createStore(fixture({ validationMode: "onSubmit", reValidateMode: "onChange" }).options);
733
751
  store.setValue("name", "");
734
- expect(await store.validate()).toEqual({ outcome: "invalid" });
752
+ assertEqual(await store.validate(), { outcome: "invalid" });
735
753
  store.setValue("name", "Ada");
736
- await vi.waitFor(() => expect(errorsOf(store).name).toBeUndefined());
754
+ await waitFor(() => assertUndefined(errorsOf(store).name));
737
755
  store.setValue("name", "");
738
- await vi.waitFor(() => expect(errorsOf(store).name?.message).toBe("Name is required"));
756
+ await waitFor(() => assertSame(errorsOf(store).name?.message, "Name is required"));
739
757
  }
740
758
  },
741
759
  {
@@ -748,10 +766,10 @@ var cases = [
748
766
  const changeWatch = watchValidation(onBlur);
749
767
  onBlur.setValue("name", "Ada");
750
768
  await settle();
751
- expect(changeWatch.started).toBe(false);
752
- expect(errorsOf(onBlur).name).toBeDefined();
769
+ assertSame(changeWatch.started, false);
770
+ assertDefined(errorsOf(onBlur).name);
753
771
  onBlur.blur("name");
754
- await vi.waitFor(() => expect(errorsOf(onBlur).name).toBeUndefined());
772
+ await waitFor(() => assertUndefined(errorsOf(onBlur).name));
755
773
  const onSubmit = createStore(fixture({ validationMode: "onSubmit", reValidateMode: "onSubmit" }).options);
756
774
  onSubmit.setValue("name", "");
757
775
  await onSubmit.validate();
@@ -759,8 +777,8 @@ var cases = [
759
777
  onSubmit.setValue("name", "Ada");
760
778
  onSubmit.blur("name");
761
779
  await settle();
762
- expect(submitWatch.started).toBe(false);
763
- expect(errorsOf(onSubmit).name).toBeDefined();
780
+ assertSame(submitWatch.started, false);
781
+ assertDefined(errorsOf(onSubmit).name);
764
782
  }
765
783
  },
766
784
  {
@@ -769,14 +787,14 @@ var cases = [
769
787
  async run(createStore) {
770
788
  const store = createStore(fixture({ validationMode: "onSubmit", reValidateMode: "onChange" }).options);
771
789
  store.setValue("name", "");
772
- expect(await store.validate(["name"])).toEqual({ outcome: "invalid" });
790
+ assertEqual(await store.validate(["name"]), { outcome: "invalid" });
773
791
  const watch = watchValidation(store);
774
792
  store.setValue("nickname", "");
775
793
  await settle();
776
- expect(watch.started).toBe(false);
777
- expect(errorsOf(store).nickname).toBeUndefined();
794
+ assertSame(watch.started, false);
795
+ assertUndefined(errorsOf(store).nickname);
778
796
  store.setValue("name", "Ada");
779
- await vi.waitFor(() => expect(errorsOf(store).name).toBeUndefined());
797
+ await waitFor(() => assertUndefined(errorsOf(store).name));
780
798
  }
781
799
  },
782
800
  {
@@ -784,23 +802,23 @@ var cases = [
784
802
  name: "a passing validate starts re-validation of the paths it checked, and no others, and reset ends it",
785
803
  async run(createStore) {
786
804
  const store = createStore(fixture({ validationMode: "onSubmit", reValidateMode: "onChange" }).options);
787
- expect(await store.validate(["nickname"])).toEqual({ outcome: "passed" });
805
+ assertEqual(await store.validate(["nickname"]), { outcome: "passed" });
788
806
  const other = watchValidation(store);
789
807
  store.setValue("name", "");
790
808
  await settle();
791
- expect(other.started).toBe(false);
792
- expect(errorsOf(store)).toEqual({});
809
+ assertSame(other.started, false);
810
+ assertEqual(errorsOf(store), {});
793
811
  store.setValue("name", "Ada");
794
- expect(await store.validate()).toEqual({ outcome: "passed" });
812
+ assertEqual(await store.validate(), { outcome: "passed" });
795
813
  store.setValue("name", "");
796
- await vi.waitFor(() => expect(errorsOf(store).name?.type).toBe("required"));
797
- expect(await store.validate()).toEqual({ outcome: "invalid" });
814
+ await waitFor(() => assertSame(errorsOf(store).name?.type, "required"));
815
+ assertEqual(await store.validate(), { outcome: "invalid" });
798
816
  store.reset();
799
817
  const afterReset = watchValidation(store);
800
818
  store.setValue("name", "");
801
819
  await settle();
802
- expect(afterReset.started).toBe(false);
803
- expect(errorsOf(store)).toEqual({});
820
+ assertSame(afterReset.started, false);
821
+ assertEqual(errorsOf(store), {});
804
822
  }
805
823
  },
806
824
  {
@@ -810,12 +828,12 @@ var cases = [
810
828
  const store = createStore(fixture().options);
811
829
  store.setValue("name", "");
812
830
  const before = store.getSnapshot();
813
- const listener = vi.fn();
831
+ const listener = createSpy();
814
832
  store.subscribe(listener);
815
- expect(await store.checkValidity()).toBe(false);
816
- expect(store.getSnapshot()).toBe(before);
817
- expect(listener).not.toHaveBeenCalled();
818
- expect(errorsOf(store)).toEqual({});
833
+ assertSame(await store.checkValidity(), false);
834
+ assertSame(store.getSnapshot(), before);
835
+ assertCallCount(listener, 0);
836
+ assertEqual(errorsOf(store), {});
819
837
  }
820
838
  },
821
839
  {
@@ -824,14 +842,14 @@ var cases = [
824
842
  run(createStore) {
825
843
  const store = createStore(fixture().options);
826
844
  store.setValue("name", "Grace");
827
- expect(store.getSnapshot().touched).toEqual({});
845
+ assertEqual(store.getSnapshot().touched, {});
828
846
  store.blur("name");
829
- expect(store.getSnapshot().touched).toEqual({ name: true });
847
+ assertEqual(store.getSnapshot().touched, { name: true });
830
848
  const touched = store.getSnapshot().touched;
831
849
  store.blur("name");
832
- expect(store.getSnapshot().touched).toBe(touched);
850
+ assertSame(store.getSnapshot().touched, touched);
833
851
  store.reset();
834
- expect(store.getSnapshot().touched).toEqual({});
852
+ assertEqual(store.getSnapshot().touched, {});
835
853
  }
836
854
  },
837
855
  {
@@ -839,19 +857,19 @@ var cases = [
839
857
  name: "dirty follows the difference from the defaults, and appending a row does not make the rows before it dirty",
840
858
  run(createStore) {
841
859
  const store = createStore(fixture().options);
842
- expect(store.getSnapshot().dirty).toEqual({});
860
+ assertEqual(store.getSnapshot().dirty, {});
843
861
  store.setValue("address.street", "2 Side");
844
- expect(marked(store.getSnapshot().dirty)).toEqual(["address.street"]);
862
+ assertEqual(marked(store.getSnapshot().dirty), ["address.street"]);
845
863
  store.setValue("address.street", "1 Main");
846
- expect(store.getSnapshot().dirty).toEqual({});
864
+ assertEqual(store.getSnapshot().dirty, {});
847
865
  store.setValue("contacts.1.email", "x@example.com");
848
- expect(marked(store.getSnapshot().dirty)).toEqual(["contacts.1.email"]);
866
+ assertEqual(marked(store.getSnapshot().dirty), ["contacts.1.email"]);
849
867
  store.setValue("contacts.1.email", "b@example.com");
850
868
  store.fieldArray("contacts").append({ email: "x@example.com" });
851
- expect(marked(store.getSnapshot().dirty)).toEqual(["contacts", "contacts.3.email"]);
869
+ assertEqual(marked(store.getSnapshot().dirty), ["contacts", "contacts.3.email"]);
852
870
  store.setValue("name", "Grace");
853
871
  store.reset();
854
- expect(store.getSnapshot().dirty).toEqual({});
872
+ assertEqual(store.getSnapshot().dirty, {});
855
873
  }
856
874
  },
857
875
  {
@@ -862,13 +880,13 @@ var cases = [
862
880
  await serverAnswer(store, { nickname: serverIssue("no") });
863
881
  store.setValue("name", "");
864
882
  store.blur("name");
865
- expect(await store.validate()).toEqual({ outcome: "invalid" });
883
+ assertEqual(await store.validate(), { outcome: "invalid" });
866
884
  store.reset();
867
885
  const snapshot = store.getSnapshot();
868
- expect(snapshot.values.name).toBe("Ada");
869
- expect(snapshot.errors).toEqual({});
870
- expect(snapshot.touched).toEqual({});
871
- expect(snapshot.dirty).toEqual({});
886
+ assertSame(snapshot.values.name, "Ada");
887
+ assertEqual(snapshot.errors, {});
888
+ assertEqual(snapshot.touched, {});
889
+ assertEqual(snapshot.dirty, {});
872
890
  }
873
891
  },
874
892
  {
@@ -878,12 +896,12 @@ var cases = [
878
896
  const store = createStore(fixture().options);
879
897
  store.setValue("name", "Grace");
880
898
  store.reset({ name: "Hedy" });
881
- expect(store.getSnapshot().values).toEqual({ name: "Hedy" });
882
- expect(store.getSnapshot().dirty).toEqual({});
899
+ assertEqual(store.getSnapshot().values, { name: "Hedy" });
900
+ assertEqual(store.getSnapshot().dirty, {});
883
901
  store.setValue("name", "Ada");
884
- expect(store.getSnapshot().dirty).toEqual({ name: true });
902
+ assertEqual(store.getSnapshot().dirty, { name: true });
885
903
  store.reset();
886
- expect(store.getValue("name")).toBe("Hedy");
904
+ assertSame(store.getValue("name"), "Hedy");
887
905
  }
888
906
  },
889
907
  {
@@ -897,17 +915,17 @@ var cases = [
897
915
  });
898
916
  store.blur("contacts.1.email");
899
917
  const [first, second, third] = ids(store);
900
- const listener = vi.fn(() => {
918
+ const listener = createSpy(() => {
901
919
  const snapshot = store.getSnapshot();
902
- expect(snapshot.rowIds.contacts).toEqual([second, first, third]);
903
- expect(contacts(store)).toEqual(["b@example.com", "a@example.com", "c@example.com"]);
904
- expect(snapshot.errors["contacts.0.email"]?.message).toBe("one");
905
- expect(snapshot.errors["contacts.1.email"]?.message).toBe("zero");
906
- expect(marked(snapshot.touched)).toEqual(["contacts.0.email"]);
920
+ assertEqual(snapshot.rowIds.contacts, [second, first, third]);
921
+ assertEqual(contacts(store), ["b@example.com", "a@example.com", "c@example.com"]);
922
+ assertSame(snapshot.errors["contacts.0.email"]?.message, "one");
923
+ assertSame(snapshot.errors["contacts.1.email"]?.message, "zero");
924
+ assertEqual(marked(snapshot.touched), ["contacts.0.email"]);
907
925
  });
908
926
  store.subscribe(listener);
909
927
  store.fieldArray("contacts").swap(0, 1);
910
- expect(listener).toHaveBeenCalledTimes(1);
928
+ assertCallCount(listener, 1);
911
929
  }
912
930
  },
913
931
  {
@@ -920,23 +938,26 @@ var cases = [
920
938
  await serverAnswer(store, { "contacts.2.email": serverIssue("two") });
921
939
  store.blur("contacts.2.email");
922
940
  array.move(2, 0);
923
- expect(ids(store)).toEqual([third, first, second]);
924
- expect(errorsOf(store)["contacts.0.email"]?.message).toBe("two");
925
- expect(marked(store.getSnapshot().touched)).toEqual(["contacts.0.email"]);
941
+ assertEqual(ids(store), [third, first, second]);
942
+ assertSame(errorsOf(store)["contacts.0.email"]?.message, "two");
943
+ assertEqual(marked(store.getSnapshot().touched), ["contacts.0.email"]);
926
944
  array.prepend({ email: "new@example.com" });
927
- expect(ids(store).slice(1)).toEqual([third, first, second]);
928
- expect(Object.keys(errorsOf(store))).toEqual(["contacts.1.email"]);
945
+ assertEqual(ids(store).slice(1), [third, first, second]);
946
+ assertEqual(Object.keys(errorsOf(store)), ["contacts.1.email"]);
929
947
  array.insert(1, { email: "mid@example.com" });
930
- expect(Object.keys(errorsOf(store))).toEqual(["contacts.2.email"]);
931
- expect(ids(store).slice(2)).toEqual([third, first, second]);
948
+ assertEqual(Object.keys(errorsOf(store)), ["contacts.2.email"]);
949
+ assertEqual(ids(store).slice(2), [third, first, second]);
932
950
  array.remove(0);
933
- expect(Object.keys(errorsOf(store))).toEqual(["contacts.1.email"]);
934
- expect(marked(store.getSnapshot().touched)).toEqual(["contacts.1.email"]);
951
+ assertEqual(Object.keys(errorsOf(store)), ["contacts.1.email"]);
952
+ assertEqual(marked(store.getSnapshot().touched), ["contacts.1.email"]);
935
953
  array.remove(1);
936
- expect(errorsOf(store)).toEqual({});
937
- expect(store.getSnapshot().touched).toEqual({});
938
- expect(contacts(store)).toEqual(["mid@example.com", "a@example.com", "b@example.com"]);
939
- expect(toFieldArrayValue(ids(store), array).fields.map(({ id }) => id)).toEqual(ids(store));
954
+ assertEqual(errorsOf(store), {});
955
+ assertEqual(store.getSnapshot().touched, {});
956
+ assertEqual(contacts(store), ["mid@example.com", "a@example.com", "b@example.com"]);
957
+ assertEqual(
958
+ toFieldArrayValue(ids(store), array).fields.map(({ id }) => id),
959
+ ids(store)
960
+ );
940
961
  }
941
962
  },
942
963
  {
@@ -946,10 +967,10 @@ var cases = [
946
967
  const store = createStore(fixture().options);
947
968
  const before = ids(store);
948
969
  store.fieldArray("contacts").append([{ email: "x@example.com" }, { email: "y@example.com" }]);
949
- expect(ids(store).slice(0, 3)).toEqual(before);
950
- expect(ids(store)).toHaveLength(5);
951
- expect(new Set(ids(store)).size).toBe(5);
952
- expect(contacts(store).slice(3)).toEqual(["x@example.com", "y@example.com"]);
970
+ assertEqual(ids(store).slice(0, 3), before);
971
+ assertLength(ids(store), 5);
972
+ assertSame(new Set(ids(store)).size, 5);
973
+ assertEqual(contacts(store).slice(3), ["x@example.com", "y@example.com"]);
953
974
  }
954
975
  },
955
976
  {
@@ -965,16 +986,16 @@ var cases = [
965
986
  });
966
987
  store.blur("contacts.0.email");
967
988
  array.update(1, { email: "u@example.com" });
968
- expect(ids(store)[0]).toBe(before[0]);
969
- expect(ids(store)[1]).not.toBe(before[1]);
970
- expect(ids(store)[2]).toBe(before[2]);
971
- expect(Object.keys(errorsOf(store))).toEqual(["contacts.0.email"]);
972
- expect(marked(store.getSnapshot().touched)).toEqual(["contacts.0.email"]);
989
+ assertSame(ids(store)[0], before[0]);
990
+ assertNotSame(ids(store)[1], before[1]);
991
+ assertSame(ids(store)[2], before[2]);
992
+ assertEqual(Object.keys(errorsOf(store)), ["contacts.0.email"]);
993
+ assertEqual(marked(store.getSnapshot().touched), ["contacts.0.email"]);
973
994
  array.replace([{ email: "r@example.com" }]);
974
- expect(ids(store)).toHaveLength(1);
975
- expect(before).not.toContain(ids(store)[0]);
976
- expect(errorsOf(store)).toEqual({});
977
- expect(store.getSnapshot().touched).toEqual({});
995
+ assertLength(ids(store), 1);
996
+ assertNotIncludes(before, ids(store)[0]);
997
+ assertEqual(errorsOf(store), {});
998
+ assertEqual(store.getSnapshot().touched, {});
978
999
  }
979
1000
  },
980
1001
  {
@@ -984,7 +1005,7 @@ var cases = [
984
1005
  const store = createStore(fixture().options);
985
1006
  const array = store.fieldArray("contacts");
986
1007
  const before = store.getSnapshot();
987
- const listener = vi.fn();
1008
+ const listener = createSpy();
988
1009
  store.subscribe(listener);
989
1010
  array.swap(0, 5);
990
1011
  array.move(-1, 0);
@@ -994,15 +1015,15 @@ var cases = [
994
1015
  array.insert(1.5, { email: "z@example.com" });
995
1016
  array.remove(7);
996
1017
  array.remove([]);
997
- expect(listener).not.toHaveBeenCalled();
998
- expect(store.getSnapshot()).toBe(before);
1018
+ assertCallCount(listener, 0);
1019
+ assertSame(store.getSnapshot(), before);
999
1020
  array.insert(3, { email: "end@example.com" });
1000
- expect(contacts(store)).toHaveLength(4);
1021
+ assertLength(contacts(store), 4);
1001
1022
  array.remove([0, 0, 9]);
1002
- expect(contacts(store)).toEqual(["b@example.com", "c@example.com", "end@example.com"]);
1023
+ assertEqual(contacts(store), ["b@example.com", "c@example.com", "end@example.com"]);
1003
1024
  array.remove();
1004
- expect(contacts(store)).toEqual([]);
1005
- expect(store.getSnapshot().rowIds.contacts).toEqual([]);
1025
+ assertEqual(contacts(store), []);
1026
+ assertEqual(store.getSnapshot().rowIds.contacts, []);
1006
1027
  }
1007
1028
  },
1008
1029
  {
@@ -1033,17 +1054,17 @@ var cases = [
1033
1054
  store.blur("groups.0.members.1.label");
1034
1055
  store.blur("tags.2");
1035
1056
  store.fieldArray("groups").swap(0, 1);
1036
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["groups.1.members.1.label", "tags.1"]);
1037
- expect(marked(store.getSnapshot().touched).toSorted()).toEqual(["groups.1.members.1.label", "tags.2"]);
1057
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["groups.1.members.1.label", "tags.1"]);
1058
+ assertEqual(marked(store.getSnapshot().touched).toSorted(), ["groups.1.members.1.label", "tags.2"]);
1038
1059
  store.fieldArray("groups.1.members").remove(0);
1039
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["groups.1.members.0.label", "tags.1"]);
1060
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["groups.1.members.0.label", "tags.1"]);
1040
1061
  store.fieldArray("tags").remove(0);
1041
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["groups.1.members.0.label", "tags.0"]);
1042
- expect(marked(store.getSnapshot().touched).toSorted()).toEqual(["groups.1.members.0.label", "tags.1"]);
1062
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["groups.1.members.0.label", "tags.0"]);
1063
+ assertEqual(marked(store.getSnapshot().touched).toSorted(), ["groups.1.members.0.label", "tags.1"]);
1043
1064
  store.setValue("groups", [{ title: "only", members: [] }]);
1044
- expect(Object.keys(errorsOf(store))).toEqual(["tags.0"]);
1045
- expect(marked(store.getSnapshot().touched)).toEqual(["tags.1"]);
1046
- expect(store.getSnapshot().rowIds["groups.0.members"]).toEqual([]);
1065
+ assertEqual(Object.keys(errorsOf(store)), ["tags.0"]);
1066
+ assertEqual(marked(store.getSnapshot().touched), ["tags.1"]);
1067
+ assertEqual(store.getSnapshot().rowIds["groups.0.members"], []);
1047
1068
  }
1048
1069
  },
1049
1070
  {
@@ -1058,17 +1079,17 @@ var cases = [
1058
1079
  const hydration = JSON.parse(JSON.stringify(toHydration(server.getSnapshot())));
1059
1080
  const client = createStore(fixture({ snapshot: hydration }).options);
1060
1081
  const was = server.getSnapshot();
1061
- expect(client.getSnapshot().values).toEqual(was.values);
1062
- expect(client.getSnapshot().rowIds).toEqual(was.rowIds);
1063
- expect(client.getSnapshot().dirty).toEqual(was.dirty);
1064
- expect(client.getServerSnapshot().rowIds).toEqual(was.rowIds);
1082
+ assertEqual(client.getSnapshot().values, was.values);
1083
+ assertEqual(client.getSnapshot().rowIds, was.rowIds);
1084
+ assertEqual(client.getSnapshot().dirty, was.dirty);
1085
+ assertEqual(client.getServerSnapshot().rowIds, was.rowIds);
1065
1086
  client.fieldArray("contacts").append({ email: "new@example.com" });
1066
1087
  client.fieldArray("contacts").remove(0);
1067
1088
  const adopted = Object.values(was.rowIds).flat();
1068
1089
  const minted = ids(client).filter((id) => !adopted.includes(id));
1069
- expect(minted).toHaveLength(1);
1070
- expect(ids(client).slice(0, 2)).toEqual(was.rowIds.contacts.slice(1));
1071
- expect(new Set(ids(client)).size).toBe(ids(client).length);
1090
+ assertLength(minted, 1);
1091
+ assertEqual(ids(client).slice(0, 2), was.rowIds.contacts.slice(1));
1092
+ assertSame(new Set(ids(client)).size, ids(client).length);
1072
1093
  }
1073
1094
  },
1074
1095
  {
@@ -1079,19 +1100,19 @@ var cases = [
1079
1100
  await serverAnswer(store, { "contacts.2.email": serverIssue("two") });
1080
1101
  store.blur("contacts.2.email");
1081
1102
  store.setValue("contacts", [{ email: "a@example.com" }]);
1082
- expect(errorsOf(store)).toEqual({});
1083
- expect(store.getSnapshot().touched).toEqual({});
1103
+ assertEqual(errorsOf(store), {});
1104
+ assertEqual(store.getSnapshot().touched, {});
1084
1105
  const checked = createStore(fixture().options);
1085
1106
  checked.setValue("contacts.2.email", "");
1086
- expect(await checked.validate(["contacts.2.email"])).toEqual({ outcome: "invalid" });
1107
+ assertEqual(await checked.validate(["contacts.2.email"]), { outcome: "invalid" });
1087
1108
  checked.setValue("contacts", [{ email: "a@example.com" }]);
1088
1109
  checked.fieldArray("contacts").append({ email: "fresh@example.com" });
1089
1110
  checked.fieldArray("contacts").append({ email: "" });
1090
- expect(errorsOf(checked)).toEqual({});
1111
+ assertEqual(errorsOf(checked), {});
1091
1112
  const watch = watchValidation(checked);
1092
1113
  checked.setValue("contacts.2.email", "changed@example.com");
1093
1114
  await settle();
1094
- expect(watch.started).toBe(false);
1115
+ assertSame(watch.started, false);
1095
1116
  }
1096
1117
  },
1097
1118
  {
@@ -1101,9 +1122,9 @@ var cases = [
1101
1122
  const store = createStore(fixture().options);
1102
1123
  const before = ids(store);
1103
1124
  store.setValue("contacts", [{ email: "1" }, { email: "2" }, { email: "3" }]);
1104
- expect(ids(store)).toEqual(before);
1125
+ assertEqual(ids(store), before);
1105
1126
  store.setValue("contacts", [{ email: "1" }]);
1106
- expect(ids(store)).toEqual(before.slice(0, 1));
1127
+ assertEqual(ids(store), before.slice(0, 1));
1107
1128
  }
1108
1129
  },
1109
1130
  {
@@ -1128,20 +1149,20 @@ var cases = [
1128
1149
  answer.setServerErrors({ slug: { message: "Taken" } });
1129
1150
  gate.settle("free", false);
1130
1151
  store.reportNative({ slug: { type: "patternMismatch", params: { pattern: "[0-9]+" } } });
1131
- expect(await store.validate(["slug"])).toEqual({ outcome: "invalid" });
1152
+ assertEqual(await store.validate(["slug"]), { outcome: "invalid" });
1132
1153
  const shown = errorsOf(store).slug;
1133
- expect(shown.all).toEqual([
1154
+ assertEqual(shown.all, [
1134
1155
  { type: "server", message: "Taken", source: "server" },
1135
1156
  { type: "gate", source: "validation", ruleId: "first" },
1136
1157
  { type: "gate", source: "validation", ruleId: "second" },
1137
1158
  { type: "patternMismatch", source: "native", params: { pattern: "[0-9]+" } }
1138
1159
  ]);
1139
1160
  const { all, ...fields } = shown;
1140
- expect(fields).toEqual(all[0]);
1161
+ assertEqual(fields, all[0]);
1141
1162
  answer.setServerErrors({});
1142
1163
  const withoutServer = errorsOf(store).slug;
1143
- expect(withoutServer.type).toBe("gate");
1144
- expect(withoutServer.all).toHaveLength(3);
1164
+ assertSame(withoutServer.type, "gate");
1165
+ assertLength(withoutServer.all, 3);
1145
1166
  }
1146
1167
  },
1147
1168
  {
@@ -1150,20 +1171,20 @@ var cases = [
1150
1171
  async run(createStore) {
1151
1172
  const store = createStore(fixture({ validationMode: "onSubmit" }).options);
1152
1173
  store.reportNative({ name: { type: "valueMissing", message: "Fill in" } });
1153
- expect(await store.validate(["name"])).toEqual({ outcome: "invalid" });
1154
- expect(errorsOf(store).name).toMatchObject({ source: "native", type: "valueMissing", message: "Fill in" });
1174
+ assertEqual(await store.validate(["name"]), { outcome: "invalid" });
1175
+ assertMatches(errorsOf(store).name, { source: "native", type: "valueMissing", message: "Fill in" });
1155
1176
  store.reportNative({ name: null });
1156
- await vi.waitFor(() => expect(errorsOf(store)).toEqual({}));
1157
- expect(await store.validate(["name"])).toEqual({ outcome: "passed" });
1177
+ await waitFor(() => assertEqual(errorsOf(store), {}));
1178
+ assertEqual(await store.validate(["name"]), { outcome: "passed" });
1158
1179
  const quiet = createStore(fixture({ validationMode: "onSubmit" }).options);
1159
1180
  quiet.blur("name");
1160
1181
  quiet.reportNative({ name: { type: "valueMissing" } });
1161
- expect(errorsOf(quiet)).toEqual({});
1182
+ assertEqual(errorsOf(quiet), {});
1162
1183
  const onChange = createStore(fixture({ validationMode: "onChange" }).options);
1163
1184
  onChange.setValue("nickname", "nick");
1164
1185
  onChange.reportNative({ nickname: { type: "valueMissing", message: "Fill in this field" } });
1165
- await vi.waitFor(() => expect(errorsOf(onChange).nickname?.source).toBe("native"));
1166
- expect(errorsOf(onChange).nickname.message).toBe("Fill in this field");
1186
+ await waitFor(() => assertSame(errorsOf(onChange).nickname?.source, "native"));
1187
+ assertSame(errorsOf(onChange).nickname.message, "Fill in this field");
1167
1188
  }
1168
1189
  },
1169
1190
  {
@@ -1173,15 +1194,15 @@ var cases = [
1173
1194
  const store = createStore(fixture().options);
1174
1195
  store.reportNative({ name: { type: "valueMissing" } });
1175
1196
  const before = store.getSnapshot();
1176
- expect(await store.checkValidity()).toBe(false);
1177
- expect(store.getSnapshot()).toBe(before);
1178
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1197
+ assertSame(await store.checkValidity(), false);
1198
+ assertSame(store.getSnapshot(), before);
1199
+ assertEqual(await store.validate(), { outcome: "invalid" });
1179
1200
  store.reportNative({ name: null });
1180
- expect(await store.checkValidity()).toBe(true);
1181
- expect(await store.validate()).toEqual({ outcome: "passed" });
1201
+ assertSame(await store.checkValidity(), true);
1202
+ assertEqual(await store.validate(), { outcome: "passed" });
1182
1203
  await serverAnswer(store, { name: { message: "Taken" } });
1183
- expect(await store.checkValidity()).toBe(false);
1184
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1204
+ assertSame(await store.checkValidity(), false);
1205
+ assertEqual(await store.validate(), { outcome: "invalid" });
1185
1206
  }
1186
1207
  },
1187
1208
  {
@@ -1191,11 +1212,11 @@ var cases = [
1191
1212
  const store = createStore(fixture().options);
1192
1213
  const answer = await passedSubmission(store);
1193
1214
  answer.setServerErrors({ [FORM_ROOT]: { message: "Service unavailable" } });
1194
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1195
- expect(await store.validate(["name"])).toEqual({ outcome: "passed" });
1215
+ assertEqual(await store.validate(), { outcome: "invalid" });
1216
+ assertEqual(await store.validate(["name"]), { outcome: "passed" });
1196
1217
  answer.setServerErrors({});
1197
- expect(await store.validate()).toEqual({ outcome: "passed" });
1198
- expect(errorsOf(store)).toEqual({});
1218
+ assertEqual(await store.validate(), { outcome: "passed" });
1219
+ assertEqual(errorsOf(store), {});
1199
1220
  }
1200
1221
  },
1201
1222
  {
@@ -1209,15 +1230,15 @@ var cases = [
1209
1230
  "address.street": { type: "taken" }
1210
1231
  });
1211
1232
  const { errors } = store.getSnapshot();
1212
- expect(errors.name).toMatchObject({ type: "server", message: "Taken", source: "server" });
1213
- expect(errors.nickname).toEqual({
1233
+ assertMatches(errors.name, { type: "server", message: "Taken", source: "server" });
1234
+ assertEqual(errors.nickname, {
1214
1235
  type: "server",
1215
1236
  source: "server",
1216
1237
  all: [{ type: "server", source: "server" }]
1217
1238
  });
1218
- expect(errors["address.street"]).toMatchObject({ type: "taken", source: "server" });
1219
- expect(errors["address.street"].message).toBeUndefined();
1220
- expect(await store.validate(["nickname"])).toEqual({ outcome: "invalid" });
1239
+ assertMatches(errors["address.street"], { type: "taken", source: "server" });
1240
+ assertUndefined(errors["address.street"].message);
1241
+ assertEqual(await store.validate(["nickname"]), { outcome: "invalid" });
1221
1242
  }
1222
1243
  },
1223
1244
  {
@@ -1228,16 +1249,16 @@ var cases = [
1228
1249
  const answer = await passedSubmission(store);
1229
1250
  answer.setServerErrors({ name: { message: "Taken" }, nickname: { message: "Taken" } });
1230
1251
  const before = store.getSnapshot();
1231
- const listener = vi.fn();
1252
+ const listener = createSpy();
1232
1253
  store.subscribe(listener);
1233
1254
  answer.setServerErrors({ name: { message: "Taken" }, nickname: { message: "Taken" } });
1234
- expect(listener).not.toHaveBeenCalled();
1235
- expect(store.getSnapshot()).toBe(before);
1255
+ assertCallCount(listener, 0);
1256
+ assertSame(store.getSnapshot(), before);
1236
1257
  answer.setServerErrors({ name: { message: "Taken" }, nickname: { message: "Other" } });
1237
1258
  const after = store.getSnapshot();
1238
- expect(after.errors.name).toBe(before.errors.name);
1239
- expect(after.errors.nickname).not.toBe(before.errors.nickname);
1240
- expect(selectFieldState(after, "name")).toBe(selectFieldState(before, "name"));
1259
+ assertSame(after.errors.name, before.errors.name);
1260
+ assertNotSame(after.errors.nickname, before.errors.nickname);
1261
+ assertSame(selectFieldState(after, "name"), selectFieldState(before, "name"));
1241
1262
  }
1242
1263
  },
1243
1264
  {
@@ -1248,14 +1269,17 @@ var cases = [
1248
1269
  await store.validate(["name"]);
1249
1270
  const first = store.getSnapshot();
1250
1271
  await store.validate(["name"]);
1251
- expect(store.getSnapshot().errors.name).toBe(first.errors.name);
1252
- expect(selectFieldState(store.getSnapshot(), "name")).toBe(selectFieldState(first, "name"));
1272
+ assertSame(store.getSnapshot().errors.name, first.errors.name);
1273
+ assertSame(selectFieldState(store.getSnapshot(), "name"), selectFieldState(first, "name"));
1253
1274
  store.blur("nickname");
1254
1275
  store.reportNative({ nickname: { type: "valueMissing" } });
1255
1276
  store.reset();
1256
1277
  store.setValue("nickname", "");
1257
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1258
- expect(errorsOf(store).nickname.all.map(({ source }) => source)).toEqual(["validation"]);
1278
+ assertEqual(await store.validate(), { outcome: "invalid" });
1279
+ assertEqual(
1280
+ errorsOf(store).nickname.all.map(({ source }) => source),
1281
+ ["validation"]
1282
+ );
1259
1283
  }
1260
1284
  },
1261
1285
  {
@@ -1264,15 +1288,17 @@ var cases = [
1264
1288
  run(createStore) {
1265
1289
  const store = createStore(fixture().options);
1266
1290
  const commands = store.fieldArray("contacts");
1267
- expect(store.fieldArray("contacts")).toBe(commands);
1291
+ assertSame(store.fieldArray("contacts"), commands);
1268
1292
  const rows = store.getSnapshot().rowIds.contacts;
1269
- expect(toFieldArrayValue(rows, commands)).toBe(toFieldArrayValue(rows, commands));
1293
+ assertSame(toFieldArrayValue(rows, commands), toFieldArrayValue(rows, commands));
1270
1294
  store.setValue("name", "Grace");
1271
- expect(toFieldArrayValue(store.getSnapshot().rowIds.contacts, commands)).toBe(
1295
+ assertSame(
1296
+ toFieldArrayValue(store.getSnapshot().rowIds.contacts, commands),
1272
1297
  toFieldArrayValue(rows, commands)
1273
1298
  );
1274
1299
  commands.append({ email: "x@example.com" });
1275
- expect(toFieldArrayValue(store.getSnapshot().rowIds.contacts, commands)).not.toBe(
1300
+ assertNotSame(
1301
+ toFieldArrayValue(store.getSnapshot().rowIds.contacts, commands),
1276
1302
  toFieldArrayValue(rows, commands)
1277
1303
  );
1278
1304
  }
@@ -1283,23 +1309,24 @@ var cases = [
1283
1309
  run(createStore) {
1284
1310
  const good = toHydration(createStore(fixture().options).getSnapshot());
1285
1311
  const start = (hydration) => () => createStore(fixture({ snapshot: hydration }).options);
1286
- expect(start({ ...good, rowIds: { ...good.rowIds, contacts: ["a", "b"] } })).toThrow();
1287
- expect(start({ ...good, rowIds: { ...good.rowIds, invites: ["k", "k"] } })).toThrow();
1288
- expect(start({ ...good, rowIds: { ...good.rowIds, name: ["x"] } })).toThrow();
1289
- expect(start({ ...good, rowIds: { ...good.rowIds, contacts: ["a", "b", 7] } })).toThrow();
1290
- expect(start({ ...good, rowIds: { contacts: good.rowIds.contacts } })).toThrow();
1291
- expect(start({ ...good, rowIds: { ...good.rowIds, invites: good.rowIds.contacts } })).toThrow();
1292
- expect(start({ values: good.values })).toThrow();
1293
- expect(start("nothing")).toThrow();
1294
- expect(start(null)).toThrow();
1295
- expect(start(good)).not.toThrow();
1312
+ assertThrows(start({ ...good, rowIds: { ...good.rowIds, contacts: ["a", "b"] } }));
1313
+ assertThrows(start({ ...good, rowIds: { ...good.rowIds, invites: ["k", "k"] } }));
1314
+ assertThrows(start({ ...good, rowIds: { ...good.rowIds, name: ["x"] } }));
1315
+ assertThrows(start({ ...good, rowIds: { ...good.rowIds, contacts: ["a", "b", 7] } }));
1316
+ assertThrows(start({ ...good, rowIds: { contacts: good.rowIds.contacts } }));
1317
+ assertThrows(start({ ...good, rowIds: { ...good.rowIds, invites: good.rowIds.contacts } }));
1318
+ assertThrows(start({ values: good.values }));
1319
+ assertThrows(start("nothing"));
1320
+ assertThrows(start(null));
1321
+ assertDoesNotThrow(start(good));
1296
1322
  }
1297
1323
  },
1298
1324
  {
1299
1325
  rule: "array reindexing",
1300
1326
  name: "containers built from the same defaults mint the same row ids",
1301
1327
  run(createStore) {
1302
- expect(createStore(fixture().options).getSnapshot().rowIds).toEqual(
1328
+ assertEqual(
1329
+ createStore(fixture().options).getSnapshot().rowIds,
1303
1330
  createStore(fixture().options).getSnapshot().rowIds
1304
1331
  );
1305
1332
  }
@@ -1311,26 +1338,25 @@ var cases = [
1311
1338
  const store = createStore(fixture().options);
1312
1339
  const answer = await passedSubmission(store);
1313
1340
  const values = store.getSnapshot().values;
1314
- expect(() => answer.setServerErrors({ __secret: { message: "x" } })).toThrow(/reserved segment '__secret'/);
1315
- expect(() => answer.setServerErrors({ "contacts.__proto__.email": { message: "x" } })).toThrow(/reserved/);
1316
- expect(() => store.blur(FORM_ROOT)).toThrow(/reserved/);
1317
- expect(() => store.setValue("__x", 1)).toThrow(/reserved/);
1318
- expect(() => store.reportNative({ __x: { type: "valueMissing" } })).toThrow(/reserved/);
1319
- expect(() => answer.setServerErrors({ "contacts.4.email": { message: "bounced" } })).toThrow(
1341
+ assertThrows(() => answer.setServerErrors({ __secret: { message: "x" } }), /reserved segment '__secret'/);
1342
+ assertThrows(() => answer.setServerErrors({ "contacts.__proto__.email": { message: "x" } }), /reserved/);
1343
+ assertThrows(() => store.blur(FORM_ROOT), /reserved/);
1344
+ assertThrows(() => store.setValue("__x", 1), /reserved/);
1345
+ assertThrows(() => store.reportNative({ __x: { type: "valueMissing" } }), /reserved/);
1346
+ assertThrows(
1347
+ () => answer.setServerErrors({ "contacts.4.email": { message: "bounced" } }),
1320
1348
  /'contacts.4.email' names row '4' of 'contacts', which has 3 rows/
1321
1349
  );
1322
- expect(() => answer.setServerErrors({ "contacts.x": { message: "x" } })).toThrow(/names row 'x'/);
1323
- expect(() => answer.setServerErrors({ "contacts.-1.email": { message: "x" } })).toThrow(/names row '-1'/);
1324
- expect(() => answer.setServerErrors({ "contacts.1e-7.email": { message: "x" } })).toThrow(
1325
- /names row '1e-7'/
1326
- );
1327
- expect(() => answer.setServerErrors({ "contacts.01.email": { message: "x" } })).toThrow(/names row '01'/);
1328
- expect(store.getSnapshot().values).toBe(values);
1329
- expect(store.getSnapshot().errors).toEqual({});
1330
- expect(
1350
+ assertThrows(() => answer.setServerErrors({ "contacts.x": { message: "x" } }), /names row 'x'/);
1351
+ assertThrows(() => answer.setServerErrors({ "contacts.-1.email": { message: "x" } }), /names row '-1'/);
1352
+ assertThrows(() => answer.setServerErrors({ "contacts.1e-7.email": { message: "x" } }), /names row '1e-7'/);
1353
+ assertThrows(() => answer.setServerErrors({ "contacts.01.email": { message: "x" } }), /names row '01'/);
1354
+ assertSame(store.getSnapshot().values, values);
1355
+ assertEqual(store.getSnapshot().errors, {});
1356
+ assertDoesNotThrow(
1331
1357
  () => answer.setServerErrors({ "nothing.here": { message: "fine" }, [FORM_ROOT]: { message: "form" } })
1332
- ).not.toThrow();
1333
- expect(Object.keys(errorsOf(store))).toEqual([FORM_ROOT]);
1358
+ );
1359
+ assertEqual(Object.keys(errorsOf(store)), [FORM_ROOT]);
1334
1360
  }
1335
1361
  },
1336
1362
  {
@@ -1342,12 +1368,12 @@ var cases = [
1342
1368
  gate.hold("taken");
1343
1369
  store.setValue("slug", "taken");
1344
1370
  const run = store.validate(["slug"]);
1345
- await vi.waitFor(() => expect(gate.pending("taken")).toBe(1));
1346
- expect(isValidating(store)).toBe(true);
1371
+ await waitFor(() => assertSame(gate.pending("taken"), 1));
1372
+ assertSame(isValidating(store), true);
1347
1373
  gate.settle("taken", false);
1348
- expect(await run).toEqual({ outcome: "invalid" });
1349
- expect(errorsOf(store).slug?.type).toBe("gate");
1350
- expect(isValidating(store)).toBe(false);
1374
+ assertEqual(await run, { outcome: "invalid" });
1375
+ assertSame(errorsOf(store).slug?.type, "gate");
1376
+ assertSame(isValidating(store), false);
1351
1377
  }
1352
1378
  },
1353
1379
  {
@@ -1359,13 +1385,13 @@ var cases = [
1359
1385
  gate.hold("taken");
1360
1386
  store.setValue("slug", "other");
1361
1387
  store.setValue("slug", "taken");
1362
- await vi.waitFor(() => expect(gate.pending("taken")).toBe(1));
1388
+ await waitFor(() => assertSame(gate.pending("taken"), 1));
1363
1389
  store.reset();
1364
- expect(store.getValue("slug")).toBe("taken");
1390
+ assertSame(store.getValue("slug"), "taken");
1365
1391
  gate.settle("taken", false);
1366
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1392
+ await waitFor(() => assertSame(isValidating(store), false));
1367
1393
  await settle();
1368
- expect(errorsOf(store)).toEqual({});
1394
+ assertEqual(errorsOf(store), {});
1369
1395
  }
1370
1396
  },
1371
1397
  {
@@ -1384,14 +1410,14 @@ var cases = [
1384
1410
  const store = createStore(options);
1385
1411
  gate.hold("one");
1386
1412
  store.blur("invites.0.code");
1387
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1413
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1388
1414
  store.fieldArray("invites").swap(0, 1);
1389
1415
  gate.settle("one", false);
1390
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1416
+ await waitFor(() => assertSame(isValidating(store), false));
1391
1417
  await settle();
1392
- expect(store.getValue("invites.1.label")).toBe("first");
1393
- expect(Object.keys(errorsOf(store))).toEqual(["invites.1.code"]);
1394
- expect(marked(store.getSnapshot().touched)).toEqual(["invites.1.code"]);
1418
+ assertSame(store.getValue("invites.1.label"), "first");
1419
+ assertEqual(Object.keys(errorsOf(store)), ["invites.1.code"]);
1420
+ assertEqual(marked(store.getSnapshot().touched), ["invites.1.code"]);
1395
1421
  }
1396
1422
  },
1397
1423
  {
@@ -1410,12 +1436,12 @@ var cases = [
1410
1436
  const store = createStore(options);
1411
1437
  gate.hold("one");
1412
1438
  store.blur("invites.0.code");
1413
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1439
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1414
1440
  store.fieldArray("invites").remove(0);
1415
1441
  gate.settle("one", false);
1416
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1442
+ await waitFor(() => assertSame(isValidating(store), false));
1417
1443
  await settle();
1418
- expect(errorsOf(store)).toEqual({});
1444
+ assertEqual(errorsOf(store), {});
1419
1445
  }
1420
1446
  },
1421
1447
  {
@@ -1426,16 +1452,16 @@ var cases = [
1426
1452
  const store = createStore(options);
1427
1453
  gate.hold("taken");
1428
1454
  const run = store.validate(["slug"]);
1429
- await vi.waitFor(() => expect(gate.pending("taken")).toBe(1));
1455
+ await waitFor(() => assertSame(gate.pending("taken"), 1));
1430
1456
  store.setValue("slug", "other");
1431
1457
  store.reset();
1432
1458
  const watch = watchValidation(store);
1433
1459
  gate.settle("taken", false);
1434
- expect(await run).toEqual({ outcome: "overtaken" });
1435
- expect(watch.started).toBe(false);
1436
- expect(gate.pending("taken")).toBe(0);
1437
- expect(errorsOf(store)).toEqual({});
1438
- expect(isValidating(store)).toBe(false);
1460
+ assertEqual(await run, { outcome: "overtaken" });
1461
+ assertSame(watch.started, false);
1462
+ assertSame(gate.pending("taken"), 0);
1463
+ assertEqual(errorsOf(store), {});
1464
+ assertSame(isValidating(store), false);
1439
1465
  }
1440
1466
  },
1441
1467
  {
@@ -1449,12 +1475,12 @@ var cases = [
1449
1475
  const store = createStore(options);
1450
1476
  gate.hold("one");
1451
1477
  store.blur("invites.0.code");
1452
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1478
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1453
1479
  store.fieldArray("invites").replace([{ code: "one", label: "second" }]);
1454
1480
  gate.settle("one", false);
1455
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1481
+ await waitFor(() => assertSame(isValidating(store), false));
1456
1482
  await settle();
1457
- expect(errorsOf(store)).toEqual({});
1483
+ assertEqual(errorsOf(store), {});
1458
1484
  }
1459
1485
  },
1460
1486
  {
@@ -1473,13 +1499,13 @@ var cases = [
1473
1499
  const store = createStore(options);
1474
1500
  gate.hold("one");
1475
1501
  store.blur("groups.0.members.1.code");
1476
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1502
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1477
1503
  store.fieldArray("groups").swap(0, 1);
1478
1504
  store.fieldArray("groups.1.members").remove(0);
1479
1505
  gate.settle("one", false);
1480
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1506
+ await waitFor(() => assertSame(isValidating(store), false));
1481
1507
  await settle();
1482
- expect(Object.keys(errorsOf(store))).toEqual(["groups.1.members.0.code"]);
1508
+ assertEqual(Object.keys(errorsOf(store)), ["groups.1.members.0.code"]);
1483
1509
  }
1484
1510
  },
1485
1511
  {
@@ -1490,13 +1516,13 @@ var cases = [
1490
1516
  const store = createStore(options);
1491
1517
  gate.hold("one", "two");
1492
1518
  const run = store.validate(["invites"]);
1493
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1519
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1494
1520
  store.fieldArray("invites").swap(0, 1);
1495
1521
  gate.settle("one", false);
1496
1522
  gate.settle("two", true);
1497
- expect(await run).toEqual({ outcome: "invalid" });
1498
- expect(Object.keys(errorsOf(store))).toEqual(["invites.1.code"]);
1499
- expect(isValidating(store)).toBe(false);
1523
+ assertEqual(await run, { outcome: "invalid" });
1524
+ assertEqual(Object.keys(errorsOf(store)), ["invites.1.code"]);
1525
+ assertSame(isValidating(store), false);
1500
1526
  }
1501
1527
  },
1502
1528
  {
@@ -1508,11 +1534,11 @@ var cases = [
1508
1534
  gate.hold("taken");
1509
1535
  store.setValue("slug", "taken");
1510
1536
  const run = store.validate(["slug"]);
1511
- await vi.waitFor(() => expect(gate.pending("taken")).toBe(1));
1537
+ await waitFor(() => assertSame(gate.pending("taken"), 1));
1512
1538
  store.setValue("slug", "free");
1513
1539
  gate.settle("taken", false);
1514
- expect(await run).toEqual({ outcome: "passed" });
1515
- expect(errorsOf(store).slug).toBeUndefined();
1540
+ assertEqual(await run, { outcome: "passed" });
1541
+ assertUndefined(errorsOf(store).slug);
1516
1542
  }
1517
1543
  },
1518
1544
  {
@@ -1525,14 +1551,14 @@ var cases = [
1525
1551
  gate.hold("a", "b");
1526
1552
  store.setValue("slug", "a");
1527
1553
  const run = store.validate(["slug"]);
1528
- await vi.waitFor(() => expect(gate.pending("a")).toBe(1));
1554
+ await waitFor(() => assertSame(gate.pending("a"), 1));
1529
1555
  store.setValue("slug", "b");
1530
1556
  gate.settle("a", true);
1531
- await vi.waitFor(() => expect(gate.pending("b")).toBe(1));
1557
+ await waitFor(() => assertSame(gate.pending("b"), 1));
1532
1558
  store.setValue("slug", "taken");
1533
1559
  gate.settle("b", true);
1534
- expect(await run).toEqual({ outcome: "overtaken" });
1535
- expect(await store.validate(["slug"])).toEqual({ outcome: "invalid" });
1560
+ assertEqual(await run, { outcome: "overtaken" });
1561
+ assertEqual(await store.validate(["slug"]), { outcome: "invalid" });
1536
1562
  }
1537
1563
  },
1538
1564
  {
@@ -1544,13 +1570,13 @@ var cases = [
1544
1570
  gate.hold("taken");
1545
1571
  const validated = store.validate(["slug"]);
1546
1572
  const submitted = store.submit();
1547
- await vi.waitFor(() => expect(gate.pending("taken")).toBe(2));
1573
+ await waitFor(() => assertSame(gate.pending("taken"), 2));
1548
1574
  store.reset();
1549
1575
  gate.settle("taken", false);
1550
- expect(await validated).toEqual({ outcome: "overtaken" });
1551
- expect(await submitted).toEqual({ outcome: "overtaken" });
1552
- expect(errorsOf(store)).toEqual({});
1553
- expect(await store.validate(["slug"])).toEqual({ outcome: "invalid" });
1576
+ assertEqual(await validated, { outcome: "overtaken" });
1577
+ assertEqual(await submitted, { outcome: "overtaken" });
1578
+ assertEqual(errorsOf(store), {});
1579
+ assertEqual(await store.validate(["slug"]), { outcome: "invalid" });
1554
1580
  }
1555
1581
  },
1556
1582
  {
@@ -1561,11 +1587,11 @@ var cases = [
1561
1587
  const store = createStore(options);
1562
1588
  gate.hold("one");
1563
1589
  const run = store.validate(["invites.0.code"]);
1564
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1590
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1565
1591
  store.fieldArray("invites").swap(0, 1);
1566
1592
  gate.settle("one", false);
1567
- expect(await run).toEqual({ outcome: "invalid" });
1568
- expect(Object.keys(errorsOf(store))).toEqual(["invites.1.code"]);
1593
+ assertEqual(await run, { outcome: "invalid" });
1594
+ assertEqual(Object.keys(errorsOf(store)), ["invites.1.code"]);
1569
1595
  }
1570
1596
  },
1571
1597
  {
@@ -1576,22 +1602,22 @@ var cases = [
1576
1602
  const store = createStore(options);
1577
1603
  gate.hold("two");
1578
1604
  const removed = store.validate(["invites.1.code"]);
1579
- await vi.waitFor(() => expect(gate.pending("two")).toBe(1));
1605
+ await waitFor(() => assertSame(gate.pending("two"), 1));
1580
1606
  store.fieldArray("invites").remove(1);
1581
1607
  gate.settle("two", false);
1582
- expect(await removed).toEqual({ outcome: "overtaken" });
1583
- expect(errorsOf(store)).toEqual({});
1608
+ assertEqual(await removed, { outcome: "overtaken" });
1609
+ assertEqual(errorsOf(store), {});
1584
1610
  const other = createStore(fixture().options);
1585
1611
  const held = fixture();
1586
1612
  held.gate.hold("one");
1587
1613
  const reset = createStore(held.options);
1588
1614
  const overtaken = reset.validate(["invites.0.code"]);
1589
- await vi.waitFor(() => expect(held.gate.pending("one")).toBe(1));
1615
+ await waitFor(() => assertSame(held.gate.pending("one"), 1));
1590
1616
  reset.reset();
1591
1617
  held.gate.settle("one", false);
1592
- expect(await overtaken).toEqual({ outcome: "overtaken" });
1593
- expect(errorsOf(reset)).toEqual({});
1594
- expect(await other.validate()).toEqual({ outcome: "passed" });
1618
+ assertEqual(await overtaken, { outcome: "overtaken" });
1619
+ assertEqual(errorsOf(reset), {});
1620
+ assertEqual(await other.validate(), { outcome: "passed" });
1595
1621
  }
1596
1622
  },
1597
1623
  {
@@ -1604,15 +1630,15 @@ var cases = [
1604
1630
  const answer = await passedSubmission(store);
1605
1631
  gate.hold("pending");
1606
1632
  const first = store.checkValidity();
1607
- await vi.waitFor(() => expect(gate.pending("pending")).toBe(1));
1633
+ await waitFor(() => assertSame(gate.pending("pending"), 1));
1608
1634
  answer.setServerErrors({ "invites.0.code": { type: "late" } });
1609
1635
  gate.settle("pending", true);
1610
- expect(await first).toBe(true);
1611
- expect(await store.checkValidity()).toBe(false);
1636
+ assertSame(await first, true);
1637
+ assertSame(await store.checkValidity(), false);
1612
1638
  store.setValue("invites.0.code", "other");
1613
- expect(await store.checkValidity()).toBe(true);
1639
+ assertSame(await store.checkValidity(), true);
1614
1640
  store.reportNative({ "invites.0.code": { type: "valueMissing" } });
1615
- expect(await store.checkValidity()).toBe(false);
1641
+ assertSame(await store.checkValidity(), false);
1616
1642
  }
1617
1643
  },
1618
1644
  {
@@ -1623,11 +1649,11 @@ var cases = [
1623
1649
  const run = store.submit();
1624
1650
  store.setValue("nickname", "ada2");
1625
1651
  const submitted = passedOf(await run);
1626
- expect(submitted.values.nickname).toBe("ada2");
1627
- expect(submitted.values).toEqual(store.getSnapshot().values);
1628
- expect(Object.isFrozen(submitted.values)).toBe(true);
1652
+ assertSame(submitted.values.nickname, "ada2");
1653
+ assertEqual(submitted.values, store.getSnapshot().values);
1654
+ assertSame(Object.isFrozen(submitted.values), true);
1629
1655
  submitted.setServerErrors({ nickname: { type: "taken" } });
1630
- expect(errorsOf(store).nickname?.type).toBe("taken");
1656
+ assertSame(errorsOf(store).nickname?.type, "taken");
1631
1657
  }
1632
1658
  },
1633
1659
  {
@@ -1636,13 +1662,13 @@ var cases = [
1636
1662
  async run(createStore) {
1637
1663
  const store = createStore(fixture().options);
1638
1664
  store.setValue("name", "");
1639
- expect(await store.submit()).toEqual({ outcome: "invalid" });
1665
+ assertEqual(await store.submit(), { outcome: "invalid" });
1640
1666
  store.setValue("name", "Grace");
1641
1667
  const submitted = await passedSubmission(store);
1642
- expect(submitted.values.name).toBe("Grace");
1668
+ assertSame(submitted.values.name, "Grace");
1643
1669
  store.setValue("nickname", "changed");
1644
1670
  submitted.setServerErrors({ name: { type: "taken" }, nickname: { type: "taken" } });
1645
- expect(Object.keys(errorsOf(store))).toEqual(["name"]);
1671
+ assertEqual(Object.keys(errorsOf(store)), ["name"]);
1646
1672
  }
1647
1673
  },
1648
1674
  {
@@ -1653,11 +1679,11 @@ var cases = [
1653
1679
  const older = store.submit();
1654
1680
  const newer = store.submit();
1655
1681
  store.setValue("name", "Grace");
1656
- expect(await older).toEqual({ outcome: "overtaken" });
1682
+ assertEqual(await older, { outcome: "overtaken" });
1657
1683
  const submitted = passedOf(await newer);
1658
- expect(submitted.values.name).toBe("Grace");
1659
- expect(Object.isFrozen(submitted.values)).toBe(true);
1660
- expect(submitted.values).toBe(submitted.values);
1684
+ assertSame(submitted.values.name, "Grace");
1685
+ assertSame(Object.isFrozen(submitted.values), true);
1686
+ assertSame(submitted.values, submitted.values);
1661
1687
  }
1662
1688
  },
1663
1689
  {
@@ -1668,37 +1694,37 @@ var cases = [
1668
1694
  const store = createStore(options);
1669
1695
  gate.hold("one");
1670
1696
  store.blur("invites.0.code");
1671
- await vi.waitFor(() => expect(gate.pending("one")).toBe(1));
1672
- expect(store.getSnapshot().validating).toEqual({ "invites.0.code": true });
1673
- expect(isValidating(store)).toBe(true);
1674
- expect(fieldState(store, "invites.0.code").isValidating).toBe(true);
1675
- expect(fieldState(store, "invites.1.code").isValidating).toBe(false);
1697
+ await waitFor(() => assertSame(gate.pending("one"), 1));
1698
+ assertEqual(store.getSnapshot().validating, { "invites.0.code": true });
1699
+ assertSame(isValidating(store), true);
1700
+ assertSame(fieldState(store, "invites.0.code").isValidating, true);
1701
+ assertSame(fieldState(store, "invites.1.code").isValidating, false);
1676
1702
  store.fieldArray("invites").swap(0, 1);
1677
- expect(store.getSnapshot().validating).toEqual({ "invites.1.code": true });
1703
+ assertEqual(store.getSnapshot().validating, { "invites.1.code": true });
1678
1704
  gate.settle("one", true);
1679
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1705
+ await waitFor(() => assertSame(isValidating(store), false));
1680
1706
  await settle();
1681
- expect(store.getSnapshot().validating).toEqual({});
1707
+ assertEqual(store.getSnapshot().validating, {});
1682
1708
  const racing = fixture();
1683
1709
  racing.gate.hold("a");
1684
1710
  const second = createStore(racing.options);
1685
1711
  second.setValue("slug", "a");
1686
1712
  const older = second.validate(["slug"]);
1687
- await vi.waitFor(() => expect(racing.gate.pending("a")).toBe(1));
1713
+ await waitFor(() => assertSame(racing.gate.pending("a"), 1));
1688
1714
  second.setValue("slug", "b");
1689
- expect(await second.validate(["slug"])).toEqual({ outcome: "passed" });
1690
- expect(second.getSnapshot().validating).toEqual({});
1715
+ assertEqual(await second.validate(["slug"]), { outcome: "passed" });
1716
+ assertEqual(second.getSnapshot().validating, {});
1691
1717
  racing.gate.settle("a", true);
1692
- expect(await older).toEqual({ outcome: "passed" });
1718
+ assertEqual(await older, { outcome: "passed" });
1693
1719
  }
1694
1720
  },
1695
1721
  {
1696
1722
  rule: "pending per field",
1697
1723
  name: "a superseded async check leaves no issue and no pending mark: pending is state, never an issue",
1698
1724
  async run(createStore) {
1699
- vi.stubGlobal(
1725
+ const restoreFetch = stubGlobal(
1700
1726
  "fetch",
1701
- vi.fn(async () => new Response(JSON.stringify({ valid: true })))
1727
+ createSpy(async () => new Response(JSON.stringify({ valid: true })))
1702
1728
  );
1703
1729
  try {
1704
1730
  const store = createStore(
@@ -1716,14 +1742,14 @@ var cases = [
1716
1742
  );
1717
1743
  store.setValue("handle", "a");
1718
1744
  store.setValue("handle", "ab");
1719
- await vi.waitFor(() => expect(isValidating(store)).toBe(false), { timeout: 2e3 });
1720
- expect(errorsOf(store)).toEqual({});
1721
- expect(store.getSnapshot().warnings).toEqual({});
1722
- expect(store.getSnapshot().validating).toEqual({});
1723
- expect(JSON.stringify(store.getSnapshot())).not.toMatch(/pending/i);
1724
- expect(await store.validate()).toEqual({ outcome: "passed" });
1745
+ await waitFor(() => assertSame(isValidating(store), false), { timeout: 2e3 });
1746
+ assertEqual(errorsOf(store), {});
1747
+ assertEqual(store.getSnapshot().warnings, {});
1748
+ assertEqual(store.getSnapshot().validating, {});
1749
+ assertNotMatches(JSON.stringify(store.getSnapshot()), /pending/i);
1750
+ assertEqual(await store.validate(), { outcome: "passed" });
1725
1751
  } finally {
1726
- vi.unstubAllGlobals();
1752
+ restoreFetch();
1727
1753
  }
1728
1754
  }
1729
1755
  },
@@ -1734,18 +1760,18 @@ var cases = [
1734
1760
  const store = createStore(fixture().options);
1735
1761
  const old = await passedSubmission(store);
1736
1762
  old.setServerErrors({ name: { type: "old" } });
1737
- expect(errorsOf(store).name?.type).toBe("old");
1763
+ assertSame(errorsOf(store).name?.type, "old");
1738
1764
  const submission = await passedSubmission(store);
1739
- expect(errorsOf(store)).toEqual({});
1765
+ assertEqual(errorsOf(store), {});
1740
1766
  store.setValue("name", "Grace");
1741
1767
  submission.setServerErrors({ name: { type: "taken" }, nickname: { type: "blocked" } });
1742
- expect(Object.keys(errorsOf(store))).toEqual(["nickname"]);
1768
+ assertEqual(Object.keys(errorsOf(store)), ["nickname"]);
1743
1769
  store.setValue("nickname", "other");
1744
- expect(errorsOf(store)).toEqual({});
1770
+ assertEqual(errorsOf(store), {});
1745
1771
  const formWide = await passedSubmission(store);
1746
1772
  store.setValue("slug", "changed");
1747
1773
  formWide.setServerErrors({ [FORM_ROOT]: { type: "invalid_credentials" } });
1748
- expect(errorsOf(store)).toEqual({});
1774
+ assertEqual(errorsOf(store), {});
1749
1775
  }
1750
1776
  },
1751
1777
  {
@@ -1759,12 +1785,12 @@ var cases = [
1759
1785
  "contacts.0.email": { type: "bounced" },
1760
1786
  "contacts.2.email": { type: "blocked" }
1761
1787
  });
1762
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["contacts.1.email", "contacts.2.email"]);
1788
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["contacts.1.email", "contacts.2.email"]);
1763
1789
  store.fieldArray("contacts").remove(2);
1764
1790
  const again = await passedSubmission(store);
1765
1791
  store.fieldArray("contacts").remove(0);
1766
1792
  again.setServerErrors({ "contacts.0.email": { type: "bounced" } });
1767
- expect(errorsOf(store)).toEqual({});
1793
+ assertEqual(errorsOf(store), {});
1768
1794
  }
1769
1795
  },
1770
1796
  {
@@ -1775,13 +1801,13 @@ var cases = [
1775
1801
  const stale = await passedSubmission(store);
1776
1802
  store.setValue("password", "b");
1777
1803
  stale.setServerErrors({ confirm: { type: "mismatch" } });
1778
- expect(errorsOf(store)).toEqual({});
1804
+ assertEqual(errorsOf(store), {});
1779
1805
  store.setValue("password", "a");
1780
1806
  const fresh = await passedSubmission(store);
1781
1807
  fresh.setServerErrors({ confirm: { type: "mismatch" } });
1782
- expect(errorsOf(store).confirm?.type).toBe("mismatch");
1808
+ assertSame(errorsOf(store).confirm?.type, "mismatch");
1783
1809
  store.setValue("password", "b");
1784
- expect(errorsOf(store)).toEqual({});
1810
+ assertEqual(errorsOf(store), {});
1785
1811
  }
1786
1812
  },
1787
1813
  {
@@ -1792,14 +1818,14 @@ var cases = [
1792
1818
  const beforeReset = await passedSubmission(store);
1793
1819
  store.reset();
1794
1820
  beforeReset.setServerErrors({ name: { type: "taken" } });
1795
- expect(errorsOf(store)).toEqual({});
1821
+ assertEqual(errorsOf(store), {});
1796
1822
  const first = await passedSubmission(store);
1797
1823
  const second = await passedSubmission(store);
1798
1824
  first.setServerErrors({ name: { type: "taken" } });
1799
- expect(errorsOf(store)).toEqual({});
1825
+ assertEqual(errorsOf(store), {});
1800
1826
  second.setServerErrors({ name: { type: "taken" } });
1801
- expect(errorsOf(store).name?.type).toBe("taken");
1802
- expect(second.values).toEqual(store.getSnapshot().values);
1827
+ assertSame(errorsOf(store).name?.type, "taken");
1828
+ assertEqual(second.values, store.getSnapshot().values);
1803
1829
  }
1804
1830
  },
1805
1831
  {
@@ -1815,8 +1841,8 @@ var cases = [
1815
1841
  ],
1816
1842
  nickname: []
1817
1843
  });
1818
- expect(Object.keys(errorsOf(store))).toEqual(["name"]);
1819
- expect(errorsOf(store).name.all).toEqual([
1844
+ assertEqual(Object.keys(errorsOf(store)), ["name"]);
1845
+ assertEqual(errorsOf(store).name.all, [
1820
1846
  { type: "taken", source: "server", message: "Already registered" },
1821
1847
  { type: "blocked_domain", source: "server", params: { domain: "example.com" } }
1822
1848
  ]);
@@ -1829,15 +1855,15 @@ var cases = [
1829
1855
  const store = createStore(fixture({ validationMode: "onChange" }).options);
1830
1856
  store.setValue("nickname", "bad");
1831
1857
  store.reportNative({ nickname: { type: "typeMismatch" } });
1832
- await vi.waitFor(() => expect(errorsOf(store).nickname?.source).toBe("native"));
1833
- expect(await store.checkValidity()).toBe(false);
1858
+ await waitFor(() => assertSame(errorsOf(store).nickname?.source, "native"));
1859
+ assertSame(await store.checkValidity(), false);
1834
1860
  store.setValue("nickname", "good");
1835
- await vi.waitFor(() => expect(errorsOf(store).nickname).toBeUndefined());
1836
- expect(await store.checkValidity()).toBe(true);
1861
+ await waitFor(() => assertUndefined(errorsOf(store).nickname));
1862
+ assertSame(await store.checkValidity(), true);
1837
1863
  store.setValue("nickname", "bad");
1838
1864
  await settle();
1839
- expect(errorsOf(store).nickname).toBeUndefined();
1840
- expect(await store.validate(["nickname"])).toEqual({ outcome: "passed" });
1865
+ assertUndefined(errorsOf(store).nickname);
1866
+ assertEqual(await store.validate(["nickname"]), { outcome: "passed" });
1841
1867
  }
1842
1868
  },
1843
1869
  {
@@ -1847,17 +1873,17 @@ var cases = [
1847
1873
  const store = createStore(fixture({ validationMode: "onChange" }).options);
1848
1874
  store.setValue("nickname", "nick");
1849
1875
  store.reportNative({ nickname: { type: "badInput" } });
1850
- await vi.waitFor(() => expect(errorsOf(store).nickname?.source).toBe("native"));
1851
- await vi.waitFor(() => expect(isValidating(store)).toBe(false));
1876
+ await waitFor(() => assertSame(errorsOf(store).nickname?.source, "native"));
1877
+ await waitFor(() => assertSame(isValidating(store), false));
1852
1878
  await settle();
1853
1879
  const watch = watchValidation(store);
1854
1880
  const before = store.getSnapshot();
1855
1881
  store.reportNative({ nickname: { type: "badInput" } });
1856
1882
  store.setValue("nickname", "nick");
1857
1883
  await settle();
1858
- expect(watch.started).toBe(false);
1859
- expect(store.getSnapshot()).toBe(before);
1860
- expect(await store.checkValidity()).toBe(false);
1884
+ assertSame(watch.started, false);
1885
+ assertSame(store.getSnapshot(), before);
1886
+ assertSame(await store.checkValidity(), false);
1861
1887
  }
1862
1888
  },
1863
1889
  {
@@ -1865,23 +1891,23 @@ var cases = [
1865
1891
  name: "reportNative binds facts to the values held now, validates only paths already checked, and is no user change",
1866
1892
  async run(createStore) {
1867
1893
  const store = createStore(fixture({ validationMode: "onChange" }).options);
1868
- const listener = vi.fn();
1894
+ const listener = createSpy();
1869
1895
  store.subscribe(listener);
1870
1896
  store.reportNative({ nickname: { type: "valueMissing" } });
1871
1897
  await settle();
1872
- expect(errorsOf(store)).toEqual({});
1873
- expect(store.getSnapshot().dirty).toEqual({});
1874
- expect(store.getSnapshot().touched).toEqual({});
1875
- expect(listener).not.toHaveBeenCalled();
1876
- expect(await store.checkValidity()).toBe(false);
1877
- expect(await store.validate(["name"])).toEqual({ outcome: "passed" });
1898
+ assertEqual(errorsOf(store), {});
1899
+ assertEqual(store.getSnapshot().dirty, {});
1900
+ assertEqual(store.getSnapshot().touched, {});
1901
+ assertCallCount(listener, 0);
1902
+ assertSame(await store.checkValidity(), false);
1903
+ assertEqual(await store.validate(["name"]), { outcome: "passed" });
1878
1904
  store.reportNative({ name: { type: "typeMismatch", params: { type: "email" } }, nickname: null });
1879
- await vi.waitFor(() => expect(errorsOf(store).name?.type).toBe("typeMismatch"));
1880
- expect(await store.checkValidity()).toBe(false);
1905
+ await waitFor(() => assertSame(errorsOf(store).name?.type, "typeMismatch"));
1906
+ assertSame(await store.checkValidity(), false);
1881
1907
  store.reportNative({ name: null });
1882
- await vi.waitFor(() => expect(errorsOf(store).name).toBeUndefined());
1883
- expect(await store.checkValidity()).toBe(true);
1884
- expect(store.getSnapshot().dirty).toEqual({});
1908
+ await waitFor(() => assertUndefined(errorsOf(store).name));
1909
+ assertSame(await store.checkValidity(), true);
1910
+ assertEqual(store.getSnapshot().dirty, {});
1885
1911
  }
1886
1912
  },
1887
1913
  {
@@ -1891,7 +1917,7 @@ var cases = [
1891
1917
  const store = createStore(fixture({ validationMode: "onChange" }).options);
1892
1918
  store.setValue("nickname", "x");
1893
1919
  store.reportNative({ nickname: { type: "typeMismatch" } });
1894
- await vi.waitFor(() => expect(errorsOf(store).nickname?.source).toBe("native"));
1920
+ await waitFor(() => assertSame(errorsOf(store).nickname?.source, "native"));
1895
1921
  store.reset();
1896
1922
  store.reportNative({
1897
1923
  nickname: { type: "valueMissing" },
@@ -1899,11 +1925,11 @@ var cases = [
1899
1925
  "nothing.here": { type: "valueMissing" }
1900
1926
  });
1901
1927
  await settle();
1902
- expect(errorsOf(store)).toEqual({});
1903
- expect(store.getSnapshot().isValid).toBe(true);
1928
+ assertEqual(errorsOf(store), {});
1929
+ assertSame(store.getSnapshot().isValid, true);
1904
1930
  store.fieldArray("contacts").remove(2);
1905
- expect(() => store.reportNative({ "contacts.2.email": { type: "valueMissing" } })).not.toThrow();
1906
- expect(await store.checkValidity()).toBe(false);
1931
+ assertDoesNotThrow(() => store.reportNative({ "contacts.2.email": { type: "valueMissing" } }));
1932
+ assertSame(await store.checkValidity(), false);
1907
1933
  }
1908
1934
  },
1909
1935
  {
@@ -1914,11 +1940,11 @@ var cases = [
1914
1940
  store.blur("contacts.1.label");
1915
1941
  store.reportNative({ "contacts.1.label": { type: "typeMismatch" } });
1916
1942
  store.fieldArray("contacts").swap(1, 2);
1917
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1918
- expect(Object.keys(errorsOf(store))).toEqual(["contacts.2.label"]);
1943
+ assertEqual(await store.validate(), { outcome: "invalid" });
1944
+ assertEqual(Object.keys(errorsOf(store)), ["contacts.2.label"]);
1919
1945
  store.fieldArray("contacts").remove(2);
1920
- expect(await store.validate()).toEqual({ outcome: "passed" });
1921
- expect(errorsOf(store)).toEqual({});
1946
+ assertEqual(await store.validate(), { outcome: "passed" });
1947
+ assertEqual(errorsOf(store), {});
1922
1948
  }
1923
1949
  },
1924
1950
  {
@@ -1927,15 +1953,15 @@ var cases = [
1927
1953
  async run(createStore) {
1928
1954
  const store = createStore(fixture().options);
1929
1955
  store.reportNative({ name: { type: "valueMissing" }, nickname: { type: "valueMissing" } });
1930
- expect(await store.checkValidity()).toBe(false);
1956
+ assertSame(await store.checkValidity(), false);
1931
1957
  store.reportNative({ nickname: null });
1932
- expect(await store.checkValidity()).toBe(false);
1933
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1934
- expect(Object.keys(errorsOf(store))).toEqual(["name"]);
1958
+ assertSame(await store.checkValidity(), false);
1959
+ assertEqual(await store.validate(), { outcome: "invalid" });
1960
+ assertEqual(Object.keys(errorsOf(store)), ["name"]);
1935
1961
  store.reportNative({ name: null });
1936
- expect(await store.checkValidity()).toBe(true);
1937
- expect(await store.validate()).toEqual({ outcome: "passed" });
1938
- expect(errorsOf(store)).toEqual({});
1962
+ assertSame(await store.checkValidity(), true);
1963
+ assertEqual(await store.validate(), { outcome: "passed" });
1964
+ assertEqual(errorsOf(store), {});
1939
1965
  }
1940
1966
  },
1941
1967
  {
@@ -1943,19 +1969,19 @@ var cases = [
1943
1969
  name: "one call reports several controls in one commit, and ignores the rows that do not exist",
1944
1970
  async run(createStore) {
1945
1971
  const store = createStore(fixture().options);
1946
- const listener = vi.fn();
1972
+ const listener = createSpy();
1947
1973
  store.subscribe(listener);
1948
1974
  store.reportNative({
1949
1975
  name: { type: "valueMissing" },
1950
1976
  nickname: { type: "valueMissing" },
1951
1977
  "contacts.9.email": { type: "valueMissing" }
1952
1978
  });
1953
- expect(listener).not.toHaveBeenCalled();
1954
- expect(await store.validate()).toEqual({ outcome: "invalid" });
1955
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["name", "nickname"]);
1979
+ assertCallCount(listener, 0);
1980
+ assertEqual(await store.validate(), { outcome: "invalid" });
1981
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["name", "nickname"]);
1956
1982
  store.reportNative({ name: null, nickname: null });
1957
- await vi.waitFor(() => expect(errorsOf(store)).toEqual({}));
1958
- expect(await store.validate()).toEqual({ outcome: "passed" });
1983
+ await waitFor(() => assertEqual(errorsOf(store), {}));
1984
+ assertEqual(await store.validate(), { outcome: "passed" });
1959
1985
  }
1960
1986
  },
1961
1987
  {
@@ -1964,14 +1990,17 @@ var cases = [
1964
1990
  async run(createStore) {
1965
1991
  const store = createStore(fixture().options);
1966
1992
  store.fieldArray("contacts").remove([0, 1, 2]);
1967
- expect(() => store.blur("contacts.0.label")).toThrow(/names row/);
1993
+ assertThrows(() => store.blur("contacts.0.label"), /names row/);
1968
1994
  store.setValue("contacts", null);
1969
1995
  store.reportNative({
1970
1996
  "contacts.0.label": { type: "valueMissing" },
1971
1997
  "contacts.1.label": { type: "valueMissing" }
1972
1998
  });
1973
1999
  await store.validate();
1974
- expect(Object.keys(errorsOf(store)).filter((path) => path.endsWith(".label"))).toEqual([]);
2000
+ assertEqual(
2001
+ Object.keys(errorsOf(store)).filter((path) => path.endsWith(".label")),
2002
+ []
2003
+ );
1975
2004
  store.setValue("contacts", []);
1976
2005
  const allowed = ["first"];
1977
2006
  const answer = await passedSubmission(store);
@@ -1981,9 +2010,9 @@ var cases = [
1981
2010
  await store.validate(["nickname"]);
1982
2011
  allowed.push("second");
1983
2012
  fact.params.list.push("b");
1984
- expect(errorsOf(store).name.params).toEqual({ allowed: ["first"] });
1985
- expect(errorsOf(store).nickname.params).toEqual({ list: ["a"] });
1986
- expect(Object.isFrozen(errorsOf(store).name.params.allowed)).toBe(true);
2013
+ assertEqual(errorsOf(store).name.params, { allowed: ["first"] });
2014
+ assertEqual(errorsOf(store).nickname.params, { list: ["a"] });
2015
+ assertSame(Object.isFrozen(errorsOf(store).name.params.allowed), true);
1987
2016
  }
1988
2017
  },
1989
2018
  {
@@ -1994,14 +2023,14 @@ var cases = [
1994
2023
  const store = createStore(options);
1995
2024
  gate.hold("two");
1996
2025
  const run = store.validate(["invites.1.code"]);
1997
- await vi.waitFor(() => expect(gate.pending("two")).toBe(1));
1998
- expect(store.getSnapshot().validating).toEqual({ "invites.1.code": true });
2026
+ await waitFor(() => assertSame(gate.pending("two"), 1));
2027
+ assertEqual(store.getSnapshot().validating, { "invites.1.code": true });
1999
2028
  store.setValue("invites", []);
2000
- expect(store.getSnapshot().validating).toEqual({});
2029
+ assertEqual(store.getSnapshot().validating, {});
2001
2030
  gate.settle("two", true);
2002
- expect(await run).toEqual({ outcome: "overtaken" });
2003
- expect(store.getSnapshot().validating).toEqual({});
2004
- expect(isValidating(store)).toBe(false);
2031
+ assertEqual(await run, { outcome: "overtaken" });
2032
+ assertEqual(store.getSnapshot().validating, {});
2033
+ assertSame(isValidating(store), false);
2005
2034
  }
2006
2035
  },
2007
2036
  {
@@ -2009,22 +2038,22 @@ var cases = [
2009
2038
  name: "a field a constraint hides takes no part: it does not block, count or show, however it was recorded",
2010
2039
  async run(createStore) {
2011
2040
  const store = createStore(businessForm());
2012
- expect(await store.validate()).toEqual({ outcome: "passed" });
2013
- expect(await store.checkValidity()).toBe(true);
2014
- expect(errorsOf(store)).toEqual({});
2041
+ assertEqual(await store.validate(), { outcome: "passed" });
2042
+ assertSame(await store.checkValidity(), true);
2043
+ assertEqual(errorsOf(store), {});
2015
2044
  store.setValue("kind", "business");
2016
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2017
- expect(errorsOf(store).company).toMatchObject({ type: "required", ruleId: "company-required" });
2045
+ assertEqual(await store.validate(), { outcome: "invalid" });
2046
+ assertMatches(errorsOf(store).company, { type: "required", ruleId: "company-required" });
2018
2047
  store.setValue("kind", "person");
2019
- expect(errorsOf(store)).toEqual({});
2020
- expect(store.getSnapshot().isValid).toBe(true);
2021
- expect(await store.validate()).toEqual({ outcome: "passed" });
2048
+ assertEqual(errorsOf(store), {});
2049
+ assertSame(store.getSnapshot().isValid, true);
2050
+ assertEqual(await store.validate(), { outcome: "passed" });
2022
2051
  await serverAnswer(store, { company: { type: "taken" } });
2023
2052
  store.blur("company");
2024
2053
  store.reportNative({ company: { type: "valueMissing" } });
2025
- expect(store.getSnapshot().isValid).toBe(true);
2026
- expect(await store.validate()).toEqual({ outcome: "passed" });
2027
- expect(await store.checkValidity()).toBe(true);
2054
+ assertSame(store.getSnapshot().isValid, true);
2055
+ assertEqual(await store.validate(), { outcome: "passed" });
2056
+ assertSame(await store.checkValidity(), true);
2028
2057
  }
2029
2058
  },
2030
2059
  {
@@ -2032,16 +2061,16 @@ var cases = [
2032
2061
  name: "a step its constraints hide is skipped: its fields take no part, its values are kept and the submitted values leave them out",
2033
2062
  async run(createStore) {
2034
2063
  const store = createStore(stepsForm({ hasCompany: false, wantsInvoice: "no", company: "", vat: "" }));
2035
- expect(await store.validate()).toEqual({ outcome: "passed" });
2036
- expect(await store.checkValidity()).toBe(true);
2037
- expect(errorsOf(store)).toEqual({});
2064
+ assertEqual(await store.validate(), { outcome: "passed" });
2065
+ assertSame(await store.checkValidity(), true);
2066
+ assertEqual(errorsOf(store), {});
2038
2067
  const submitted = await store.submit();
2039
- expect(submitted.outcome).toBe("passed");
2040
- if (submitted.outcome === "passed") expect(submitted.values).toEqual({ hasCompany: false });
2041
- expect(store.getSnapshot().values).toMatchObject({ wantsInvoice: "no", company: "" });
2068
+ assertSame(submitted.outcome, "passed");
2069
+ if (submitted.outcome === "passed") assertEqual(submitted.values, { hasCompany: false });
2070
+ assertMatches(store.getSnapshot().values, { wantsInvoice: "no", company: "" });
2042
2071
  store.setValue("hasCompany", true);
2043
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2044
- expect(Object.keys(errorsOf(store))).toEqual(["company"]);
2072
+ assertEqual(await store.validate(), { outcome: "invalid" });
2073
+ assertEqual(Object.keys(errorsOf(store)), ["company"]);
2045
2074
  }
2046
2075
  },
2047
2076
  {
@@ -2049,15 +2078,15 @@ var cases = [
2049
2078
  name: "a value that takes no part is absent for the constraints after it, in order: a skipped step cannot keep a later field shown",
2050
2079
  async run(createStore) {
2051
2080
  const store = createStore(stepsForm({ hasCompany: false, wantsInvoice: "yes", company: "", vat: "" }));
2052
- expect(await store.validate()).toEqual({ outcome: "passed" });
2053
- expect(await store.checkValidity()).toBe(true);
2081
+ assertEqual(await store.validate(), { outcome: "passed" });
2082
+ assertSame(await store.checkValidity(), true);
2054
2083
  store.setValue("hasCompany", true);
2055
2084
  store.setValue("company", "Acme");
2056
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2057
- expect(Object.keys(errorsOf(store))).toEqual(["vat"]);
2085
+ assertEqual(await store.validate(), { outcome: "invalid" });
2086
+ assertEqual(Object.keys(errorsOf(store)), ["vat"]);
2058
2087
  store.setValue("hasCompany", false);
2059
- expect(errorsOf(store)).toEqual({});
2060
- expect(await store.validate()).toEqual({ outcome: "passed" });
2088
+ assertEqual(errorsOf(store), {});
2089
+ assertEqual(await store.validate(), { outcome: "passed" });
2061
2090
  }
2062
2091
  },
2063
2092
  {
@@ -2065,16 +2094,16 @@ var cases = [
2065
2094
  name: "a path that takes part again is re-validated when it was checked before, and waits for its timing otherwise",
2066
2095
  async run(createStore) {
2067
2096
  const checked = createStore(businessForm({ kind: "business", company: "" }));
2068
- expect(await checked.validate()).toEqual({ outcome: "invalid" });
2097
+ assertEqual(await checked.validate(), { outcome: "invalid" });
2069
2098
  checked.setValue("kind", "person");
2070
- expect(errorsOf(checked)).toEqual({});
2099
+ assertEqual(errorsOf(checked), {});
2071
2100
  checked.setValue("kind", "business");
2072
- await vi.waitFor(() => expect(errorsOf(checked).company?.type).toBe("required"));
2101
+ await waitFor(() => assertSame(errorsOf(checked).company?.type, "required"));
2073
2102
  const untouched = createStore(businessForm());
2074
2103
  untouched.setValue("kind", "business");
2075
2104
  await settle();
2076
- expect(errorsOf(untouched)).toEqual({});
2077
- expect(untouched.getSnapshot().isValid).toBe(true);
2105
+ assertEqual(errorsOf(untouched), {});
2106
+ assertSame(untouched.getSnapshot().isValid, true);
2078
2107
  }
2079
2108
  },
2080
2109
  {
@@ -2103,13 +2132,13 @@ var cases = [
2103
2132
  { locked: "", mode: "view", frozen: "", extra: { note: "" }, later: "" }
2104
2133
  )
2105
2134
  );
2106
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2107
- expect(Object.keys(errorsOf(store))).toEqual(["later"]);
2135
+ assertEqual(await store.validate(), { outcome: "invalid" });
2136
+ assertEqual(Object.keys(errorsOf(store)), ["later"]);
2108
2137
  store.setValue("later", "x");
2109
- expect(await store.validate()).toEqual({ outcome: "passed" });
2138
+ assertEqual(await store.validate(), { outcome: "passed" });
2110
2139
  store.setValue("mode", "edit");
2111
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2112
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual(["extra.note", "frozen"]);
2140
+ assertEqual(await store.validate(), { outcome: "invalid" });
2141
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), ["extra.note", "frozen"]);
2113
2142
  }
2114
2143
  },
2115
2144
  {
@@ -2133,23 +2162,26 @@ var cases = [
2133
2162
  { tag: "AB1234" }
2134
2163
  )
2135
2164
  );
2136
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2165
+ assertEqual(await store.validate(), { outcome: "invalid" });
2137
2166
  const { all } = errorsOf(store).tag;
2138
- expect(all.map(({ type, ruleId }) => [type, ruleId])).toEqual([
2139
- ["pattern", "tag-letters"],
2140
- ["pattern", "tag-short"],
2141
- ["minLength", void 0]
2142
- ]);
2143
- expect(all[0]).toEqual({
2167
+ assertEqual(
2168
+ all.map(({ type, ruleId }) => [type, ruleId]),
2169
+ [
2170
+ ["pattern", "tag-letters"],
2171
+ ["pattern", "tag-short"],
2172
+ ["minLength", void 0]
2173
+ ]
2174
+ );
2175
+ assertEqual(all[0], {
2144
2176
  type: "pattern",
2145
2177
  source: "validation",
2146
2178
  ruleId: "tag-letters",
2147
2179
  params: { pattern: "^[a-z]+$" },
2148
2180
  message: "Letters only"
2149
2181
  });
2150
- expect(all[2].params).toEqual({ minLength: 8 });
2151
- expect(all[2].message).toBeUndefined();
2152
- expect(Object.isFrozen(all[2].params)).toBe(true);
2182
+ assertEqual(all[2].params, { minLength: 8 });
2183
+ assertUndefined(all[2].message);
2184
+ assertSame(Object.isFrozen(all[2].params), true);
2153
2185
  }
2154
2186
  },
2155
2187
  {
@@ -2169,13 +2201,16 @@ var cases = [
2169
2201
  const store = createStore(options);
2170
2202
  gate.hold("ab");
2171
2203
  const run = store.validate();
2172
- await vi.waitFor(() => expect(gate.pending("ab")).toBe(1));
2204
+ await waitFor(() => assertSame(gate.pending("ab"), 1));
2173
2205
  gate.settle("ab", false);
2174
- expect(await run).toEqual({ outcome: "invalid" });
2206
+ assertEqual(await run, { outcome: "invalid" });
2175
2207
  const first = errorsOf(store).slug;
2176
- expect(first.all.map(({ type }) => type)).toEqual(["gate", "minLength"]);
2208
+ assertEqual(
2209
+ first.all.map(({ type }) => type),
2210
+ ["gate", "minLength"]
2211
+ );
2177
2212
  await store.validate();
2178
- expect(errorsOf(store).slug).toBe(first);
2213
+ assertSame(errorsOf(store).slug, first);
2179
2214
  }
2180
2215
  },
2181
2216
  {
@@ -2201,7 +2236,7 @@ var cases = [
2201
2236
  () => void 0,
2202
2237
  (error) => error
2203
2238
  );
2204
- expect(rejected).toMatchObject({
2239
+ assertMatches(rejected, {
2205
2240
  name: "FormValidationFailure",
2206
2241
  path: "secret",
2207
2242
  ruleType: "boom",
@@ -2211,23 +2246,24 @@ var cases = [
2211
2246
  () => void 0,
2212
2247
  (error) => error
2213
2248
  );
2214
- expect(check).toMatchObject({ path: "secret", ruleType: "boom" });
2215
- expect(isValidating(store)).toBe(false);
2216
- const logged = vi.spyOn(logger, "error").mockReturnThis();
2249
+ assertMatches(check, { path: "secret", ruleType: "boom" });
2250
+ assertSame(isValidating(store), false);
2251
+ const logged = spyOn(logger, "error");
2217
2252
  try {
2218
2253
  const automatic = createStore(options);
2219
2254
  automatic.setValue("secret", "x");
2220
2255
  automatic.setValue("secret", "");
2221
- await vi.waitFor(() => expect(errorsOf(automatic).secret).toBeDefined());
2222
- expect(logged).toHaveBeenCalledWith(expect.stringContaining("'secret'"), {
2223
- error: expect.objectContaining({ path: "secret", ruleType: "boom", ruleId: "secret-boom" })
2224
- });
2225
- expect(errorsOf(automatic).secret?.all).toEqual([
2256
+ await waitFor(() => assertDefined(errorsOf(automatic).secret));
2257
+ const report = logged.spy.calls.find(
2258
+ ([message]) => typeof message === "string" && message.includes("'secret'")
2259
+ );
2260
+ assertMatches(report?.[1], { error: { path: "secret", ruleType: "boom", ruleId: "secret-boom" } });
2261
+ assertEqual(errorsOf(automatic).secret?.all, [
2226
2262
  { type: "required", source: "validation", ruleId: "secret-required" }
2227
2263
  ]);
2228
- expect(automatic.getSnapshot().isValid).toBe(false);
2264
+ assertSame(automatic.getSnapshot().isValid, false);
2229
2265
  } finally {
2230
- logged.mockRestore();
2266
+ logged.restore();
2231
2267
  }
2232
2268
  }
2233
2269
  },
@@ -2258,8 +2294,8 @@ var cases = [
2258
2294
  )
2259
2295
  );
2260
2296
  store.setValue("password", "abcde");
2261
- await vi.waitFor(() => expect(store.getSnapshot().warnings.password).toBeDefined());
2262
- expect(store.getSnapshot().warnings.password).toEqual({
2297
+ await waitFor(() => assertDefined(store.getSnapshot().warnings.password));
2298
+ assertEqual(store.getSnapshot().warnings.password, {
2263
2299
  type: "minLength",
2264
2300
  source: "validation",
2265
2301
  ruleId: "password-strength",
@@ -2275,19 +2311,19 @@ var cases = [
2275
2311
  }
2276
2312
  ]
2277
2313
  });
2278
- expect(errorsOf(store)).toEqual({});
2279
- expect(store.getSnapshot().isValid).toBe(true);
2280
- expect(await store.validate()).toEqual({ outcome: "passed" });
2281
- expect(await store.checkValidity()).toBe(true);
2314
+ assertEqual(errorsOf(store), {});
2315
+ assertSame(store.getSnapshot().isValid, true);
2316
+ assertEqual(await store.validate(), { outcome: "passed" });
2317
+ assertSame(await store.checkValidity(), true);
2282
2318
  const field = fieldState(store, "password");
2283
- expect(field).toMatchObject({ invalid: false, error: void 0 });
2284
- expect(fieldState(store, "password").warning).toBe(field.warning);
2319
+ assertMatches(field, { invalid: false, error: void 0 });
2320
+ assertSame(fieldState(store, "password").warning, field.warning);
2285
2321
  store.setValue("password", "abcdefgh");
2286
- await vi.waitFor(() => expect(store.getSnapshot().warnings).toEqual({}));
2322
+ await waitFor(() => assertEqual(store.getSnapshot().warnings, {}));
2287
2323
  store.setValue("password", "a");
2288
- await vi.waitFor(() => expect(errorsOf(store).password?.message).toBe("Too short"));
2289
- expect(store.getSnapshot().warnings.password?.message).toBe("Weak");
2290
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2324
+ await waitFor(() => assertSame(errorsOf(store).password?.message, "Too short"));
2325
+ assertSame(store.getSnapshot().warnings.password?.message, "Weak");
2326
+ assertEqual(await store.validate(), { outcome: "invalid" });
2291
2327
  }
2292
2328
  },
2293
2329
  {
@@ -2308,10 +2344,10 @@ var cases = [
2308
2344
  { kind: "business", company: "" }
2309
2345
  )
2310
2346
  );
2311
- expect(await store.validate()).toEqual({ outcome: "passed" });
2312
- expect(store.getSnapshot().warnings.company?.type).toBe("required");
2347
+ assertEqual(await store.validate(), { outcome: "passed" });
2348
+ assertSame(store.getSnapshot().warnings.company?.type, "required");
2313
2349
  store.setValue("kind", "person");
2314
- expect(store.getSnapshot().warnings).toEqual({});
2350
+ assertEqual(store.getSnapshot().warnings, {});
2315
2351
  }
2316
2352
  },
2317
2353
  {
@@ -2319,8 +2355,8 @@ var cases = [
2319
2355
  name: "an async rule reports the endpoint text on its own channel, never library text, and an outage is a failure to run and is not cached",
2320
2356
  async run(createStore) {
2321
2357
  let reply = () => new Response(JSON.stringify({ valid: false }));
2322
- const fetchSpy = vi.fn(async () => reply());
2323
- vi.stubGlobal("fetch", fetchSpy);
2358
+ const fetchSpy = createSpy(async () => reply());
2359
+ const restoreFetch = stubGlobal("fetch", fetchSpy);
2324
2360
  try {
2325
2361
  const options = custom(
2326
2362
  [
@@ -2340,37 +2376,37 @@ var cases = [
2340
2376
  { handle: "ada" }
2341
2377
  );
2342
2378
  const store = createStore(options);
2343
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2344
- expect(errorsOf(store).handle.all).toEqual([
2379
+ assertEqual(await store.validate(), { outcome: "invalid" });
2380
+ assertEqual(errorsOf(store).handle.all, [
2345
2381
  { type: "async", source: "validation", ruleId: "handle-free" }
2346
2382
  ]);
2347
2383
  reply = () => new Response(JSON.stringify({ valid: false, message: "Handle is taken" }));
2348
2384
  store.setValue("handle", "ada2");
2349
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2350
- expect(errorsOf(store).handle.message).toBe("Handle is taken");
2351
- expect(JSON.stringify(store.getSnapshot())).not.toMatch(/Invalid input|secret|\/check/);
2385
+ assertEqual(await store.validate(), { outcome: "invalid" });
2386
+ assertSame(errorsOf(store).handle.message, "Handle is taken");
2387
+ assertNotMatches(JSON.stringify(store.getSnapshot()), /Invalid input|secret|\/check/);
2352
2388
  reply = () => new Response("no", { status: 503 });
2353
2389
  store.setValue("handle", "ada3");
2354
2390
  const down = await store.validate().then(
2355
2391
  () => void 0,
2356
2392
  (error) => error
2357
2393
  );
2358
- expect(down).toMatchObject({ name: "FormValidationFailure", path: "handle", ruleType: "async" });
2359
- expect(down.cause.name).toBe("ValidationUnavailable");
2360
- const calls = fetchSpy.mock.calls.length;
2394
+ assertMatches(down, { name: "FormValidationFailure", path: "handle", ruleType: "async" });
2395
+ assertSame(down.cause.name, "ValidationUnavailable");
2396
+ const calls = fetchSpy.calls.length;
2361
2397
  reply = () => new Response(JSON.stringify({ valid: true }));
2362
- expect(await store.validate()).toEqual({ outcome: "passed" });
2363
- expect(fetchSpy.mock.calls.length).toBe(calls + 1);
2364
- fetchSpy.mockImplementation(async () => {
2398
+ assertEqual(await store.validate(), { outcome: "passed" });
2399
+ assertSame(fetchSpy.calls.length, calls + 1);
2400
+ fetchSpy.implement(async () => {
2365
2401
  throw new Error("offline");
2366
2402
  });
2367
2403
  const offline = await createStore({ ...options, defaults: { handle: "zed" } }).validate().then(
2368
2404
  () => void 0,
2369
2405
  (error) => error
2370
2406
  );
2371
- expect(offline.cause.name).toBe("ValidationUnavailable");
2407
+ assertSame(offline.cause.name, "ValidationUnavailable");
2372
2408
  } finally {
2373
- vi.unstubAllGlobals();
2409
+ restoreFetch();
2374
2410
  }
2375
2411
  }
2376
2412
  },
@@ -2379,30 +2415,30 @@ var cases = [
2379
2415
  name: "a submission ends passed, invalid, or overtaken",
2380
2416
  async run(createStore) {
2381
2417
  const store = createStore(fixture().options);
2382
- expect((await store.submit()).outcome).toBe("passed");
2418
+ assertSame((await store.submit()).outcome, "passed");
2383
2419
  store.setValue("name", "");
2384
- expect(await store.submit()).toEqual({ outcome: "invalid" });
2420
+ assertEqual(await store.submit(), { outcome: "invalid" });
2385
2421
  const edit = fixture();
2386
2422
  const edited = createStore(edit.options);
2387
2423
  edit.gate.settle("taken", false);
2388
2424
  edit.gate.hold("a", "b");
2389
2425
  edited.setValue("slug", "a");
2390
2426
  const outrun = edited.submit();
2391
- await vi.waitFor(() => expect(edit.gate.pending("a")).toBe(1));
2427
+ await waitFor(() => assertSame(edit.gate.pending("a"), 1));
2392
2428
  edited.setValue("slug", "b");
2393
2429
  edit.gate.settle("a", true);
2394
- await vi.waitFor(() => expect(edit.gate.pending("b")).toBe(1));
2430
+ await waitFor(() => assertSame(edit.gate.pending("b"), 1));
2395
2431
  edited.setValue("slug", "taken");
2396
2432
  edit.gate.settle("b", true);
2397
- expect(await outrun).toEqual({ outcome: "overtaken" });
2433
+ assertEqual(await outrun, { outcome: "overtaken" });
2398
2434
  const hold = fixture();
2399
2435
  const reset = createStore(hold.options);
2400
2436
  hold.gate.hold("free");
2401
2437
  const cleared = reset.submit();
2402
- await vi.waitFor(() => expect(hold.gate.pending("free")).toBe(1));
2438
+ await waitFor(() => assertSame(hold.gate.pending("free"), 1));
2403
2439
  reset.reset();
2404
2440
  hold.gate.settle("free", true);
2405
- expect(await cleared).toEqual({ outcome: "overtaken" });
2441
+ assertEqual(await cleared, { outcome: "overtaken" });
2406
2442
  }
2407
2443
  },
2408
2444
  {
@@ -2411,13 +2447,14 @@ var cases = [
2411
2447
  async run(createStore) {
2412
2448
  const store = createStore(fixture().options);
2413
2449
  const before = store.getSnapshot();
2414
- expect(() => store.reportNative({ name: { type: "valueMissing" }, __x: { type: "valueMissing" } })).toThrow(
2450
+ assertThrows(
2451
+ () => store.reportNative({ name: { type: "valueMissing" }, __x: { type: "valueMissing" } }),
2415
2452
  /reserved/
2416
2453
  );
2417
- expect(() => store.reportNative({ "a.constructor": null })).toThrow(/'constructor'/);
2418
- expect(await store.checkValidity()).toBe(true);
2419
- expect(store.getSnapshot()).toBe(before);
2420
- expect(() => store.setValue("prototype.x", 1)).toThrow(/__.*constructor.*prototype/s);
2454
+ assertThrows(() => store.reportNative({ "a.constructor": null }), /'constructor'/);
2455
+ assertSame(await store.checkValidity(), true);
2456
+ assertSame(store.getSnapshot(), before);
2457
+ assertThrows(() => store.setValue("prototype.x", 1), /__.*constructor.*prototype/s);
2421
2458
  }
2422
2459
  },
2423
2460
  {
@@ -2426,18 +2463,24 @@ var cases = [
2426
2463
  async run(createStore) {
2427
2464
  const store = createStore(fixture({ validationMode: "onChange" }).options);
2428
2465
  store.setValue("nickname", "");
2429
- expect(store.getSnapshot().validating.nickname).toBe(true);
2466
+ assertSame(store.getSnapshot().validating.nickname, true);
2430
2467
  store.reportNative({ nickname: { type: "valueMissing" } });
2431
- await vi.waitFor(
2432
- () => expect(errorsOf(store).nickname?.all.map(({ source }) => source)).toEqual(["validation", "native"])
2468
+ await waitFor(
2469
+ () => assertEqual(
2470
+ errorsOf(store).nickname?.all.map(({ source }) => source),
2471
+ ["validation", "native"]
2472
+ )
2433
2473
  );
2434
- expect(isValidating(store)).toBe(false);
2474
+ assertSame(isValidating(store), false);
2435
2475
  const touched = createStore(fixture({ validationMode: "onTouched" }).options);
2436
2476
  touched.blur("name");
2437
2477
  touched.setValue("name", "");
2438
2478
  touched.reportNative({ name: { type: "valueMissing" } });
2439
- await vi.waitFor(
2440
- () => expect(errorsOf(touched).name?.all.map(({ source }) => source)).toEqual(["validation", "native"])
2479
+ await waitFor(
2480
+ () => assertEqual(
2481
+ errorsOf(touched).name?.all.map(({ source }) => source),
2482
+ ["validation", "native"]
2483
+ )
2441
2484
  );
2442
2485
  }
2443
2486
  },
@@ -2448,17 +2491,17 @@ var cases = [
2448
2491
  const store = createStore(fixture().options);
2449
2492
  const first = store.submit();
2450
2493
  const second = store.submit();
2451
- expect(await first).toEqual({ outcome: "overtaken" });
2452
- expect((await second).outcome).toBe("passed");
2494
+ assertEqual(await first, { outcome: "overtaken" });
2495
+ assertSame((await second).outcome, "passed");
2453
2496
  }
2454
2497
  },
2455
2498
  {
2456
2499
  rule: "validator failures",
2457
2500
  name: "a failure says why a rule did not run: the service was unavailable, or the rule threw",
2458
2501
  async run(createStore) {
2459
- vi.stubGlobal(
2502
+ const restoreFetch = stubGlobal(
2460
2503
  "fetch",
2461
- vi.fn(async () => new Response("no", { status: 500 }))
2504
+ createSpy(async () => new Response("no", { status: 500 }))
2462
2505
  );
2463
2506
  try {
2464
2507
  const unavailable = createStore(
@@ -2477,7 +2520,7 @@ var cases = [
2477
2520
  () => void 0,
2478
2521
  (error) => error
2479
2522
  );
2480
- expect(down).toMatchObject({ path: "handle", ruleType: "async", reason: "unavailable" });
2523
+ assertMatches(down, { path: "handle", ruleType: "async", reason: "unavailable" });
2481
2524
  const threw = createStore(
2482
2525
  custom([{ $type: "input", name: "secret", rules: [{ $type: "boom" }] }], { secret: "" })
2483
2526
  );
@@ -2485,9 +2528,9 @@ var cases = [
2485
2528
  () => void 0,
2486
2529
  (error) => error
2487
2530
  );
2488
- expect(exploded).toMatchObject({ path: "secret", ruleType: "boom", reason: "error" });
2531
+ assertMatches(exploded, { path: "secret", ruleType: "boom", reason: "error" });
2489
2532
  } finally {
2490
- vi.unstubAllGlobals();
2533
+ restoreFetch();
2491
2534
  }
2492
2535
  }
2493
2536
  },
@@ -2531,19 +2574,19 @@ var cases = [
2531
2574
  );
2532
2575
  const store = createStore(options);
2533
2576
  const submitted = await passedSubmission(store);
2534
- expect(submitted.values).toEqual({
2577
+ assertEqual(submitted.values, {
2535
2578
  kind: "person",
2536
2579
  rows: [{ role: "office" }, { role: "home", fax: "2" }],
2537
2580
  tenant: "t1",
2538
2581
  context: { source: "email" }
2539
2582
  });
2540
- expect(Object.isFrozen(submitted.values)).toBe(true);
2541
- expect(store.getSnapshot().values).not.toHaveProperty("tenant");
2542
- expect(store.getSnapshot().dirty).toEqual({});
2583
+ assertSame(Object.isFrozen(submitted.values), true);
2584
+ assertNoProperty(store.getSnapshot().values, "tenant");
2585
+ assertEqual(store.getSnapshot().dirty, {});
2543
2586
  store.setValue("kind", "business");
2544
2587
  const next = await passedSubmission(store);
2545
- expect(next.values).toMatchObject({ company: "Acme", tenant: "t1" });
2546
- expect(next.values).not.toHaveProperty("locked");
2588
+ assertMatches(next.values, { company: "Acme", tenant: "t1" });
2589
+ assertNoProperty(next.values, "locked");
2547
2590
  }
2548
2591
  },
2549
2592
  {
@@ -2551,19 +2594,19 @@ var cases = [
2551
2594
  name: "blur marks the path touched in one notification and validates by mode; written first, the value ends as one command would leave it",
2552
2595
  async run(createStore) {
2553
2596
  const quiet = createStore(fixture().options);
2554
- const listener = vi.fn();
2597
+ const listener = createSpy();
2555
2598
  quiet.subscribe(listener);
2556
2599
  quiet.blur("name");
2557
- expect(listener).toHaveBeenCalledTimes(1);
2558
- expect(quiet.getSnapshot().touched).toEqual({ name: true });
2559
- expect(quiet.getValue("name")).toBe("Ada");
2560
- expect(quiet.getSnapshot().dirty).toEqual({});
2600
+ assertCallCount(listener, 1);
2601
+ assertEqual(quiet.getSnapshot().touched, { name: true });
2602
+ assertSame(quiet.getValue("name"), "Ada");
2603
+ assertEqual(quiet.getSnapshot().dirty, {});
2561
2604
  const store = createStore(fixture({ validationMode: "onBlur" }).options);
2562
2605
  store.setValue("name", "");
2563
2606
  store.blur("name");
2564
- await vi.waitFor(() => expect(errorsOf(store).name?.type).toBe("required"));
2565
- expect(store.getSnapshot().dirty.name).toBe(true);
2566
- expect(store.getSnapshot().touched.name).toBe(true);
2607
+ await waitFor(() => assertSame(errorsOf(store).name?.type, "required"));
2608
+ assertSame(store.getSnapshot().dirty.name, true);
2609
+ assertSame(store.getSnapshot().touched.name, true);
2567
2610
  }
2568
2611
  },
2569
2612
  {
@@ -2572,19 +2615,23 @@ var cases = [
2572
2615
  run(createStore) {
2573
2616
  const store = createStore(fixture().options);
2574
2617
  const before = store.getSnapshot();
2575
- expect(() => store.setValue("contacts.3.email", "x")).toThrow(
2618
+ assertThrows(
2619
+ () => store.setValue("contacts.3.email", "x"),
2576
2620
  /'contacts.3.email' names row '3' of 'contacts'/
2577
2621
  );
2578
- expect(() => store.setValue("contacts.-1.email", "x")).toThrow(/names row '-1'/);
2579
- expect(() => store.blur("contacts.5.email")).toThrow(/names row '5'/);
2580
- expect(() => store.setValue("name.3.x", "x")).toThrow(/names row '3' of 'name'/);
2581
- expect(() => store.setValue("name.03.x", "x")).toThrow(/names row '03' of 'name'/);
2582
- expect(() => store.setValue("__secret", 1)).toThrow(/reserved segment/);
2583
- expect(store.getSnapshot()).toBe(before);
2622
+ assertThrows(() => store.setValue("contacts.-1.email", "x"), /names row '-1'/);
2623
+ assertThrows(() => store.blur("contacts.5.email"), /names row '5'/);
2624
+ assertThrows(() => store.setValue("name.3.x", "x"), /names row '3' of 'name'/);
2625
+ assertThrows(() => store.setValue("name.03.x", "x"), /names row '03' of 'name'/);
2626
+ assertThrows(() => store.setValue("__secret", 1), /reserved segment/);
2627
+ assertSame(store.getSnapshot(), before);
2584
2628
  store.fieldArray("contacts").append({ email: "d@example.com" });
2585
2629
  store.setValue("contacts.3.email", "e@example.com");
2586
- expect(store.getSnapshot().rowIds.contacts).toHaveLength(4);
2587
- expect(store.getSnapshot().rowIds.contacts.every((id) => typeof id === "string")).toBe(true);
2630
+ assertLength(store.getSnapshot().rowIds.contacts, 4);
2631
+ assertSame(
2632
+ store.getSnapshot().rowIds.contacts.every((id) => typeof id === "string"),
2633
+ true
2634
+ );
2588
2635
  }
2589
2636
  },
2590
2637
  {
@@ -2597,13 +2644,13 @@ var cases = [
2597
2644
  store.setValue("name", "x");
2598
2645
  store.setValue("name", "");
2599
2646
  await settle();
2600
- expect(watch.started).toBe(false);
2647
+ assertSame(watch.started, false);
2601
2648
  store.blur("name");
2602
- await vi.waitFor(() => expect(errorsOf(store).name?.type).toBe("required"));
2649
+ await waitFor(() => assertSame(errorsOf(store).name?.type, "required"));
2603
2650
  store.setValue("name", "Ada");
2604
- await vi.waitFor(() => expect(errorsOf(store).name).toBeUndefined());
2651
+ await waitFor(() => assertUndefined(errorsOf(store).name));
2605
2652
  store.setValue("name", "");
2606
- await vi.waitFor(() => expect(errorsOf(store).name?.type).toBe("required"));
2653
+ await waitFor(() => assertSame(errorsOf(store).name?.type, "required"));
2607
2654
  }
2608
2655
  },
2609
2656
  {
@@ -2646,15 +2693,18 @@ var cases = [
2646
2693
  { tag: "abc", other: "z", count: 3, rows: [{ x: "" }] }
2647
2694
  )
2648
2695
  );
2649
- expect(await store.validate()).toEqual({ outcome: "invalid" });
2696
+ assertEqual(await store.validate(), { outcome: "invalid" });
2650
2697
  const errors = errorsOf(store);
2651
- expect(errors.tag.all).toEqual([
2698
+ assertEqual(errors.tag.all, [
2652
2699
  { type: "maxLength", source: "validation", params: { maxLength: 2 } },
2653
2700
  { type: "relate", source: "validation", ruleId: "same", params: { assert: "allEqual" } }
2654
2701
  ]);
2655
- expect(errors.count.all.map(({ params }) => params)).toEqual([{ min: 5 }, { max: 1 }]);
2656
- expect(errors.rows.params).toEqual({ minItems: 2 });
2657
- expect(JSON.stringify(errors)).not.toMatch(/Too (small|big)|Invalid input/);
2702
+ assertEqual(
2703
+ errors.count.all.map(({ params }) => params),
2704
+ [{ min: 5 }, { max: 1 }]
2705
+ );
2706
+ assertEqual(errors.rows.params, { minItems: 2 });
2707
+ assertNotMatches(JSON.stringify(errors), /Too (small|big)|Invalid input/);
2658
2708
  }
2659
2709
  },
2660
2710
  {
@@ -2669,12 +2719,12 @@ var cases = [
2669
2719
  "address.nowhere": { type: "valueMissing" },
2670
2720
  "contacts.0.nothing": { type: "valueMissing" }
2671
2721
  });
2672
- expect(await store.validate()).toEqual({ outcome: "passed" });
2673
- expect(await store.checkValidity()).toBe(true);
2674
- expect(errorsOf(store)).toEqual({});
2675
- expect(store.getSnapshot().isValid).toBe(true);
2676
- expect((await store.submit()).outcome).toBe("passed");
2677
- expect(before.errors).toEqual({});
2722
+ assertEqual(await store.validate(), { outcome: "passed" });
2723
+ assertSame(await store.checkValidity(), true);
2724
+ assertEqual(errorsOf(store), {});
2725
+ assertSame(store.getSnapshot().isValid, true);
2726
+ assertSame((await store.submit()).outcome, "passed");
2727
+ assertEqual(before.errors, {});
2678
2728
  }
2679
2729
  },
2680
2730
  {
@@ -2690,8 +2740,8 @@ var cases = [
2690
2740
  name: { type: "taken" },
2691
2741
  "contacts.1": { type: "row_error" }
2692
2742
  });
2693
- expect(Object.keys(errorsOf(store)).toSorted()).toEqual([FORM_ROOT, "contacts.1", "name"]);
2694
- expect(errorsOf(store)[FORM_ROOT].all).toEqual([
2743
+ assertEqual(Object.keys(errorsOf(store)).toSorted(), [FORM_ROOT, "contacts.1", "name"]);
2744
+ assertEqual(errorsOf(store)[FORM_ROOT].all, [
2695
2745
  { type: "server", source: "server", message: "Try later" },
2696
2746
  {
2697
2747
  type: "unknown_field",
@@ -2703,18 +2753,18 @@ var cases = [
2703
2753
  ]);
2704
2754
  const alone = await passedSubmission(store);
2705
2755
  alone.setServerErrors({ ghost: { type: "unknown_field" } });
2706
- expect(Object.keys(errorsOf(store))).toEqual([FORM_ROOT]);
2707
- expect(errorsOf(store)[FORM_ROOT].type).toBe("unknown_field");
2756
+ assertEqual(Object.keys(errorsOf(store)), [FORM_ROOT]);
2757
+ assertSame(errorsOf(store)[FORM_ROOT].type, "unknown_field");
2708
2758
  }
2709
2759
  }
2710
2760
  ];
2711
2761
  var formStateContainerCases = cases;
2712
- function formStateContainerConformance(createStore) {
2713
- describe("form state container conformance", () => {
2762
+ function formStateContainerConformance(createStore, runner) {
2763
+ runner.describe("form state container conformance", () => {
2714
2764
  for (const rule of new Set(cases.map((entry) => entry.rule))) {
2715
- describe(rule, () => {
2765
+ runner.describe(rule, () => {
2716
2766
  for (const entry of cases.filter((candidate) => candidate.rule === rule)) {
2717
- test(entry.name, () => entry.run(createStore));
2767
+ runner.test(entry.name, () => entry.run(createStore));
2718
2768
  }
2719
2769
  });
2720
2770
  }