/* * Copyright (C) 2020 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ import {Logger} from '@openstapps/logger'; import {slow, suite, test, timeout} from '@testdeck/mocha'; import {MapAggTest} from './mapping-model/MapAggTest'; import {inheritTagsTest} from './mapping-model/mappings/src/inherit-tags'; import {mapExplicitTypesTest} from './mapping-model/mappings/src/map-explicit-types'; import {doubleTypeConflictTest} from './mapping-model/mappings/src/double-type-conflict'; import {incompatibleTypeTest} from './mapping-model/mappings/src/incompatible-type'; import {sensibleDefaultsTest} from './mapping-model/mappings/src/sensible-defaults'; import {invalidTagTest} from './mapping-model/mappings/src/invalid-tag'; import {missingPremapTest} from './mapping-model/mappings/src/missing-premap'; import {defaultGenericTest} from './mapping-model/mappings/src/default-generics'; import {genericTest} from './mapping-model/mappings/src/generics'; import {nestedTest} from './mapping-model/mappings/src/nested'; import {indexSignatureTest} from './mapping-model/mappings/src/index-signature'; import {impossibleUnionTest} from './mapping-model/mappings/src/impossible-union'; import {objectUnionTest} from './mapping-model/mappings/src/object-union'; import {sortableTagTest} from './mapping-model/mappings/src/sortable-tag'; import {enumTest} from './mapping-model/mappings/src/enum'; import {inheritedPropertyTest} from './mapping-model/mappings/src/inherited-property'; import {pairedTagsTest} from './mapping-model/mappings/src/paired-tags'; import {filterableTagTest} from './mapping-model/mappings/src/filterable-tag'; import {anyUnknownTest} from './mapping-model/mappings/src/any-unknown'; import {tagsIgnoreCaseTest} from './mapping-model/mappings/src/tags-ignore-case'; import {typeAliasTest} from './mapping-model/mappings/src/type-alias'; import {dateAndRangeTest} from './mapping-model/mappings/src/date'; process.on('unhandledRejection', (error: unknown) => { if (error instanceof Error) { void Logger.error('UNHANDLED REJECTION', error.stack); } process.exit(1); }); const magAppInstance = new MapAggTest('mappings'); @suite(timeout(20000), slow(10000)) export class MappingSpec { @test async 'Any or unknown should create a dynamic field'() { magAppInstance.testInterfaceAgainstPath(anyUnknownTest); } @test async 'Filterable tag should add raw field to strings'() { magAppInstance.testInterfaceAgainstPath(filterableTagTest); } @test async 'Tags should be able to be paired'() { magAppInstance.testInterfaceAgainstPath(pairedTagsTest); } @test async 'Inherited properties should inherit tags'() { magAppInstance.testInterfaceAgainstPath(inheritedPropertyTest); } @test async 'Tags should ignore case'() { magAppInstance.testInterfaceAgainstPath(tagsIgnoreCaseTest); } @test async 'Emums should work'() { // Known issue: Enums only use text // https://gitlab.com/openstapps/core-tools/-/issues/46 magAppInstance.testInterfaceAgainstPath(enumTest); } @test async 'Sortable tag should work'() { magAppInstance.testInterfaceAgainstPath(sortableTagTest); } /* https://gitlab.com/openstapps/core-tools/-/merge_requests/29 @test async 'Wrapper types should inherit tags'() { this.testInterfaceAgainstPath(typeWrapperInheritanceTest); }*/ @test async 'Inherit tags tag should work'() { magAppInstance.testInterfaceAgainstPath(inheritTagsTest); } @test async 'Object union types should work'() { magAppInstance.testInterfaceAgainstPath(objectUnionTest); } /* https://gitlab.com/openstapps/core-tools/-/issues/47 @test async 'Type queries should work'() { magAppInstance.testInterfaceAgainstPath(typeQueryTest); }*/ @test async 'Type alias annotations should work'(){ magAppInstance.testInterfaceAgainstPath(typeAliasTest); } @test async 'Impossible union should cause an error'() { magAppInstance.testInterfaceAgainstPath(impossibleUnionTest); } @test async 'Index Signatures should work'() { magAppInstance.testInterfaceAgainstPath(indexSignatureTest); } @test async 'Nested properties should work'() { magAppInstance.testInterfaceAgainstPath(nestedTest); } @test async 'Generics should work'() { magAppInstance.testInterfaceAgainstPath(genericTest); } @test async 'Missing premap should cause an error'() { magAppInstance.testInterfaceAgainstPath(missingPremapTest); } @test async 'Default generics should fail (if they don\'t that\'s actually brilliant)'() { magAppInstance.testInterfaceAgainstPath(defaultGenericTest); } @test async 'Explicit type annotations should work'() { magAppInstance.testInterfaceAgainstPath(mapExplicitTypesTest); } @test async 'Double type annotations should cause an error'() { magAppInstance.testInterfaceAgainstPath(doubleTypeConflictTest); } @test async 'Incompatible type annotations should cause an error and use defaults'() { magAppInstance.testInterfaceAgainstPath(incompatibleTypeTest); } @test async 'Primitive types should have sensible defaults'() { magAppInstance.testInterfaceAgainstPath(sensibleDefaultsTest); } @test async 'Invalid tags should cause an error'() { magAppInstance.testInterfaceAgainstPath(invalidTagTest); } @test async 'Dates and date ranges should have the correct type'() { magAppInstance.testInterfaceAgainstPath(dateAndRangeTest); } }