createDataModelBodyTest method
void
createDataModelBodyTest()
Implementation
void createDataModelBodyTest(
String pathTestPage,
String featureName,
String pageName,
String apiName,
dynamic jsonBody,
String bodyVariable,
bool isBodyList,
) {
final path = join(pathTestPage, 'data', 'models', 'body');
DirectoryHelper.createDir(path);
join(path, '${apiName.snakeCase}_body_test.dart').write(
'''// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'package:core/core.dart';
import 'package:dev_dependency_manager/dev_dependency_manager.dart';
import 'package:$featureName/$pageName/data/models/body/${apiName.snakeCase}_body.dart' as body_${apiName.snakeCase};
Future<void> main() async {
initializeDateFormatting();
test('Test body convert to map', () {
${getConstOrFinalValue(bodyVariable)} body${apiName.pascalCase} = $bodyVariable
final map = ${isBodyList ? 'body${apiName.pascalCase}.map((e) => e.toMap()).toList()' : 'body${apiName.pascalCase}.toMap()'};
expect(map, ${getChangeDateTimeFromMapJsonBody(jsonBody)});
});
}''');
StatusHelper.generated(join(path, '${pageName}_body_test.dart'));
}