Skip to content

Commit

Permalink
. r toJson methods to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed Jun 30, 2024
1 parent 7465aa1 commit 4cea675
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/approval_tests/test/models/item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class JsonItem {
required this.subItem,
required this.anotherItem,
});

Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'subItem': subItem.toJson(),
'anotherItem': anotherItem.toJson(),
};
}

/// Sub item class for testing
Expand All @@ -24,6 +31,12 @@ class SubItem {
required this.name,
required this.anotherItems,
});

Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'anotherItems': anotherItems.map((e) => e.toJson()).toList(),
};
}

/// Another item class for testing
Expand All @@ -32,4 +45,9 @@ class AnotherItem {
final String name;

const AnotherItem({required this.id, required this.name});

Map<String, dynamic> toJson() => {
'id': id,
'name': name,
};
}

0 comments on commit 4cea675

Please sign in to comment.