-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
. d updated README.md file: added snippets for example with model
- Loading branch information
1 parent
252dacc
commit 2d67c73
Showing
4 changed files
with
51 additions
and
70 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
12 changes: 6 additions & 6 deletions
12
example/verify_methods/verify_as_json/verify_as_json_test.approved.txt
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
{ | ||
"item": { | ||
"jsonItem": { | ||
"id": 1, | ||
"name": "Widget", | ||
"name": "JsonItem", | ||
"subItem": { | ||
"id": 1, | ||
"name": "SubWidget", | ||
"name": "SubItem", | ||
"anotherItems": [ | ||
{ | ||
"id": 1, | ||
"name": "AnotherWidget1" | ||
"name": "AnotherItem 1" | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "AnotherWidget2" | ||
"name": "AnotherItem 2" | ||
} | ||
] | ||
}, | ||
"anotherItem": { | ||
"id": 1, | ||
"name": "AnotherWidget" | ||
"name": "AnotherItem" | ||
} | ||
} | ||
} |
25 changes: 22 additions & 3 deletions
25
example/verify_methods/verify_as_json/verify_as_json_test.dart
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 |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import 'package:approval_tests/approval_tests.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../test/approval_test.dart'; | ||
import '../../../test/models/item.dart'; | ||
|
||
// begin-snippet: same_verify_as_json_test_with_model | ||
void main() { | ||
const jsonItem = JsonItem( | ||
id: 1, | ||
name: "JsonItem", | ||
anotherItem: AnotherItem(id: 1, name: "AnotherItem"), | ||
subItem: SubItem( | ||
id: 1, | ||
name: "SubItem", | ||
anotherItems: [ | ||
AnotherItem(id: 1, name: "AnotherItem 1"), | ||
AnotherItem(id: 2, name: "AnotherItem 2"), | ||
], | ||
), | ||
); | ||
|
||
test('Verify JSON output of an object', () { | ||
Approvals.verifyAsJson( | ||
ApprovalTestHelper.jsonItem, | ||
options: const Options(deleteReceivedFile: true), | ||
jsonItem, | ||
options: const Options( | ||
deleteReceivedFile: true, // Automatically delete the received file after the test. | ||
approveResult: true, // Approve the result automatically. You can remove this property after the approved file is created. | ||
), | ||
); | ||
}); | ||
} | ||
// end-snippet |