From edfdad8fef05b892d795db4a63b35b726ce59b89 Mon Sep 17 00:00:00 2001 From: gromdimon Date: Fri, 22 Sep 2023 15:53:08 +0200 Subject: [PATCH] more tests --- .../components/__tests__/AcmgRating.spec.ts | 49 +++++-------------- .../views/__tests__/VariantDetailView.spec.ts | 27 ++++++---- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/frontend/src/components/__tests__/AcmgRating.spec.ts b/frontend/src/components/__tests__/AcmgRating.spec.ts index 7b6a7faf..10f23322 100644 --- a/frontend/src/components/__tests__/AcmgRating.spec.ts +++ b/frontend/src/components/__tests__/AcmgRating.spec.ts @@ -11,6 +11,12 @@ import { createVuetify } from 'vuetify' import * as components from 'vuetify/components' import * as directives from 'vuetify/directives' +import { + MultiSourceAcmgCriteriaState, + StateSource, + AcmgCriteria, + Presence +} from '@/components/ACMG/acmgSeqVar' import AcmgRating from '@/components/VariantDetails/AcmgRating.vue' const vuetify = createVuetify({ @@ -35,37 +41,6 @@ const smallVariantInfo = { hgnc_id: 'HGNC:1100' } -export const AcmgRatingInfo = { - pvs1: true, - ps1: false, - ps2: false, - ps3: false, - ps4: false, - pm1: false, - pm2: false, - pm3: false, - pm4: false, - pm5: false, - pm6: true, - pp1: false, - pp2: false, - pp3: false, - pp4: false, - pp5: false, - ba1: false, - bs1: false, - bs2: false, - bs3: true, - bs4: false, - bp1: false, - bp2: false, - bp3: false, - bp4: false, - bp5: true, - bp6: false, - bp7: false -} - const makeWrapper = () => { const pinia = createTestingPinia({ createSpy: vi.fn() }) const store = useVariantAcmgRatingStore(pinia) @@ -73,13 +48,15 @@ const makeWrapper = () => { const mockRetrieveAcmgRating = vi.fn().mockImplementation(async () => { store.storeState = StoreState.Active store.smallVariant = JSON.parse(JSON.stringify(smallVariantInfo)) - store.acmgRatingComputed = JSON.parse(JSON.stringify(AcmgRatingInfo)) + store.acmgRating = new MultiSourceAcmgCriteriaState() + store.acmgRating.setPresence(StateSource.InterVar, AcmgCriteria.Pvs1, Presence.Present) }) - store.retrieveAcmgRating = mockRetrieveAcmgRating + store.setAcmgRating = mockRetrieveAcmgRating store.storeState = StoreState.Active store.smallVariant = JSON.parse(JSON.stringify(smallVariantInfo)) - store.acmgRatingComputed = JSON.parse(JSON.stringify(AcmgRatingInfo)) + store.acmgRating = new MultiSourceAcmgCriteriaState() + store.acmgRating.setPresence(StateSource.InterVar, AcmgCriteria.Pvs1, Presence.Present) return mount(AcmgRating, { props: { @@ -101,7 +78,7 @@ describe.concurrent('AcmgRating', async () => { expect(wrapper.text()).toContain('Benign') const switchers = wrapper.findAll('.v-switch') - expect(switchers.length).toBe(28) + expect(switchers.length).toBe(29) }) it('should correctly update the AcmgRating info', async () => { @@ -114,6 +91,6 @@ describe.concurrent('AcmgRating', async () => { expect(wrapper.text()).toContain('Benign') const updatedSwitchers = wrapper.findAll('.v-switch') - expect(updatedSwitchers.length).toBe(28) + expect(updatedSwitchers.length).toBe(29) }) }) diff --git a/frontend/src/views/__tests__/VariantDetailView.spec.ts b/frontend/src/views/__tests__/VariantDetailView.spec.ts index e7aa71e0..6e337e42 100644 --- a/frontend/src/views/__tests__/VariantDetailView.spec.ts +++ b/frontend/src/views/__tests__/VariantDetailView.spec.ts @@ -14,10 +14,15 @@ import * as directives from 'vuetify/directives' import VariantDetailView from '../VariantDetailView.vue' import { StoreState } from '@/stores/misc' -import { AcmgRatingInfo } from '@/components/__tests__/AcmgRating.spec' import * as BRCA1GeneInfo from '@/assets/__tests__/BRCA1GeneInfo.json' import * as BRCA1VariantInfo from '@/assets/__tests__/BRCA1VariantInfo.json' import * as BRCA1TxInfo from '@/assets/__tests__/BRCA1TxInfo.json' +import { + MultiSourceAcmgCriteriaState, + StateSource, + AcmgCriteria, + Presence +} from '@/components/ACMG/acmgSeqVar' import HeaderDetailPage from '@/components/HeaderDetailPage.vue' import SearchBar from '@/components/SearchBar.vue' import VariantGene from '@/components/VariantDetails/VariantGene.vue' @@ -57,8 +62,7 @@ const variantData = { smallVariant: smallVariantInfo, varAnnos: JSON.parse(JSON.stringify(BRCA1VariantInfo)).result, geneInfo: JSON.parse(JSON.stringify(BRCA1GeneInfo)).genes['HGNC:1100'], - txCsq: JSON.parse(JSON.stringify(BRCA1TxInfo)).result, - acmgRating: AcmgRatingInfo + txCsq: JSON.parse(JSON.stringify(BRCA1TxInfo)).result } const makeWrapper = () => { @@ -78,9 +82,14 @@ const makeWrapper = () => { const mockRetrieveAcmgRating = vi.fn().mockImplementation(async () => { variantAcmgStore.storeState = StoreState.Active variantAcmgStore.smallVariant = JSON.parse(JSON.stringify(smallVariantInfo)) - variantAcmgStore.acmgRating = JSON.parse(JSON.stringify(variantData.acmgRating)) + variantAcmgStore.acmgRating = new MultiSourceAcmgCriteriaState() + variantAcmgStore.acmgRating.setPresence( + StateSource.InterVar, + AcmgCriteria.Pvs1, + Presence.Present + ) }) - variantAcmgStore.retrieveAcmgRating = mockRetrieveAcmgRating + variantAcmgStore.setAcmgRating = mockRetrieveAcmgRating // Initial load variantInfoStore.storeState = StoreState.Active @@ -91,7 +100,7 @@ const makeWrapper = () => { variantInfoStore.txCsq = JSON.parse(JSON.stringify(variantData.txCsq)) variantAcmgStore.storeState = StoreState.Active variantAcmgStore.smallVariant = JSON.parse(JSON.stringify(smallVariantInfo)) - variantAcmgStore.acmgRating = JSON.parse(JSON.stringify(variantData.acmgRating)) + variantAcmgStore.acmgRating = new MultiSourceAcmgCriteriaState() return mount( { @@ -216,9 +225,9 @@ describe.concurrent('VariantDetailView', async () => { const mockRetrieveAcmgRating = vi.fn().mockImplementation(async () => { variantAcmgStore.storeState = StoreState.Active variantAcmgStore.smallVariant = JSON.parse(JSON.stringify(smallVariantInfo)) - variantAcmgStore.acmgRating = JSON.parse(JSON.stringify(variantData.acmgRating)) + variantAcmgStore.acmgRating = new MultiSourceAcmgCriteriaState() }) - variantAcmgStore.retrieveAcmgRating = mockRetrieveAcmgRating + variantAcmgStore.setAcmgRating = mockRetrieveAcmgRating // Initial load variantInfoStore.storeState = StoreState.Active @@ -229,7 +238,7 @@ describe.concurrent('VariantDetailView', async () => { variantInfoStore.txCsq = JSON.parse(JSON.stringify(variantData.txCsq)) variantAcmgStore.storeState = StoreState.Active variantAcmgStore.smallVariant = JSON.parse(JSON.stringify(smallVariantInfo)) - variantAcmgStore.acmgRating = JSON.parse(JSON.stringify(variantData.acmgRating)) + variantAcmgStore.acmgRating = new MultiSourceAcmgCriteriaState() mount( {