jazz-vue 0.11.7 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,30 @@
2
2
 
3
3
  import { Account, CoMap, co } from "jazz-tools";
4
4
  import { describe, expect, it } from "vitest";
5
- import { createUseAccountComposables, useAccount } from "../composables.js";
5
+ import { useAccount } from "../composables.js";
6
6
  import { createJazzTestAccount } from "../testing.js";
7
7
  import { withJazzTestSetup } from "./testUtils.js";
8
8
 
9
+ class AccountRoot extends CoMap {
10
+ value = co.string;
11
+ }
12
+
13
+ class AccountSchema extends Account {
14
+ root = co.ref(AccountRoot);
15
+
16
+ migrate() {
17
+ if (!this._refs.root) {
18
+ this.root = AccountRoot.create({ value: "123" }, { owner: this });
19
+ }
20
+ }
21
+ }
22
+
23
+ declare module "../provider" {
24
+ interface Register {
25
+ Account: AccountSchema;
26
+ }
27
+ }
28
+
9
29
  describe("useAccount", () => {
10
30
  it("should return the correct value", async () => {
11
31
  const account = await createJazzTestAccount();
@@ -18,28 +38,14 @@ describe("useAccount", () => {
18
38
  });
19
39
 
20
40
  it("should load nested values if requested", async () => {
21
- class AccountRoot extends CoMap {
22
- value = co.string;
23
- }
24
-
25
- class AccountSchema extends Account {
26
- root = co.ref(AccountRoot);
27
-
28
- migrate() {
29
- if (!this._refs.root) {
30
- this.root = AccountRoot.create({ value: "123" }, { owner: this });
31
- }
32
- }
33
- }
34
-
35
- const { useAccount } = createUseAccountComposables<AccountSchema>();
36
-
37
41
  const account = await createJazzTestAccount({ AccountSchema });
38
42
 
39
43
  const [result] = withJazzTestSetup(
40
44
  () =>
41
45
  useAccount({
42
- root: {},
46
+ resolve: {
47
+ root: true,
48
+ },
43
49
  }),
44
50
  {
45
51
  account,
@@ -2,10 +2,7 @@
2
2
 
3
3
  import { Account, CoMap, co } from "jazz-tools";
4
4
  import { describe, expect, it } from "vitest";
5
- import {
6
- createUseAccountComposables,
7
- useAccountOrGuest,
8
- } from "../composables.js";
5
+ import { useAccountOrGuest } from "../composables.js";
9
6
  import { createJazzTestAccount, createJazzTestGuest } from "../testing.js";
10
7
  import { withJazzTestSetup } from "./testUtils.js";
11
8
 
@@ -46,12 +43,13 @@ describe("useAccountOrGuest", () => {
46
43
  }
47
44
 
48
45
  const account = await createJazzTestAccount({ AccountSchema });
49
- const { useAccountOrGuest } = createUseAccountComposables<AccountSchema>();
50
46
 
51
47
  const [result] = withJazzTestSetup(
52
48
  () =>
53
49
  useAccountOrGuest({
54
- root: {},
50
+ resolve: {
51
+ root: true,
52
+ },
55
53
  }),
56
54
  {
57
55
  account,
@@ -68,7 +66,9 @@ describe("useAccountOrGuest", () => {
68
66
  const [result] = withJazzTestSetup(
69
67
  () =>
70
68
  useAccountOrGuest({
71
- root: {},
69
+ resolve: {
70
+ root: true,
71
+ },
72
72
  }),
73
73
  {
74
74
  account,
@@ -91,7 +91,9 @@ describe("useCoState", () => {
91
91
  const [result] = withJazzTestSetup(
92
92
  () =>
93
93
  useCoState(TestMap, map.id, {
94
- nested: {},
94
+ resolve: {
95
+ nested: true,
96
+ },
95
97
  }),
96
98
  {
97
99
  account,
@@ -165,7 +167,9 @@ describe("useCoState", () => {
165
167
  });
166
168
 
167
169
  const [result] = withJazzTestSetup(() =>
168
- useCoState(TestMap, map.id as ID<CoValue>, []),
170
+ useCoState(TestMap, map.id as ID<CoValue>, {
171
+ resolve: true,
172
+ }),
169
173
  );
170
174
  expectTypeOf(result).toEqualTypeOf<
171
175
  Ref<TestMap | null | undefined, TestMap | null | undefined>