mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 06:22:53 +00:00
test: add date mapping tests
This commit is contained in:
51
test/mapping-model/mappings/src/date.ts
Normal file
51
test/mapping-model/mappings/src/date.ts
Normal 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,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -34,6 +34,7 @@ export enum ThingType {
|
|||||||
PairedTags = 'paired tags',
|
PairedTags = 'paired tags',
|
||||||
FilterableTag = 'filterable tag',
|
FilterableTag = 'filterable tag',
|
||||||
AnyUnknown = 'any unknown',
|
AnyUnknown = 'any unknown',
|
||||||
|
Date = 'date',
|
||||||
InheritTags = 'inherit tags',
|
InheritTags = 'inherit tags',
|
||||||
TagsIgnoreCase = 'tags ignore case',
|
TagsIgnoreCase = 'tags ignore case',
|
||||||
TypeAlias = 'type alias',
|
TypeAlias = 'type alias',
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import {filterableTagTest} from './mapping-model/mappings/src/filterable-tag';
|
|||||||
import {anyUnknownTest} from './mapping-model/mappings/src/any-unknown';
|
import {anyUnknownTest} from './mapping-model/mappings/src/any-unknown';
|
||||||
import {tagsIgnoreCaseTest} from './mapping-model/mappings/src/tags-ignore-case';
|
import {tagsIgnoreCaseTest} from './mapping-model/mappings/src/tags-ignore-case';
|
||||||
import {typeAliasTest} from './mapping-model/mappings/src/type-alias';
|
import {typeAliasTest} from './mapping-model/mappings/src/type-alias';
|
||||||
|
import {dateAndRangeTest} from './mapping-model/mappings/src/date';
|
||||||
|
|
||||||
process.on('unhandledRejection', (error: unknown) => {
|
process.on('unhandledRejection', (error: unknown) => {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
@@ -168,4 +169,9 @@ export class MappingSpec {
|
|||||||
async 'Invalid tags should cause an error'() {
|
async 'Invalid tags should cause an error'() {
|
||||||
magAppInstance.testInterfaceAgainstPath(invalidTagTest);
|
magAppInstance.testInterfaceAgainstPath(invalidTagTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
async 'Dates and date ranges should have the correct type'() {
|
||||||
|
magAppInstance.testInterfaceAgainstPath(dateAndRangeTest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user