Skip to content

Commit cb0acea

Browse files
fix: update acceptMutations tests to use encoded storage keys
Tests were expecting unencoded keys (e.g., 'tx-1') but the new type-safe encoding stores string keys with the 's:' prefix (e.g., 's:tx-1'). Updated 6 test cases to access parsed storage with correct encoded keys. Co-authored-by: Kevin <kevin-dp@users.noreply.github.com>
1 parent 3ef7559 commit cb0acea

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/db/tests/local-storage.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,8 @@ describe(`localStorage collection`, () => {
869869
const storedData = mockStorage.getItem(`todos`)
870870
expect(storedData).toBeDefined()
871871
const parsed = JSON.parse(storedData!)
872-
expect(parsed[`tx-1`].data.title).toBe(`Manual Tx Insert`)
873-
expect(parsed[`tx-2`].data.title).toBe(`Manual Tx Insert 2`)
872+
expect(parsed[`s:tx-1`].data.title).toBe(`Manual Tx Insert`)
873+
expect(parsed[`s:tx-2`].data.title).toBe(`Manual Tx Insert 2`)
874874

875875
subscription.unsubscribe()
876876
})
@@ -927,7 +927,7 @@ describe(`localStorage collection`, () => {
927927
const stored1 = mockStorage.getItem(`todos-1`)
928928
expect(stored1).toBeDefined()
929929
const parsed1 = JSON.parse(stored1!)
930-
expect(parsed1[`c1-item`].data.title).toBe(`Collection 1`)
930+
expect(parsed1[`s:c1-item`].data.title).toBe(`Collection 1`)
931931

932932
// Second collection mutations should NOT be in storage (remains optimistic)
933933
const stored2 = mockStorage.getItem(`todos-2`)
@@ -988,9 +988,9 @@ describe(`localStorage collection`, () => {
988988
const parsed = JSON.parse(storedData!)
989989

990990
// Updated item should be in storage with new title
991-
expect(parsed[`existing`].data.title).toBe(`Updated Item`)
991+
expect(parsed[`s:existing`].data.title).toBe(`Updated Item`)
992992
// Deleted item should not be in storage
993-
expect(parsed[`new`]).toBeUndefined()
993+
expect(parsed[`s:new`]).toBeUndefined()
994994

995995
subscription.unsubscribe()
996996
})
@@ -1035,7 +1035,7 @@ describe(`localStorage collection`, () => {
10351035
const storedData = mockStorage.getItem(`todos`)
10361036
expect(storedData).toBeDefined()
10371037
const parsed = JSON.parse(storedData!)
1038-
expect(parsed[`to-delete`]).toBeUndefined()
1038+
expect(parsed[`s:to-delete`]).toBeUndefined()
10391039

10401040
// Collection should also not have the item
10411041
expect(collection.has(`to-delete`)).toBe(false)
@@ -1137,7 +1137,7 @@ describe(`localStorage collection`, () => {
11371137
const storedData = mockStorage.getItem(`todos`)
11381138
expect(storedData).toBeDefined()
11391139
const parsed = JSON.parse(storedData!)
1140-
expect(parsed[`after-api`].data.title).toBe(`After API`)
1140+
expect(parsed[`s:after-api`].data.title).toBe(`After API`)
11411141

11421142
subscription.unsubscribe()
11431143
})
@@ -1437,7 +1437,7 @@ describe(`localStorage collection`, () => {
14371437
const storedData = mockStorage.getItem(`todos`)
14381438
expect(storedData).toBeDefined()
14391439
const parsed = JSON.parse(storedData!)
1440-
expect(parsed[`early`].data.title).toBe(`Early Mutation`)
1440+
expect(parsed[`s:early`].data.title).toBe(`Early Mutation`)
14411441

14421442
subscription.unsubscribe()
14431443
})
@@ -1499,9 +1499,9 @@ describe(`localStorage collection`, () => {
14991499
const storedData = mockStorage.getItem(`todos`)
15001500
const parsed = JSON.parse(storedData!)
15011501

1502-
expect(parsed[`auto1`].data.title).toBe(`Auto 1 Updated`)
1503-
expect(parsed[`manual1`].data.title).toBe(`Manual 1`)
1504-
expect(parsed[`auto2`].data.title).toBe(`Auto 2`)
1502+
expect(parsed[`s:auto1`].data.title).toBe(`Auto 1 Updated`)
1503+
expect(parsed[`s:manual1`].data.title).toBe(`Manual 1`)
1504+
expect(parsed[`s:auto2`].data.title).toBe(`Auto 2`)
15051505

15061506
subscription.unsubscribe()
15071507
})

0 commit comments

Comments
 (0)