@@ -3,7 +3,7 @@ import React from 'react'
33import { render , waitFor , screen , fireEvent } from '@testing-library/react'
44import '@testing-library/jest-dom/extend-expect'
55
6- import StudyGeneField , { getIsInvalidQuery } from 'components/explore/StudyGeneField'
6+ import StudyGeneField , { getIsInvalidQuery , getIsEligibleForPathwayExplore } from 'components/explore/StudyGeneField'
77import * as UserProvider from '~/providers/UserProvider'
88import { interestingNames , interactionCacheCsn1s1 } from './../visualization/pathway.test-data'
99
@@ -67,7 +67,10 @@ describe('Search query display text', () => {
6767 } )
6868
6969 const { container } = render (
70- < StudyGeneField queries = { [ ] } queryFn = { ( ) => { } } allGenes = { [ 'PTEN' ] } speciesList = { [ 'Homo sapiens' ] } />
70+ < StudyGeneField
71+ queries = { [ ] } queryFn = { ( ) => { } } allGenes = { [ 'PTEN' ] }
72+ speciesList = { [ 'Homo sapiens' ] } selectedAnnotation = { { type : 'group' } }
73+ />
7174 )
7275
7376 // Find the input field inside react-select
@@ -97,5 +100,26 @@ describe('Search query display text', () => {
97100 const pathwayIsInvalid = getIsInvalidQuery ( 'CSN1S1' , [ 'PTEN' ] )
98101 expect ( pathwayIsInvalid ) . toBe ( false )
99102 } )
103+
104+ it ( 'determines if view is eligible for pathway exploration' , async ( ) => {
105+ jest
106+ . spyOn ( UserProvider , 'getFeatureFlagsWithDefaults' )
107+ . mockReturnValue ( {
108+ show_pathway_expression : true
109+ } )
110+
111+ // Confirm mouse is not eligible
112+ const isMouseEligible = getIsEligibleForPathwayExplore ( [ 'Mus musculus' ] , { type : 'group' } )
113+ expect ( isMouseEligible ) . toBe ( false )
114+
115+ // Confirm numeric annotation is not eligible
116+ const isNumericAnnotationEligible = getIsEligibleForPathwayExplore ( [ 'Homo sapiens' ] , { type : 'numeric' } )
117+ expect ( isNumericAnnotationEligible ) . toBe ( false )
118+
119+ // Confirm group annotation for human is eligible
120+ const isHumanGroupAnnotationEligible = getIsEligibleForPathwayExplore ( [ 'Homo sapiens' ] , { type : 'group' } )
121+ expect ( isHumanGroupAnnotationEligible ) . toBe ( true )
122+ } )
123+
100124} )
101125
0 commit comments