Skip to content

Commit 4f19312

Browse files
Fix initialValue JSON expectations in ObjectCreationHelpersTests
Update test expectations to match the unwrapped initialValue format from 95bf7c6. The initialValue JSON string should contain the CounterCreate/MapCreate object directly (e.g. {"count": 10.5}), not wrapped in a type key (e.g. {"counterCreate": {"count": 10.5}}). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cd7c289 commit 4f19312

File tree

1 file changed

+44
-48
lines changed

1 file changed

+44
-48
lines changed

Tests/AblyLiveObjectsTests/ObjectCreationHelpersTests.swift

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -60,59 +60,57 @@ struct ObjectCreationHelpersTests {
6060
#expect(creationOperation.operation.mapCreate?.semantics == .known(creationOperation.semantics))
6161
#expect(creationOperation.objectMessage.operation?.mapCreateWithObjectId != nil)
6262

63-
// Check that the initial value JSON is correctly populated on the mapCreateWithObjectId.initialValue property per RTO11f12, using the RTO11f4 partial ObjectOperation and correctly encoded per RTO13
63+
// Check that the initial value JSON is correctly populated on the mapCreateWithObjectId.initialValue property per RTO11f15, using the RTO11f4 partial ObjectOperation and correctly encoded per RTO13. Per RTO11f15, the initialValue is a JSON string of the MapCreate object itself (not wrapped in a type key).
6464
let initialValueString = try #require(creationOperation.objectMessage.operation?.mapCreateWithObjectId?.initialValue)
6565
let deserializedInitialValue = try #require(try JSONObjectOrArray(jsonString: initialValueString).objectValue)
6666
#expect(deserializedInitialValue == [
67-
"mapCreate": [
68-
// RTO11f4a
69-
"semantics": .number(Double(ObjectsMapSemantics.lww.rawValue)),
70-
"entries": [
71-
// RTO11f4c1a
72-
"mapRef": [
73-
"data": [
74-
"objectId": "referencedMapID",
75-
],
67+
// RTO11f4a
68+
"semantics": .number(Double(ObjectsMapSemantics.lww.rawValue)),
69+
"entries": [
70+
// RTO11f4c1a
71+
"mapRef": [
72+
"data": [
73+
"objectId": "referencedMapID",
7674
],
77-
"counterRef": [
78-
"data": [
79-
"objectId": "referencedCounterID",
80-
],
75+
],
76+
"counterRef": [
77+
"data": [
78+
"objectId": "referencedCounterID",
8179
],
82-
// RTO11f4c1b
83-
"jsonArrayKey": [
84-
"data": [
85-
"json": #"["arrayItem1","arrayItem2"]"#,
86-
],
80+
],
81+
// RTO11f4c1b
82+
"jsonArrayKey": [
83+
"data": [
84+
"json": #"["arrayItem1","arrayItem2"]"#,
8785
],
88-
"jsonObjectKey": [
89-
"data": [
90-
"json": #"{"nestedKey":"nestedValue"}"#,
91-
],
86+
],
87+
"jsonObjectKey": [
88+
"data": [
89+
"json": #"{"nestedKey":"nestedValue"}"#,
9290
],
93-
// RTO11f4c1c
94-
"stringKey": [
95-
"data": [
96-
"string": "stringValue",
97-
],
91+
],
92+
// RTO11f4c1c
93+
"stringKey": [
94+
"data": [
95+
"string": "stringValue",
9896
],
99-
// RTO11f4c1d
100-
"numberKey": [
101-
"data": [
102-
"number": 42.5,
103-
],
97+
],
98+
// RTO11f4c1d
99+
"numberKey": [
100+
"data": [
101+
"number": 42.5,
104102
],
105-
// RTO11f4c1e
106-
"booleanKey": [
107-
"data": [
108-
"boolean": true,
109-
],
103+
],
104+
// RTO11f4c1e
105+
"booleanKey": [
106+
"data": [
107+
"boolean": true,
110108
],
111-
// RTO11f4c1f
112-
"dataKey": [
113-
"data": [
114-
"bytes": .string(Data([0x01, 0x02, 0x03]).base64EncodedString()),
115-
],
109+
],
110+
// RTO11f4c1f
111+
"dataKey": [
112+
"data": [
113+
"bytes": .string(Data([0x01, 0x02, 0x03]).base64EncodedString()),
116114
],
117115
],
118116
],
@@ -171,14 +169,12 @@ struct ObjectCreationHelpersTests {
171169
#expect(creationOperation.operation.counterCreate != nil)
172170
#expect(creationOperation.objectMessage.operation?.counterCreateWithObjectId != nil)
173171

174-
// Check that the initial value JSON is correctly populated on the counterCreateWithObjectId.initialValue property per RTO12f10, using the RTO12f2 partial ObjectOperation and correctly encoded per RTO13
172+
// Check that the initial value JSON is correctly populated on the counterCreateWithObjectId.initialValue property per RTO12f13, using the RTO12f2 partial ObjectOperation and correctly encoded per RTO13. Per RTO12f13, the initialValue is a JSON string of the CounterCreate object itself (not wrapped in a type key).
175173
let initialValueString = try #require(creationOperation.objectMessage.operation?.counterCreateWithObjectId?.initialValue)
176174
let deserializedInitialValue = try #require(try JSONObjectOrArray(jsonString: initialValueString).objectValue)
177175
#expect(deserializedInitialValue == [
178-
"counterCreate": [
179-
// RTO12f2a
180-
"count": 10.5,
181-
],
176+
// RTO12f2a
177+
"count": 10.5,
182178
])
183179

184180
// Check that the local merge operation has the counterCreate properties

0 commit comments

Comments
 (0)