From 2feab1138596a7dee3293a22cd67fadb652729c1 Mon Sep 17 00:00:00 2001 From: Dominik Toton Date: Thu, 16 Jan 2025 15:00:02 +0100 Subject: [PATCH] chore: drop unnecessary tests --- .../test/src/document/document_dto_test.dart | 54 ---------------- .../schema/document_definitions_dto_test.dart | 55 ---------------- .../schema/document_schema_dto_test.dart | 59 ------------------ .../document_schema_property_dto_test.dart | 62 ------------------- 4 files changed, 230 deletions(-) delete mode 100644 catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_definitions_dto_test.dart delete mode 100644 catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_dto_test.dart delete mode 100644 catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_property_dto_test.dart diff --git a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/document_dto_test.dart b/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/document_dto_test.dart index 4452727048d..1bcc1944e9d 100644 --- a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/document_dto_test.dart +++ b/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/document_dto_test.dart @@ -1,6 +1,5 @@ import 'dart:convert'; -import 'package:catalyst_voices_models/catalyst_voices_models.dart'; import 'package:catalyst_voices_repositories/src/dto/document/document_dto.dart'; import 'package:catalyst_voices_repositories/src/dto/document/schema/document_schema_dto.dart'; import 'package:test/test.dart'; @@ -59,58 +58,5 @@ void main() { // verify they are the same expect(deserializedDoc, equals(originalDoc)); }); - - test('Converts segments list into object for JSON', () { - // final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - // final schema = schemaDto.toModel(); - - // final document = DocumentBuilder.fromSchema( - // schemaUrl: schemaPath, - // schema: schema, - // ).build(); - - // final documentDto = DocumentDto.fromModel(document); - // final documentJson = documentDto.toJson(); - - // for (final segment in documentDto.properties) { - // expect(documentJson[segment.schema.id], isA>()); - // } - }); - - test('Converts object from JSON into List of segments', () { - final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - final schema = schemaDto.toModel(); - - final document = DocumentBuilder.fromSchema( - schemaUrl: schemaPath, - schema: schema, - ).build(); - - final documentDto = DocumentDto.fromModel(document); - - final documentJson = documentDto.toJson(); - final documentDtoFromJson = - DocumentDto.fromJsonSchema(documentJson, schema); - - expect( - documentDtoFromJson.properties.length, - documentDto.properties.length, - ); - }); - - test('After serialization $DocumentPropertyValueDto has correct type', () { - // final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - // final schema = schemaDto.toModel(); - - // final documentDto = DocumentDto.fromJsonSchema(documentJson, schema); - - // final agreementSegment = documentDto.properties - // .indexWhere((e) => e.schema.nodeId.paths.last == 'agreements'); - // expect(agreementSegment, isNot(equals(-1))); - // final agreementSections = documentDto.properties[agreementSegment].sections; - // final agreementProperty = agreementSections.first.properties.first - // as DocumentPropertyValueDto; - // expect(agreementProperty.value, true); - }); }); } diff --git a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_definitions_dto_test.dart b/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_definitions_dto_test.dart deleted file mode 100644 index feb8289de45..00000000000 --- a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_definitions_dto_test.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'dart:convert'; - -import 'package:catalyst_voices_repositories/src/dto/document/schema/document_schema_dto.dart'; -import 'package:test/test.dart'; - -import '../../../helpers/read_json.dart'; - -void main() { - group('$DocumentSchemaDto definitions', () { - const schemaPath = - 'test/assets/0ce8ab38-9258-4fbc-a62e-7faa6e58318f.schema.json'; - - late Map schemaJson; - - setUpAll(() { - schemaJson = json.decode(readJson(schemaPath)) as Map; - }); - - test( - 'Check if all definition are in definition ' - 'list inside DefinitionDto model', - () async { - // final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - // final definitions = schemaDto.definitions.models; - - // for (final value - // in BaseDocumentDefinition.refPathToDefinitionType.values) { - // final occurrences = definitions - // .where((element) => element.runtimeType == value) - // .length; - // expect( - // occurrences, - // equals(1), - // reason: 'Value $value appears $occurrences times in the list', - // ); - // } - }, - ); - - test('Check if document definition media type is parse correctly', () { - // final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - // final definitions = schemaDto.definitions.models; - - // final singleLineTextEntry = definitions.getDefinition( - // '#/definitions/singleLineTextEntry', - // DocumentPropertyType.string, - // ) as SingleLineTextEntryDefinition; - - // expect( - // singleLineTextEntry.contentMediaType, - // DocumentContentMediaType.textPlain, - // ); - }); - }); -} diff --git a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_dto_test.dart b/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_dto_test.dart deleted file mode 100644 index 5b4fbfdb1a1..00000000000 --- a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_dto_test.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'dart:convert'; - -import 'package:catalyst_voices_repositories/src/dto/document/schema/document_schema_dto.dart'; -import 'package:test/test.dart'; - -import '../../../helpers/read_json.dart'; - -void main() { - group(DocumentSchemaDto, () { - const schemaPath = - 'test/assets/0ce8ab38-9258-4fbc-a62e-7faa6e58318f.schema.json'; - - late Map schemaJson; - - setUpAll(() { - schemaJson = json.decode(readJson(schemaPath)) as Map; - }); - - test('X-order of segments is kept in model class', () async { - final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - - final schema = schemaDto.toModel(); - - if (schemaDto.order?.length != schema.properties.length) { - return; - } - for (var i = 0; i < schema.properties.length; i++) { - expect(schema.properties[i].id, schemaDto.order?[i]); - } - }); - - test('X-order of section is kept in model class', () { - final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - final schema = schemaDto.toModel(); - - // for (var i = 0; i < schema.properties.length; i++) { - // if (schemaDto.properties.values.toList()[i].order?.length != - // schema.properties[i].properties.length) { - // continue; - // } - // for (var j = 0; j < schema.properties[i].sections.length; j++) { - // expect( - // schema.properties[i].sections[j].id, - // schemaDto.segments.values.toList()[i].order?[j], - // ); - // } - // } - }); - - test('Check if every segment has a SegmentDefinition as ref', () { - // final schemaDto = DocumentSchemaDto.fromJson(schemaJson); - // final schema = schemaDto.toModel(); - - // for (final segment in schema.segments) { - // expect(segment.definition, isA()); - // } - }); - }); -} diff --git a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_property_dto_test.dart b/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_property_dto_test.dart deleted file mode 100644 index 57da4497d48..00000000000 --- a/catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/document/schema/document_schema_property_dto_test.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:convert'; - -import 'package:catalyst_voices_repositories/src/dto/document/schema/document_property_schema_dto.dart'; -import 'package:test/test.dart'; - -import '../../../helpers/read_json.dart'; - -void main() { - group(DocumentPropertySchemaDto, () { - const schemaPath = - 'test/assets/0ce8ab38-9258-4fbc-a62e-7faa6e58318f.schema.json'; - - late Map schemaJson; - - setUpAll(() { - schemaJson = json.decode(readJson(schemaPath)) as Map; - }); - - test('includeIfNull does not add keys for values that are null', () { - // Given - const dto = DocumentPropertySchemaDto( - ref: '#/definitions/section', - ); - - const expectedJson = { - r'$ref': '#/definitions/section', - }; - - // When - final json = dto.toJson(); - - // Then - expect(json, expectedJson); - }); - - group('grouped_tag', () { - test('oneOf is parsed correctly', () { - // Given - // ignore: avoid_dynamic_calls - final json = schemaJson['properties']['horizons']['properties']['theme'] - ['properties']['grouped_tag'] as Map - ..['id'] = 'grouped_tag'; - - // When - final dto = DocumentPropertySchemaDto.fromJson(json); - - // Then - expect(dto.ref, '#/definitions/singleGroupedTagSelector'); - expect( - dto.oneOf, - allOf(isNotNull, hasLength(13)), - ); - - // for (final group in dto.oneOf!) { - // expect(group.conditions, hasLength(2)); - // expect(group.conditions![0], 'group'); - // expect(group.conditions![1].id, 'tag'); - // } - }); - }); - }); -}