test: add date mapping tests

This commit is contained in:
Wieland Schöbl
2021-02-01 14:47:50 +01:00
parent 62a739048c
commit 33397e90fe
3 changed files with 58 additions and 0 deletions

View File

@@ -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 <https://www.gnu.org/licenses/>.
*/
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,
},
}
}
};

View File

@@ -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',

View File

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