createDataModelBodyTest method

void createDataModelBodyTest(
  1. String pathTestPage,
  2. String featureName,
  3. String pageName,
  4. String apiName,
  5. dynamic jsonBody,
  6. String bodyVariable,
  7. bool isBodyList,
)

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'));
}