TestStep.fromJson constructor
TestStep.fromJson(
- Map<String, dynamic> json
)
Implementation
factory TestStep.fromJson(Map<String, dynamic> json) {
final entries = json.entries
.where((entry) => entry.key != 'steps')
.toList(growable: false);
if (entries.length != 1) {
throw const FormatException('Serialized TestStep must contain one step.');
}
final entry = entries.single;
final rawArgs = entry.value;
return TestStep(
type: entry.key,
args: rawArgs is Map
? Map<String, dynamic>.from(rawArgs)
: <String, dynamic>{'value': rawArgs},
nestedSteps: (json['steps'] as List<dynamic>? ?? const [])
.whereType<Map>()
.map((value) => TestStep.fromJson(Map<String, dynamic>.from(value)))
.toList(),
);
}