@molgenis/vip-report-template 6.2.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- package/.travis.yml +8 -8
- package/README.md +411 -1
- package/eslint.config.mjs +11 -0
- package/package.json +40 -35
- package/scripts/deploy_npm_registry.sh +5 -0
- package/src/App.tsx +30 -24
- package/src/assets/sass/main.scss +12 -4
- package/src/components/Allele.tsx +95 -0
- package/src/components/Anchor.tsx +1 -1
- package/src/components/Breadcrumb.tsx +6 -4
- package/src/components/DatasetDropdown.tsx +12 -25
- package/src/components/ErrorNotification.tsx +9 -0
- package/src/components/GenomeBrowser.tsx +40 -23
- package/src/components/HpoTerm.tsx +1 -1
- package/src/components/{record/Pager.tsx → Pager.tsx} +21 -14
- package/src/components/RecordsPerPage.tsx +9 -7
- package/src/components/RecordsTable.tsx +130 -0
- package/src/components/SampleTable.tsx +70 -98
- package/src/components/SearchBox.tsx +8 -2
- package/src/components/Sort.tsx +28 -25
- package/src/components/Table.tsx +16 -0
- package/src/components/Tooltip.tsx +20 -0
- package/src/components/VariantBreadcrumb.tsx +54 -0
- package/src/components/VariantConsequenceContainer.tsx +100 -0
- package/src/components/VariantConsequenceTable.tsx +58 -0
- package/src/components/VariantContainer.tsx +71 -0
- package/src/components/VariantFilters.tsx +27 -0
- package/src/components/VariantGenotypeTable.tsx +44 -0
- package/src/components/VariantInfoTable.tsx +24 -33
- package/src/components/VariantResults.tsx +103 -0
- package/src/components/VariantTable.tsx +62 -66
- package/src/components/VariantTypeSelect.tsx +34 -0
- package/src/components/VariantsContainer.tsx +150 -0
- package/src/components/VariantsContainerHeader.tsx +70 -0
- package/src/components/field/Field.tsx +80 -0
- package/src/components/field/FieldAlt.tsx +19 -0
- package/src/components/field/FieldChrom.tsx +6 -0
- package/src/components/{record/Id.tsx → field/FieldFilter.tsx} +2 -1
- package/src/components/field/FieldFormat.tsx +10 -0
- package/src/components/{record/Filter.tsx → field/FieldId.tsx} +1 -1
- package/src/components/field/FieldPos.tsx +6 -0
- package/src/components/field/FieldQual.tsx +6 -0
- package/src/components/field/FieldRef.tsx +8 -0
- package/src/components/field/composed/FieldClinVar.tsx +72 -0
- package/src/components/field/composed/FieldComposed.tsx +68 -0
- package/src/components/field/composed/FieldGene.tsx +39 -0
- package/src/components/field/composed/FieldGenotype.tsx +35 -0
- package/src/components/{record/format/GenotypeField.tsx → field/composed/FieldGenotypeSnvSv.tsx} +20 -16
- package/src/components/field/composed/FieldGenotypeStr.tsx +31 -0
- package/src/components/field/composed/FieldGnomAd.tsx +58 -0
- package/src/components/field/composed/FieldHpo.tsx +50 -0
- package/src/components/field/composed/FieldInheritanceModes.tsx +32 -0
- package/src/components/field/composed/FieldLocus.tsx +18 -0
- package/src/components/field/composed/FieldVipC.tsx +25 -0
- package/src/components/field/composed/FieldVipCS.tsx +15 -0
- package/src/components/field/composed/FieldVkgl.tsx +37 -0
- package/src/components/field/genotype/FieldGenotype.tsx +19 -0
- package/src/components/field/genotype/FieldGenotypeType.tsx +9 -0
- package/src/components/field/info/FieldConsequence.tsx +15 -0
- package/src/components/{record/info/Hgvs.tsx → field/info/FieldHgvs.tsx} +4 -6
- package/src/components/field/info/FieldInfo.tsx +27 -0
- package/src/components/{record/info/PubMed.tsx → field/info/FieldPubMed.tsx} +4 -7
- package/src/components/field/typed/FieldCategorical.tsx +17 -0
- package/src/components/{record/field/FieldValueCharacter.tsx → field/typed/FieldCharacter.tsx} +3 -2
- package/src/components/{record/field/FieldValueFlag.tsx → field/typed/FieldFlag.tsx} +3 -2
- package/src/components/{record/field/FieldValueFloat.tsx → field/typed/FieldFloat.tsx} +3 -2
- package/src/components/{record/field/FieldValueInteger.tsx → field/typed/FieldInteger.tsx} +3 -2
- package/src/components/{record/field/FieldValueString.tsx → field/typed/FieldString.tsx} +3 -2
- package/src/components/field/typed/FieldTyped.tsx +20 -0
- package/src/components/field/typed/FieldTypedItem.tsx +49 -0
- package/src/components/field/typed/FieldTypedMultiple.tsx +21 -0
- package/src/components/filter/Filter.tsx +56 -48
- package/src/components/filter/FilterWrapper.scss +23 -0
- package/src/components/filter/FilterWrapper.tsx +63 -0
- package/src/components/filter/composed/FilterAllelicImbalance.tsx +26 -0
- package/src/components/filter/composed/FilterComposed.tsx +92 -0
- package/src/components/filter/composed/FilterDeNovo.tsx +35 -0
- package/src/components/filter/composed/FilterHpo.tsx +16 -0
- package/src/components/filter/composed/FilterInheritance.tsx +42 -0
- package/src/components/filter/composed/FilterLocus.tsx +75 -0
- package/src/components/filter/composed/FilterVipC.tsx +16 -0
- package/src/components/filter/composed/FilterVipCS.tsx +16 -0
- package/src/components/filter/fixed/FilterAlt.tsx +20 -0
- package/src/components/filter/fixed/FilterChrom.tsx +22 -0
- package/src/components/filter/fixed/FilterFilter.tsx +20 -0
- package/src/components/filter/fixed/FilterFixed.tsx +96 -0
- package/src/components/filter/fixed/FilterId.tsx +20 -0
- package/src/components/filter/fixed/FilterPos.tsx +22 -0
- package/src/components/filter/fixed/FilterQual.tsx +21 -0
- package/src/components/filter/fixed/FilterRef.tsx +22 -0
- package/src/components/filter/typed/FilterCategorical.tsx +119 -0
- package/src/components/filter/typed/FilterFlag.tsx +23 -0
- package/src/components/filter/typed/FilterInterval.tsx +72 -0
- package/src/components/filter/typed/FilterString.tsx +43 -0
- package/src/components/filter/typed/FilterTyped.tsx +56 -0
- package/src/components/form/ButtonApply.tsx +11 -0
- package/src/components/form/ButtonDownload.tsx +11 -0
- package/src/components/form/ButtonReset.tsx +9 -0
- package/src/components/{Checkbox.tsx → form/Checkbox.tsx} +4 -9
- package/src/components/form/Input.tsx +19 -0
- package/src/components/form/Select.scss +7 -0
- package/src/components/form/Select.tsx +34 -0
- package/src/components/tree/DecisionTreeBoolMultiQuery.tsx +1 -1
- package/src/components/tree/DecisionTreeBoolQuery.tsx +1 -1
- package/src/components/tree/DecisionTreeNode.tsx +41 -39
- package/src/components/tree/DecisionTreeNodeBool.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeBoolMulti.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeCategorical.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeExists.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeLeaf.tsx +1 -1
- package/src/components/tree/DecisionTreeOutcomeNode.tsx +1 -1
- package/src/components/tree/DecisionTreePath.tsx +1 -1
- package/src/igv.d.ts +2 -1
- package/src/index.tsx +48 -19
- package/src/mocks/GRCh37/decisionTree.json +23 -22
- package/src/mocks/GRCh37/field_metadata.json +435 -95
- package/src/mocks/GRCh37/sampleTree.json +21 -1
- package/src/mocks/GRCh37/static.ts +62 -134
- package/src/mocks/GRCh37/vcf/family.vcf.blob +9 -3
- package/src/mocks/GRCh38/decisionTree.json +52 -33
- package/src/mocks/GRCh38/decisionTreeStr.json +572 -0
- package/src/mocks/GRCh38/fasta/chr1_149380406-149403321.fasta.gz.blob +0 -0
- package/src/mocks/GRCh38/field_metadata.json +435 -95
- package/src/mocks/GRCh38/sampleTree.json +175 -0
- package/src/mocks/GRCh38/static.ts +101 -42
- package/src/mocks/GRCh38/str.cram.blob +0 -0
- package/src/mocks/GRCh38/str.cram.crai.blob +0 -0
- package/src/mocks/GRCh38/vcf/family.vcf.blob +25 -24
- package/src/mocks/GRCh38/vcf/no_vep.vcf.blob +29 -28
- package/src/mocks/GRCh38/vcf/samples_0.vcf.blob +28 -27
- package/src/mocks/GRCh38/vcf/samples_1.vcf.blob +29 -28
- package/src/mocks/GRCh38/vcf/samples_100.vcf.blob +28 -27
- package/src/mocks/GRCh38/vcf/str.vcf.blob +321 -0
- package/src/mocks/MockApiClient.ts +339 -332
- package/src/mocks/config_cram.json +701 -0
- package/src/mocks/config_vcf.json +699 -0
- package/src/store/app.ts +30 -0
- package/src/store/index.tsx +3 -168
- package/src/store/variants.ts +182 -0
- package/src/types/config.d.ts +190 -0
- package/src/types/configCellComposed.d.ts +86 -0
- package/src/types/configCells.d.ts +129 -0
- package/src/types/configFilter.d.ts +80 -0
- package/src/types/configFilterComposed.d.ts +60 -0
- package/src/types/configSort.d.ts +13 -0
- package/src/types/filter.d.ts +17 -0
- package/src/types/store.d.ts +34 -0
- package/src/utils/api.ts +281 -0
- package/src/utils/config/config.ts +182 -0
- package/src/utils/config/configCells.ts +74 -0
- package/src/utils/config/configCellsComposed.ts +508 -0
- package/src/utils/config/configCellsField.ts +61 -0
- package/src/utils/config/configCellsFixed.ts +126 -0
- package/src/utils/config/configFilters.ts +46 -0
- package/src/utils/config/configFiltersComposed.ts +208 -0
- package/src/utils/config/configFiltersField.ts +49 -0
- package/src/utils/config/configFiltersFixed.ts +106 -0
- package/src/utils/config/configSorts.ts +44 -0
- package/src/utils/config/configValidator.ts +380 -0
- package/src/utils/config/configVip.ts +25 -0
- package/src/utils/csq.ts +115 -0
- package/src/utils/decisionTree.ts +45 -0
- package/src/utils/download.ts +30 -0
- package/src/utils/error.ts +69 -0
- package/src/utils/query/query.ts +55 -0
- package/src/utils/query/queryFilter.ts +132 -0
- package/src/utils/query/queryFilterComposed.ts +247 -0
- package/src/utils/query/queryFilterField.ts +75 -0
- package/src/utils/query/queryFilterFixed.ts +44 -0
- package/src/utils/query/querySample.ts +18 -0
- package/src/utils/query/queryVariantType.ts +76 -0
- package/src/utils/query/selector.ts +41 -0
- package/src/utils/{sortUtils.ts → query/sort.ts} +32 -11
- package/src/utils/sample.ts +19 -35
- package/src/utils/utils.ts +66 -2
- package/src/utils/variantType.ts +43 -0
- package/src/utils/vcf.ts +352 -0
- package/src/views/Help.tsx +109 -114
- package/src/views/Home.tsx +3 -2
- package/src/views/Sample.tsx +12 -7
- package/src/views/SampleVariant.tsx +23 -112
- package/src/views/SampleVariantConsequence.tsx +54 -144
- package/src/views/SampleVariants.tsx +33 -445
- package/src/views/SampleVariantsRedirect.tsx +20 -0
- package/src/views/Samples.tsx +7 -10
- package/src/views/Variant.tsx +31 -61
- package/src/views/VariantConsequence.tsx +42 -72
- package/src/views/Variants.tsx +29 -138
- package/src/views/VariantsRedirect.tsx +25 -0
- package/src/views/data/data.tsx +32 -6
- package/tests/store/variants.test.ts +122 -0
- package/tests/utils/config/config.test.ts +167 -0
- package/tests/utils/config/configCells.test.ts +86 -0
- package/tests/utils/config/configCellsComposed.test.ts +1163 -0
- package/tests/utils/config/configCellsField.test.ts +164 -0
- package/tests/utils/config/configCellsFixed.test.ts +99 -0
- package/tests/utils/config/configFilters.test.ts +80 -0
- package/tests/utils/config/configFiltersComposed.test.ts +504 -0
- package/tests/utils/config/configFiltersField.test.ts +140 -0
- package/tests/utils/config/configFiltersFixed.test.ts +81 -0
- package/tests/utils/config/configSorts.test.ts +55 -0
- package/tests/utils/config/configValidator.test.ts +56 -0
- package/tests/utils/config/configVip.test.ts +53 -0
- package/tests/utils/decisionTree.test.ts +71 -0
- package/tests/utils/download.test.ts +20 -0
- package/tests/utils/query/query.test.ts +84 -0
- package/tests/utils/query/queryFilter.test.ts +243 -0
- package/tests/utils/query/queryFilterComposed.test.ts +301 -0
- package/tests/utils/query/queryFilterField.test.ts +75 -0
- package/tests/utils/query/queryFilterFixed.test.ts +86 -0
- package/tests/utils/query/querySample.test.ts +45 -0
- package/tests/utils/query/queryVariantType.test.ts +56 -0
- package/{src/__tests__/sortUtils.test.ts → tests/utils/query/sort.test.ts} +3 -4
- package/tests/utils/sample.test.ts +259 -0
- package/tests/utils/utils.test.ts +120 -0
- package/tests/utils/variantType.test.ts +48 -0
- package/tests/utils/vcf.test.ts +649 -0
- package/tsconfig.json +6 -2
- package/vite.config.mts +20 -3
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -23
- package/src/Api.ts +0 -12
- package/src/__tests__/decisionTreeUtils.test.ts +0 -75
- package/src/__tests__/field.test.ts +0 -107
- package/src/__tests__/query.test.ts +0 -188
- package/src/__tests__/sample.test.ts +0 -184
- package/src/__tests__/utils.test.ts +0 -24
- package/src/__tests__/viewUtils.test.ts +0 -125
- package/src/components/ConsequenceTable.tsx +0 -45
- package/src/components/Error.tsx +0 -9
- package/src/components/FieldHeader.tsx +0 -26
- package/src/components/InfoCollapsablePane.tsx +0 -90
- package/src/components/VariantInfoNestedTable.tsx +0 -127
- package/src/components/VariantSampleTable.tsx +0 -58
- package/src/components/VariantsSampleTable.tsx +0 -184
- package/src/components/VariantsTable.tsx +0 -125
- package/src/components/filter/FilterAllelicBalance.tsx +0 -81
- package/src/components/filter/FilterCategorical.tsx +0 -81
- package/src/components/filter/FilterClinVar.tsx +0 -21
- package/src/components/filter/FilterGene.tsx +0 -34
- package/src/components/filter/FilterHpo.tsx +0 -161
- package/src/components/filter/FilterInheritance.tsx +0 -162
- package/src/components/filter/FilterIntegerGq.tsx +0 -47
- package/src/components/filter/FilterVI.tsx +0 -68
- package/src/components/filter/FilterVariantType.tsx +0 -146
- package/src/components/filter/Filters.tsx +0 -29
- package/src/components/filter/InfoFilter.tsx +0 -39
- package/src/components/filter/InfoFilters.tsx +0 -35
- package/src/components/filter/SampleFilters.tsx +0 -93
- package/src/components/filter/SamplesFilters.tsx +0 -33
- package/src/components/record/Allele.tsx +0 -38
- package/src/components/record/AlleleBreakend.tsx +0 -5
- package/src/components/record/AlleleMissing.tsx +0 -5
- package/src/components/record/AlleleNucs.tsx +0 -49
- package/src/components/record/AlleleSymbolic.tsx +0 -5
- package/src/components/record/Alt.tsx +0 -17
- package/src/components/record/Chrom.tsx +0 -5
- package/src/components/record/Format.tsx +0 -40
- package/src/components/record/Info.tsx +0 -55
- package/src/components/record/Pos.tsx +0 -5
- package/src/components/record/Qual.tsx +0 -5
- package/src/components/record/RecordDownload.tsx +0 -66
- package/src/components/record/Ref.tsx +0 -6
- package/src/components/record/field/Field.tsx +0 -36
- package/src/components/record/field/FieldMultipleValue.tsx +0 -22
- package/src/components/record/field/FieldSingleValue.tsx +0 -35
- package/src/components/record/info/ClinVar.tsx +0 -81
- package/src/components/record/info/Consequence.tsx +0 -18
- package/src/components/record/info/Gene.tsx +0 -56
- package/src/components/record/info/GnomAD.tsx +0 -54
- package/src/components/record/info/Hpo.tsx +0 -52
- package/src/components/record/info/InheritanceModes.tsx +0 -22
- package/src/components/record/info/VipC.tsx +0 -23
- package/src/components/record/info/Vkgl.tsx +0 -42
- package/src/mocks/GRCh37/vcf/no_vep.vcf.blob +0 -61
- package/src/mocks/GRCh37/vcf/samples_0.vcf.blob +0 -93
- package/src/mocks/GRCh37/vcf/samples_1.vcf.blob +0 -93
- package/src/mocks/GRCh37/vcf/samples_100.vcf.blob +0 -93
- package/src/utils/ApiUtils.ts +0 -263
- package/src/utils/csqUtils.ts +0 -27
- package/src/utils/decisionTreeUtils.ts +0 -31
- package/src/utils/field.ts +0 -49
- package/src/utils/query.ts +0 -154
- package/src/utils/viewUtils.ts +0 -32
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { initConfigFilterFixed } from "../../../src/utils/config/configFiltersFixed.ts";
|
|
3
|
+
|
|
4
|
+
describe("config filters fixed", () => {
|
|
5
|
+
describe("initConfigFilterFixed", () => {
|
|
6
|
+
test("chrom", () => {
|
|
7
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "chrom" });
|
|
8
|
+
|
|
9
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
10
|
+
expect(filter.id).toStrictEqual("chrom");
|
|
11
|
+
expect(filter.label()).toStrictEqual("Chromosome");
|
|
12
|
+
expect(filter.description()).toStrictEqual(null);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("pos", () => {
|
|
16
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "pos" });
|
|
17
|
+
|
|
18
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
19
|
+
expect(filter.id).toStrictEqual("pos");
|
|
20
|
+
expect(filter.label()).toStrictEqual("Position");
|
|
21
|
+
expect(filter.description()).toStrictEqual(null);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("id", () => {
|
|
25
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "id" });
|
|
26
|
+
|
|
27
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
28
|
+
expect(filter.id).toStrictEqual("id");
|
|
29
|
+
expect(filter.label()).toStrictEqual("Identifiers");
|
|
30
|
+
expect(filter.description()).toStrictEqual(null);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("ref", () => {
|
|
34
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "ref" });
|
|
35
|
+
|
|
36
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
37
|
+
expect(filter.id).toStrictEqual("ref");
|
|
38
|
+
expect(filter.label()).toStrictEqual("Reference");
|
|
39
|
+
expect(filter.description()).toStrictEqual(null);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("alt", () => {
|
|
43
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "alt" });
|
|
44
|
+
|
|
45
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
46
|
+
expect(filter.id).toStrictEqual("alt");
|
|
47
|
+
expect(filter.label()).toStrictEqual("Alt");
|
|
48
|
+
expect(filter.description()).toStrictEqual(null);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("qual", () => {
|
|
52
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "qual" });
|
|
53
|
+
|
|
54
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
55
|
+
expect(filter.id).toStrictEqual("qual");
|
|
56
|
+
expect(filter.label()).toStrictEqual("Quality");
|
|
57
|
+
expect(filter.description()).toStrictEqual(null);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("filter", () => {
|
|
61
|
+
const filter = initConfigFilterFixed({ type: "fixed", name: "filter" });
|
|
62
|
+
|
|
63
|
+
expect(filter.type).toStrictEqual("fixed");
|
|
64
|
+
expect(filter.id).toStrictEqual("filter");
|
|
65
|
+
expect(filter.label()).toStrictEqual("Filter");
|
|
66
|
+
expect(filter.description()).toStrictEqual(null);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("filter with custom label and description", () => {
|
|
70
|
+
const filter = initConfigFilterFixed({
|
|
71
|
+
type: "fixed",
|
|
72
|
+
name: "chrom",
|
|
73
|
+
label: "custom_label",
|
|
74
|
+
description: "custom_description",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(filter.label()).toStrictEqual("custom_label");
|
|
78
|
+
expect(filter.description()).toStrictEqual("custom_description");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MetadataContainer, VcfMetadataContainer } from "../../../src/utils/api.ts";
|
|
2
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
3
|
+
import { ConfigJsonSort } from "../../../src/types/config";
|
|
4
|
+
import { initConfigSorts } from "../../../src/utils/config/configSorts.ts";
|
|
5
|
+
import { FieldMetadataWrapper, getInfoField } from "../../../src/utils/vcf.ts";
|
|
6
|
+
|
|
7
|
+
describe("initConfigSorts", () => {
|
|
8
|
+
vi.mock(import("../../../src/utils/vcf.ts"));
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
vi.resetAllMocks();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const vcfMetadata = {};
|
|
15
|
+
const metadata: Partial<MetadataContainer> = { records: vcfMetadata as VcfMetadataContainer };
|
|
16
|
+
|
|
17
|
+
test("regular sorts config", () => {
|
|
18
|
+
const fieldMetadata = { id: "f" } as FieldMetadataWrapper;
|
|
19
|
+
const config: ConfigJsonSort[] = [
|
|
20
|
+
{
|
|
21
|
+
selected: true,
|
|
22
|
+
orders: [{ direction: "desc", field: { type: "info", name: "f" } }],
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
vi.mocked(getInfoField).mockReturnValue(fieldMetadata);
|
|
26
|
+
|
|
27
|
+
expect(initConfigSorts(config, metadata as MetadataContainer)).toStrictEqual([
|
|
28
|
+
{
|
|
29
|
+
orders: [
|
|
30
|
+
{
|
|
31
|
+
direction: "desc",
|
|
32
|
+
field: {
|
|
33
|
+
id: "f",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
selected: true,
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
expect(getInfoField).toHaveBeenCalledWith(vcfMetadata, "f");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("undefined sort field", () => {
|
|
44
|
+
const config: ConfigJsonSort[] = [
|
|
45
|
+
{
|
|
46
|
+
selected: true,
|
|
47
|
+
orders: [{ direction: "desc", field: { type: "info", name: "f_unknown" } }],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
vi.mocked(getInfoField).mockReturnValue(undefined);
|
|
51
|
+
|
|
52
|
+
expect(initConfigSorts(config, metadata as MetadataContainer)).toStrictEqual([]);
|
|
53
|
+
expect(getInfoField).toHaveBeenCalledWith(vcfMetadata, "f_unknown");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { validateConfig } from "../../../src/utils/config/configValidator.ts";
|
|
3
|
+
|
|
4
|
+
describe("config parser", () => {
|
|
5
|
+
const configBase = {
|
|
6
|
+
sample_variants: { cells: {} },
|
|
7
|
+
variants: { cells: {} },
|
|
8
|
+
sample_variant: { cells: {} },
|
|
9
|
+
variant: { cells: {} },
|
|
10
|
+
sample_variant_consequence: { sample_cells: {} },
|
|
11
|
+
variant_consequence: {},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe("parseConfig", () => {
|
|
15
|
+
test("valid", () => {
|
|
16
|
+
const config = {
|
|
17
|
+
...configBase,
|
|
18
|
+
vip: {
|
|
19
|
+
filter_field: { type: "genotype", name: "f" },
|
|
20
|
+
params: { vcf: { filter: { classes: "c0,c1", consequences: true }, filter_samples: { classes: "cs0,cs1" } } },
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
expect(validateConfig(config)).toStrictEqual(config);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("valid with additional vip.params properties", () => {
|
|
27
|
+
const config = {
|
|
28
|
+
...configBase,
|
|
29
|
+
vip: {
|
|
30
|
+
filter_field: { type: "genotype", name: "f" },
|
|
31
|
+
params: {
|
|
32
|
+
vcf: {
|
|
33
|
+
filter: { classes: "c0,c1", consequences: true, new_prop: true },
|
|
34
|
+
filter_samples: { classes: "cs0,cs1", new_prop: true },
|
|
35
|
+
},
|
|
36
|
+
new_prop: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
expect(validateConfig(config)).toStrictEqual(config);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("invalid", () => {
|
|
44
|
+
const config = {};
|
|
45
|
+
|
|
46
|
+
// suppress logging
|
|
47
|
+
const old = console.error;
|
|
48
|
+
console.error = () => {};
|
|
49
|
+
try {
|
|
50
|
+
expect(() => validateConfig(config)).toThrow(/^config invalid$/);
|
|
51
|
+
} finally {
|
|
52
|
+
console.error = old;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { initConfigVip } from "../../../src/utils/config/configVip.ts";
|
|
3
|
+
import { ConfigJsonVip, ConfigJsonVipParams } from "../../../src/types/config";
|
|
4
|
+
import { MetadataContainer, VcfMetadataContainer } from "../../../src/utils/api.ts";
|
|
5
|
+
import { FieldMetadataWrapper, getSampleField } from "../../../src/utils/vcf.ts";
|
|
6
|
+
|
|
7
|
+
describe("config vip", () => {
|
|
8
|
+
vi.mock(import("../../../src/utils/vcf.ts"));
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
vi.resetAllMocks();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("initConfigVip", () => {
|
|
15
|
+
const vcfMetadata = {};
|
|
16
|
+
const metadata: Partial<MetadataContainer> = { records: vcfMetadata as VcfMetadataContainer };
|
|
17
|
+
const params = { vcf: {} } as ConfigJsonVipParams;
|
|
18
|
+
const config: ConfigJsonVip = {
|
|
19
|
+
filter_field: { type: "genotype", name: "f" },
|
|
20
|
+
params,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
test("init", () => {
|
|
24
|
+
const fieldMetadata = { id: "f", type: "CATEGORICAL" } as FieldMetadataWrapper;
|
|
25
|
+
vi.mocked(getSampleField).mockReturnValue(fieldMetadata);
|
|
26
|
+
|
|
27
|
+
expect(initConfigVip(config, metadata as MetadataContainer)).toStrictEqual({
|
|
28
|
+
filter_field: fieldMetadata,
|
|
29
|
+
params,
|
|
30
|
+
});
|
|
31
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "f");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("init metadata invalid", () => {
|
|
35
|
+
const fieldMetadata = { id: "f", type: "INTEGER" } as FieldMetadataWrapper;
|
|
36
|
+
vi.mocked(getSampleField).mockReturnValue(fieldMetadata);
|
|
37
|
+
|
|
38
|
+
expect(() => initConfigVip(config, metadata as MetadataContainer)).toThrowError(
|
|
39
|
+
/^config invalid: property 'vip.filter_field.name' value 'f' is of type INTEGER instead of CATEGORICAL$/,
|
|
40
|
+
);
|
|
41
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "f");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("init metadata unavailable", () => {
|
|
45
|
+
vi.mocked(getSampleField).mockReturnValue(undefined);
|
|
46
|
+
|
|
47
|
+
expect(() => initConfigVip(config, metadata as MetadataContainer)).toThrowError(
|
|
48
|
+
/^config invalid: property 'vip.filter_field.name' value 'f' does not exist in vcf metadata$/,
|
|
49
|
+
);
|
|
50
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "f");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { getDecisionTreePath, getSampleTreePath } from "../../src/utils/decisionTree.ts";
|
|
3
|
+
import { Item } from "@molgenis/vip-report-api";
|
|
4
|
+
import { VcfRecord } from "@molgenis/vip-report-vcf";
|
|
5
|
+
import { SampleContainer, VcfMetadataContainer } from "../../src/utils/api.ts";
|
|
6
|
+
import {
|
|
7
|
+
FieldMetadataWrapper,
|
|
8
|
+
getInfoNestedField,
|
|
9
|
+
getInfoValue,
|
|
10
|
+
getSampleField,
|
|
11
|
+
getSampleValue,
|
|
12
|
+
} from "../../src/utils/vcf.ts";
|
|
13
|
+
|
|
14
|
+
describe("decision tree", () => {
|
|
15
|
+
vi.mock(import("../../src/utils/vcf.ts"));
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.resetAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const vcfMetadata = {} as VcfMetadataContainer;
|
|
22
|
+
const record: Item<VcfRecord> = {
|
|
23
|
+
data: {
|
|
24
|
+
c: "chr1",
|
|
25
|
+
p: 123,
|
|
26
|
+
},
|
|
27
|
+
} as Partial<Item<Partial<VcfRecord>>> as Item<VcfRecord>;
|
|
28
|
+
|
|
29
|
+
describe("getDecisionTreePath", () => {
|
|
30
|
+
test("get", () => {
|
|
31
|
+
const fieldMetadata = {
|
|
32
|
+
id: "VIPP",
|
|
33
|
+
parent: { id: "CSQ" },
|
|
34
|
+
} as FieldMetadataWrapper;
|
|
35
|
+
|
|
36
|
+
vi.mocked(getInfoNestedField).mockReturnValue(fieldMetadata);
|
|
37
|
+
vi.mocked(getInfoValue).mockReturnValue("a&b&c");
|
|
38
|
+
expect(getDecisionTreePath(vcfMetadata, record, 2)).toStrictEqual("a&b&c");
|
|
39
|
+
expect(getInfoNestedField).toHaveBeenCalledWith(vcfMetadata, "CSQ", "VIPP");
|
|
40
|
+
expect(getInfoValue).toHaveBeenCalledWith(record, 2, fieldMetadata);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("get, no metadata", () => {
|
|
44
|
+
vi.mocked(getInfoNestedField).mockReturnValue(undefined);
|
|
45
|
+
expect(getDecisionTreePath(vcfMetadata, record, 2)).toStrictEqual([]);
|
|
46
|
+
expect(getInfoNestedField).toHaveBeenCalledWith(vcfMetadata, "CSQ", "VIPP");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("getSampleTreePath", () => {
|
|
51
|
+
const sample = { item: { id: 0 } } as SampleContainer;
|
|
52
|
+
|
|
53
|
+
test("get", () => {
|
|
54
|
+
const fieldMetadata = {
|
|
55
|
+
id: "VIPP_S",
|
|
56
|
+
} as FieldMetadataWrapper;
|
|
57
|
+
|
|
58
|
+
vi.mocked(getSampleField).mockReturnValue(fieldMetadata);
|
|
59
|
+
vi.mocked(getSampleValue).mockReturnValue(["a&b&c", "d&e&f"]);
|
|
60
|
+
expect(getSampleTreePath(vcfMetadata, sample, record, 1)).toStrictEqual(["d", "e", "f"]);
|
|
61
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "VIPP_S");
|
|
62
|
+
expect(getSampleValue).toHaveBeenCalledWith(sample, record, -1, fieldMetadata);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("get, no metadata", () => {
|
|
66
|
+
vi.mocked(getSampleField).mockReturnValue(undefined);
|
|
67
|
+
expect(getSampleTreePath(vcfMetadata, sample, record, 1)).toStrictEqual([]);
|
|
68
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "VIPP_S");
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { HtsFileMetadata } from "@molgenis/vip-report-api";
|
|
3
|
+
import { createVcfDownloadFilename } from "../../src/utils/download.ts";
|
|
4
|
+
|
|
5
|
+
describe("download", () => {
|
|
6
|
+
test("createVcfDownloadFilename with path", () => {
|
|
7
|
+
const metadata = { uri: "/x/y/my.vcf" } as HtsFileMetadata;
|
|
8
|
+
expect(createVcfDownloadFilename(metadata)).toMatch(/^my_report_.*.vcf$/);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("createVcfDownloadFilename without path", () => {
|
|
12
|
+
const metadata = { uri: "my.vcf" } as HtsFileMetadata;
|
|
13
|
+
expect(createVcfDownloadFilename(metadata)).toMatch(/^my_report_.*.vcf$/);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("createVcfDownloadFilename unknown ", () => {
|
|
17
|
+
const metadata = { uri: "" } as HtsFileMetadata;
|
|
18
|
+
expect(createVcfDownloadFilename(metadata)).toMatch(/^unknown_report_.*.vcf$/);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { FieldMetadata } from "@molgenis/vip-report-vcf";
|
|
3
|
+
|
|
4
|
+
import { createInfoSortPath } from "../../../src/utils/query/selector.ts";
|
|
5
|
+
import { createQuery } from "../../../src/utils/query/query.ts";
|
|
6
|
+
import { createQueryVariantType } from "../../../src/utils/query/queryVariantType.ts";
|
|
7
|
+
import { createQuerySample } from "../../../src/utils/query/querySample.ts";
|
|
8
|
+
import { createQueryFilters } from "../../../src/utils/query/queryFilter.ts";
|
|
9
|
+
import { Query } from "@molgenis/vip-report-api";
|
|
10
|
+
import { Config, ConfigFilters, ConfigVariants, ConfigVip, ConfigVipParams } from "../../../src/types/config";
|
|
11
|
+
import { SampleContainer } from "../../../src/utils/api.ts";
|
|
12
|
+
import { VariantType } from "../../../src/utils/variantType.ts";
|
|
13
|
+
import { ConfigFilterFixed } from "../../../src/types/configFilter";
|
|
14
|
+
|
|
15
|
+
describe("query", () => {
|
|
16
|
+
vi.mock(import("../../../src/utils/query/queryFilter.ts"));
|
|
17
|
+
vi.mock(import("../../../src/utils/query/queryVariantType.ts"));
|
|
18
|
+
vi.mock(import("../../../src/utils/query/querySample.ts"));
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
vi.resetAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("createQuery", () => {
|
|
25
|
+
const configFilters: ConfigFilters = [{ type: "fixed", id: "chrom" } as ConfigFilterFixed];
|
|
26
|
+
const configVip = { params: {} as ConfigVipParams } as ConfigVip;
|
|
27
|
+
const config: Config = { vip: configVip, variants: { filters: configFilters } as ConfigVariants } as Config;
|
|
28
|
+
const variantType = { id: "snv" } as VariantType;
|
|
29
|
+
const sample = { item: { id: 2 } } as SampleContainer;
|
|
30
|
+
const filterValues = { chrom: ["chr1"] };
|
|
31
|
+
|
|
32
|
+
test("variant type, sample and filters", () => {
|
|
33
|
+
const queryVariantType: Query = { selector: "a", operator: "==", args: "b" };
|
|
34
|
+
const querySample: Query = { selector: "c", operator: "==", args: "d" };
|
|
35
|
+
const queryFilters: Query = { selector: "e", operator: "==", args: "f" };
|
|
36
|
+
vi.mocked(createQueryVariantType).mockReturnValue(queryVariantType);
|
|
37
|
+
vi.mocked(createQuerySample).mockReturnValue(querySample);
|
|
38
|
+
vi.mocked(createQueryFilters).mockReturnValue(queryFilters);
|
|
39
|
+
|
|
40
|
+
expect(createQuery(config, variantType, sample, filterValues)).toStrictEqual({
|
|
41
|
+
args: [
|
|
42
|
+
{ selector: "a", operator: "==", args: "b" },
|
|
43
|
+
{ selector: "c", operator: "==", args: "d" },
|
|
44
|
+
{ selector: "e", operator: "==", args: "f" },
|
|
45
|
+
],
|
|
46
|
+
operator: "and",
|
|
47
|
+
});
|
|
48
|
+
expect(createQueryVariantType).toHaveBeenCalledWith(variantType);
|
|
49
|
+
expect(createQuerySample).toHaveBeenCalledWith(configVip, sample);
|
|
50
|
+
expect(createQueryFilters).toHaveBeenCalledWith(configFilters, filterValues);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("sample", () => {
|
|
54
|
+
const querySample: Query = { selector: "c", operator: "==", args: "d" };
|
|
55
|
+
vi.mocked(createQueryVariantType).mockReturnValue(null);
|
|
56
|
+
vi.mocked(createQuerySample).mockReturnValue(querySample);
|
|
57
|
+
vi.mocked(createQueryFilters).mockReturnValue(null);
|
|
58
|
+
|
|
59
|
+
expect(createQuery(config, variantType, sample, filterValues)).toStrictEqual(querySample);
|
|
60
|
+
expect(createQueryVariantType).toHaveBeenCalledWith(variantType);
|
|
61
|
+
expect(createQuerySample).toHaveBeenCalledWith(configVip, sample);
|
|
62
|
+
expect(createQueryFilters).toHaveBeenCalledWith(configFilters, filterValues);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("variant type=null, sample=null and filters=null", () => {
|
|
66
|
+
const variantType = { id: "all" } as VariantType;
|
|
67
|
+
vi.mocked(createQueryVariantType).mockReturnValue(null);
|
|
68
|
+
vi.mocked(createQueryFilters).mockReturnValue(null);
|
|
69
|
+
|
|
70
|
+
expect(createQuery(config, variantType, null, filterValues)).toStrictEqual(null);
|
|
71
|
+
expect(createQueryVariantType).toHaveBeenCalledWith(variantType);
|
|
72
|
+
expect(createQueryFilters).toHaveBeenCalledWith(configFilters, filterValues);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("infoSortPath", () => {
|
|
77
|
+
const fieldMetaCsq: FieldMetadata = {
|
|
78
|
+
id: "CSQ",
|
|
79
|
+
number: { type: "NUMBER" },
|
|
80
|
+
type: "STRING",
|
|
81
|
+
};
|
|
82
|
+
expect(createInfoSortPath(fieldMetaCsq)).toStrictEqual(["n", "CSQ"]);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
createQueryFilterClosedInterval,
|
|
4
|
+
createQueryFilterClosedIntervalOutside,
|
|
5
|
+
createQueryFilters,
|
|
6
|
+
createQueryFilterString,
|
|
7
|
+
} from "../../../src/utils/query/queryFilter.ts";
|
|
8
|
+
import { Query, Selector } from "@molgenis/vip-report-api";
|
|
9
|
+
import { createQueryFilterComposed } from "../../../src/utils/query/queryFilterComposed.ts";
|
|
10
|
+
import { ConfigFilterComposed } from "../../../src/types/configFilterComposed";
|
|
11
|
+
import {
|
|
12
|
+
ConfigFilterField,
|
|
13
|
+
ConfigFilterFixed,
|
|
14
|
+
ConfigFilterFormat,
|
|
15
|
+
FilterValueString,
|
|
16
|
+
} from "../../../src/types/configFilter";
|
|
17
|
+
import { createQueryFilterFixed } from "../../../src/utils/query/queryFilterFixed.ts";
|
|
18
|
+
import { createQueryFilterField } from "../../../src/utils/query/queryFilterField.ts";
|
|
19
|
+
|
|
20
|
+
describe("query filters", () => {
|
|
21
|
+
vi.mock(import("../../../src/utils/query/queryFilterComposed.ts"));
|
|
22
|
+
vi.mock(import("../../../src/utils/query/queryFilterField.ts"));
|
|
23
|
+
vi.mock(import("../../../src/utils/query/queryFilterFixed.ts"));
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
vi.resetAllMocks();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("createQueryFilters", () => {
|
|
30
|
+
const query: Query = { selector: "x", operator: "==", args: "y" };
|
|
31
|
+
|
|
32
|
+
test("composed", () => {
|
|
33
|
+
const config0 = { type: "composed", id: "c0" } as ConfigFilterComposed;
|
|
34
|
+
const config1 = { type: "composed", id: "c1" } as ConfigFilterComposed;
|
|
35
|
+
const value0 = ["my_value"];
|
|
36
|
+
const filterValues = { c0: value0 };
|
|
37
|
+
vi.mocked(createQueryFilterComposed).mockReturnValue(query);
|
|
38
|
+
expect(createQueryFilters([config0, config1], filterValues)).toStrictEqual(query);
|
|
39
|
+
expect(createQueryFilterComposed).toHaveBeenCalledWith(config0, value0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("fixed", () => {
|
|
43
|
+
const config = { type: "fixed", id: "chrom" } as ConfigFilterFixed;
|
|
44
|
+
const value = ["chr1"];
|
|
45
|
+
const filterValues = { chrom: value };
|
|
46
|
+
vi.mocked(createQueryFilterFixed).mockReturnValue(query);
|
|
47
|
+
expect(createQueryFilters([config], filterValues)).toStrictEqual(query);
|
|
48
|
+
expect(createQueryFilterFixed).toHaveBeenCalledWith(config, value);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("genotype", () => {
|
|
52
|
+
const config = { type: "genotype", id: "f" } as ConfigFilterFormat;
|
|
53
|
+
const value = ["x"];
|
|
54
|
+
const filterValues = { f: value };
|
|
55
|
+
vi.mocked(createQueryFilterField).mockReturnValue(query);
|
|
56
|
+
expect(createQueryFilters([config], filterValues)).toStrictEqual(query);
|
|
57
|
+
expect(createQueryFilterField).toHaveBeenCalledWith(config, value);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("info", () => {
|
|
61
|
+
const config = { type: "info", id: "f" } as ConfigFilterField;
|
|
62
|
+
const value = ["x"];
|
|
63
|
+
const filterValues = { f: value };
|
|
64
|
+
vi.mocked(createQueryFilterField).mockReturnValue(query);
|
|
65
|
+
expect(createQueryFilters([config], filterValues)).toStrictEqual(query);
|
|
66
|
+
expect(createQueryFilterField).toHaveBeenCalledWith(config, value);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("mixed", () => {
|
|
70
|
+
const query0: Query = query;
|
|
71
|
+
const query1: Query = { selector: "y", operator: "==", args: "z" };
|
|
72
|
+
|
|
73
|
+
const config0 = { type: "composed", id: "c0" } as ConfigFilterComposed;
|
|
74
|
+
const config1 = { type: "fixed", id: "chrom" } as ConfigFilterComposed;
|
|
75
|
+
const value0 = ["my_value"];
|
|
76
|
+
const value1 = ["chr1"];
|
|
77
|
+
const filterValues = { c0: value0, chrom: value1 };
|
|
78
|
+
vi.mocked(createQueryFilterComposed).mockReturnValue(query0);
|
|
79
|
+
vi.mocked(createQueryFilterFixed).mockReturnValue(query1);
|
|
80
|
+
expect(createQueryFilters([config0, config1], filterValues)).toStrictEqual({
|
|
81
|
+
args: [query0, query1],
|
|
82
|
+
operator: "and",
|
|
83
|
+
});
|
|
84
|
+
expect(createQueryFilterComposed).toHaveBeenCalledWith(config0, value0);
|
|
85
|
+
expect(createQueryFilterFixed).toHaveBeenCalledWith(config1, value1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("return null", () => {
|
|
89
|
+
const config0 = { type: "composed", id: "c0" } as ConfigFilterComposed;
|
|
90
|
+
const filterValues = {};
|
|
91
|
+
expect(createQueryFilters([config0], filterValues)).toStrictEqual(null);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("createQueryFilterClosedInterval", () => {
|
|
96
|
+
const selector: Selector = ["x"];
|
|
97
|
+
|
|
98
|
+
test("left", () => {
|
|
99
|
+
expect(createQueryFilterClosedInterval(selector, { left: 1, right: undefined })).toStrictEqual({
|
|
100
|
+
selector: ["x"],
|
|
101
|
+
operator: ">=",
|
|
102
|
+
args: 1,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("right", () => {
|
|
107
|
+
expect(createQueryFilterClosedInterval(selector, { left: undefined, right: 2 })).toStrictEqual({
|
|
108
|
+
selector: ["x"],
|
|
109
|
+
operator: "<=",
|
|
110
|
+
args: 2,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("left and right", () => {
|
|
115
|
+
expect(createQueryFilterClosedInterval(selector, { left: 1, right: 2 })).toStrictEqual({
|
|
116
|
+
args: [
|
|
117
|
+
{ selector: ["x"], operator: ">=", args: 1 },
|
|
118
|
+
{ selector: ["x"], operator: "<=", args: 2 },
|
|
119
|
+
],
|
|
120
|
+
operator: "and",
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("left=undefined and right=undefined", () => {
|
|
125
|
+
expect(() =>
|
|
126
|
+
createQueryFilterClosedInterval(selector, {
|
|
127
|
+
left: undefined,
|
|
128
|
+
right: undefined,
|
|
129
|
+
}),
|
|
130
|
+
).toThrow();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe("createQueryFilterClosedIntervalOutside", () => {
|
|
135
|
+
const selector: Selector = ["x"];
|
|
136
|
+
|
|
137
|
+
test("left", () => {
|
|
138
|
+
expect(createQueryFilterClosedIntervalOutside(selector, { left: 1, right: undefined })).toStrictEqual({
|
|
139
|
+
selector: ["x"],
|
|
140
|
+
operator: "<",
|
|
141
|
+
args: 1,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("right", () => {
|
|
146
|
+
expect(createQueryFilterClosedIntervalOutside(selector, { left: undefined, right: 2 })).toStrictEqual({
|
|
147
|
+
selector: ["x"],
|
|
148
|
+
operator: ">",
|
|
149
|
+
args: 2,
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("left and right", () => {
|
|
154
|
+
expect(createQueryFilterClosedIntervalOutside(selector, { left: 1, right: 2 })).toStrictEqual({
|
|
155
|
+
args: [
|
|
156
|
+
{ selector: ["x"], operator: "<", args: 1 },
|
|
157
|
+
{ selector: ["x"], operator: ">", args: 2 },
|
|
158
|
+
],
|
|
159
|
+
operator: "or",
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("left=undefined and right=undefined", () => {
|
|
164
|
+
expect(() =>
|
|
165
|
+
createQueryFilterClosedIntervalOutside(selector, {
|
|
166
|
+
left: undefined,
|
|
167
|
+
right: undefined,
|
|
168
|
+
}),
|
|
169
|
+
).toThrow();
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe("createQueryFilterString", () => {
|
|
174
|
+
const selector: Selector = ["x"];
|
|
175
|
+
|
|
176
|
+
test("multi_value=false nested_value=false args=single", () => {
|
|
177
|
+
const value: FilterValueString = ["y"];
|
|
178
|
+
expect(createQueryFilterString(selector, value, false, false)).toStrictEqual({
|
|
179
|
+
selector: ["x"],
|
|
180
|
+
operator: "in",
|
|
181
|
+
args: ["y"],
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("multi_value=false nested_value=false args=multi", () => {
|
|
186
|
+
const value: FilterValueString = ["y", "z"];
|
|
187
|
+
expect(createQueryFilterString(selector, value, false, false)).toStrictEqual({
|
|
188
|
+
selector: ["x"],
|
|
189
|
+
operator: "in",
|
|
190
|
+
args: ["y", "z"],
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("multi_value=true nested_value=false args=single", () => {
|
|
195
|
+
const value: FilterValueString = ["y"];
|
|
196
|
+
expect(createQueryFilterString(selector, value, true, false)).toStrictEqual({
|
|
197
|
+
selector: ["x"],
|
|
198
|
+
operator: "has_any",
|
|
199
|
+
args: ["y"],
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test("multi_value=false nested_value=true args=single", () => {
|
|
204
|
+
const value: FilterValueString = ["y"];
|
|
205
|
+
expect(createQueryFilterString(selector, value, false, true)).toStrictEqual({
|
|
206
|
+
selector: ["x"],
|
|
207
|
+
operator: "has_any",
|
|
208
|
+
args: ["y"],
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("multi_value=true nested_value=true args=single", () => {
|
|
213
|
+
const value: FilterValueString = ["y"];
|
|
214
|
+
expect(createQueryFilterString(selector, value, true, true)).toStrictEqual({
|
|
215
|
+
selector: ["x"],
|
|
216
|
+
operator: "any_has_any",
|
|
217
|
+
args: ["y"],
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe("categorical select null", () => {
|
|
222
|
+
test("categorical __null", () => {
|
|
223
|
+
const value: FilterValueString = ["__null"];
|
|
224
|
+
|
|
225
|
+
expect(createQueryFilterString(selector, value, false, false)).toStrictEqual({
|
|
226
|
+
selector: ["x"],
|
|
227
|
+
operator: "in",
|
|
228
|
+
args: [null],
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("categorical category and __null", () => {
|
|
233
|
+
const value: FilterValueString = ["c0", "__null"];
|
|
234
|
+
|
|
235
|
+
expect(createQueryFilterString(selector, value, false, false)).toStrictEqual({
|
|
236
|
+
selector: ["x"],
|
|
237
|
+
operator: "in",
|
|
238
|
+
args: ["c0", null],
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|