-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Custom JSON encoder for List and Map doesn't work correctly in `…
…full` mode (#789)
- Loading branch information
1 parent
14be107
commit 7fb7ce6
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:parse_server_sdk/parse_server_sdk.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test( | ||
'should return expectedResult json when json has Nested map and list data.', | ||
() async { | ||
// arrange | ||
await Parse().initialize( | ||
'appId', | ||
'https://test.parse.com', | ||
debug: true, | ||
// to prevent automatic detection | ||
fileDirectory: 'someDirectory', | ||
// to prevent automatic detection | ||
appName: 'appName', | ||
// to prevent automatic detection | ||
appPackageName: 'somePackageName', | ||
// to prevent automatic detection | ||
appVersion: 'someAppVersion', | ||
); | ||
|
||
ParseObject parseObject2 = ParseObject("objectId2"); | ||
parseObject2.objectId = "objectId2"; | ||
|
||
// List and Map | ||
parseObject2 | ||
.setAdd("dataParseObjectList", ["ListText1", "ListText2", "ListText3"]); | ||
parseObject2.setAdd("dataParseObjectMap", { | ||
'KeyTestMap1': 'ValueTestMap1', | ||
'KeyTestMap2': 'ValueTestMap2', | ||
'KeyTestMap3': 'ValueTestMap3', | ||
}); | ||
|
||
// parseObject2 inside parseObject1 | ||
ParseObject parseObject1 = ParseObject("parseObject1"); | ||
parseObject1.objectId = "objectId1"; | ||
parseObject1.setAdd("dataParseObject2", parseObject2); | ||
|
||
// desired output | ||
String expectedResult = | ||
"{className: parseObject1, objectId: objectId1, dataParseObject2: {__op: Add, objects: [{className: objectId2, objectId: objectId2, dataParseObjectList: {__op: Add, objects: [[ListText1, ListText2, ListText3]]}, dataParseObjectMap: {__op: Add, objects: [{KeyTestMap1: ValueTestMap1, KeyTestMap2: ValueTestMap2, KeyTestMap3: ValueTestMap3}]}}]}}"; | ||
|
||
// act | ||
dynamic actualResult = parseEncode(parseObject1, full: true); | ||
|
||
//assert | ||
expect(actualResult.toString(), expectedResult); | ||
}); | ||
} |