From 33397e90fe491353c2f7b1d6df12374d78d13cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wieland=20Sch=C3=B6bl?= Date: Mon, 1 Feb 2021 14:47:50 +0100 Subject: [PATCH] test: add date mapping tests --- test/mapping-model/mappings/src/date.ts | 51 ++++++++++++++++++++++++ test/mapping-model/mappings/src/types.ts | 1 + test/mapping.spec.ts | 6 +++ 3 files changed, 58 insertions(+) create mode 100644 test/mapping-model/mappings/src/date.ts diff --git a/test/mapping-model/mappings/src/date.ts b/test/mapping-model/mappings/src/date.ts new file mode 100644 index 00000000..060cfb3f --- /dev/null +++ b/test/mapping-model/mappings/src/date.ts @@ -0,0 +1,51 @@ +/* + * 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 {ThingType} from './types'; +import {MapAggTestOptions} from '../../MapAggTestOptions'; +import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap'; + +/** + * @date + */ +export type SCISO8601Date = string + +/** + * @indexable + */ +export interface DateAndRange { + /** + * @date + */ + directDate: string; + + dateAlias: SCISO8601Date; + + type: ThingType.Date +} + +export const dateAndRangeTest: MapAggTestOptions = { + name: ThingType.Date, + map: { + maps: { + directDate: { + type: ElasticsearchDataType.date, + }, + dateAlias: { + type: ElasticsearchDataType.date, + }, + } + } +}; diff --git a/test/mapping-model/mappings/src/types.ts b/test/mapping-model/mappings/src/types.ts index a2f2c98b..c3015ac0 100644 --- a/test/mapping-model/mappings/src/types.ts +++ b/test/mapping-model/mappings/src/types.ts @@ -34,6 +34,7 @@ export enum ThingType { PairedTags = 'paired tags', FilterableTag = 'filterable tag', AnyUnknown = 'any unknown', + Date = 'date', InheritTags = 'inherit tags', TagsIgnoreCase = 'tags ignore case', TypeAlias = 'type alias', diff --git a/test/mapping.spec.ts b/test/mapping.spec.ts index e847ba56..d2acafd2 100644 --- a/test/mapping.spec.ts +++ b/test/mapping.spec.ts @@ -36,6 +36,7 @@ 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) { @@ -168,4 +169,9 @@ export class MappingSpec { async 'Invalid tags should cause an error'() { magAppInstance.testInterfaceAgainstPath(invalidTagTest); } + + @test + async 'Dates and date ranges should have the correct type'() { + magAppInstance.testInterfaceAgainstPath(dateAndRangeTest); + } }