mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 14:32:50 +00:00
Upgraded JSON Schema from version 6 to version 7 Upgraded TypeDoc version to latest Replaced 'jsonschema' with 'json-schema' package to better comply with 'ts-json-schema-generator' Replace JSON Schema validation with AJV in areas where it wasn't used previously Removed commander help output as it causes strange issues
155 lines
5.1 KiB
TypeScript
155 lines
5.1 KiB
TypeScript
// tslint:disable
|
|
/*
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
*/
|
|
import {Logger} from '@openstapps/logger';
|
|
import {slow, suite, test, timeout} from 'mocha-typescript';
|
|
import {MapAggTest} from './mapping-model/MapAggTest';
|
|
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';
|
|
|
|
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 'Emums should work'() {
|
|
// Known issue: Enums only use text
|
|
// https://gitlab.com/openstapps/core-tools/-/issues/46
|
|
magAppInstance.testInterfaceAgainstPath(enumTest);
|
|
}
|
|
|
|
@test
|
|
'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 '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 '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);
|
|
}
|
|
}
|