Skip to content

Commit

Permalink
test(browser): add TissueExpressionTrack tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyhgrant committed Oct 23, 2024
1 parent 91d7fc7 commit 3c6d5f7
Show file tree
Hide file tree
Showing 4 changed files with 411 additions and 1 deletion.
65 changes: 65 additions & 0 deletions browser/src/GenePage/TissueExpressionTrack.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react'
import renderer from 'react-test-renderer'
import { jest, describe, expect, test } from '@jest/globals'

Check failure on line 3 in browser/src/GenePage/TissueExpressionTrack.spec.tsx

View workflow job for this annotation

GitHub Actions / Checks

'jest' is defined but never used. Allowed unused vars must match /^_/u

import TissueExpressionTrack, { TranscriptWithTissueExpression } from './TissueExpressionTrack'

import { BrowserRouter } from 'react-router-dom'

Check failure on line 7 in browser/src/GenePage/TissueExpressionTrack.spec.tsx

View workflow job for this annotation

GitHub Actions / Checks

'BrowserRouter' is defined but never used. Allowed unused vars must match /^_/u
import { RegionViewerContext } from '@gnomad/region-viewer'

Check failure on line 8 in browser/src/GenePage/TissueExpressionTrack.spec.tsx

View workflow job for this annotation

GitHub Actions / Checks

Could not find a declaration file for module '@gnomad/region-viewer'. '/home/runner/work/gnomad-browser/gnomad-browser/node_modules/.pnpm/@Gnomad+region-viewer@4.0.0/node_modules/@gnomad/region-viewer/lib/cjs/index.js' implicitly has an 'any' type.

import geneFactory from '../__factories__/Gene'

describe('TissueExpressionTrack', () => {
const childProps = {
centerPanelWidth: 500,
isPositionDefined: true,
leftPanelWidth: 100,
// same regions as pext factory regions
regions: [
{
start: 0,
stop: 100,
},
],
rightPanelWidth: 100,
scalePosition: (i: number) => i,
}

test('has no unexpected changes', () => {
const testTranscriptId = 'transcript-1337'
const gene = geneFactory.build({ canonical_transcript_id: testTranscriptId })

const testExons = [
{
feature_type: 'CDS',
start: 10,
stop: 20,
},
{
feature_type: 'CDS',
start: 20,
stop: 30,
},
{
feature_type: 'CDS',
start: 40,
stop: 60,
},
]

const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<TissueExpressionTrack
exons={testExons}
expressionRegions={gene.pext!.regions}
flags={gene.pext!.flags}
transcripts={gene.transcripts as TranscriptWithTissueExpression[]}
preferredTranscriptId={testTranscriptId}
preferredTranscriptDescription={'test-canonical-transcript'}

Check failure on line 58 in browser/src/GenePage/TissueExpressionTrack.spec.tsx

View workflow job for this annotation

GitHub Actions / Checks

Curly braces are unnecessary here
/>
</RegionViewerContext.Provider>
)

expect(tree).toMatchSnapshot()
})
})
284 changes: 284 additions & 0 deletions browser/src/GenePage/__snapshots__/TissueExpressionTrack.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TissueExpressionTrack has no unexpected changes 1`] = `
<div
className="TissueExpressionTrack__Wrapper-sc-1t85ku0-3 iexARk"
>
<div
className="TissueExpressionTrack__InnerWrapper-sc-1t85ku0-4 jdaBoy"
>
<div
className="Track__OuterWrapper-sc-1sdyh2h-0 bBMGlf"
>
<div
className="Track__InnerWrapper-sc-1sdyh2h-1 cEOGGC"
>
<div
className="Track__SidePanel-sc-1sdyh2h-3 iSYzDq"
style={
{
"width": 100,
}
}
>
<div
className="TissueExpressionTrack__TissueName-sc-1t85ku0-5 duaCFM"
style={
{
"fontSize": "12px",
"justifyContent": "space-between",
"marginRight": 0,
}
}
>
<button
className="Button__BaseButton-sc-1eobygi-0 Button-sc-1eobygi-1 indcWT"
disabled={false}
onClick={[Function]}
style={
{
"height": "auto",
"paddingLeft": "0.25em",
"paddingRight": "0.25em",
"width": "70px",
}
}
type="button"
>
Show
tissues
</button>
<span
style={
{
"marginRight": "0.25em",
"textAlign": "right",
}
}
>
Mean pext
</span>
<button
className="InfoButton__Button-sc-13t5e82-0 gxsoyZ"
onClick={[Function]}
style={
{
"display": "inline",
}
}
type="button"
>
<img
alt=""
aria-hidden="true"
src="test-file-stub"
/>
<span
style={
{
"border": "0",
"clip": "rect(0 0 0 0)",
"height": "1px",
"margin": "-1px",
"overflow": "hidden",
"padding": "0",
"position": "absolute",
"whiteSpace": "nowrap",
"width": "1px",
}
}
>
More information
</span>
</button>
</div>
</div>
<div
className="Track__CenterPanel-sc-1sdyh2h-4 iAyrrk"
style={
{
"width": 500,
}
}
>
<div
className="TissueExpressionTrack__PlotWrapper-sc-1t85ku0-6 jiFpkp"
>
<svg
height={20}
width={500}
>
<g
className="TissueExpressionTrack__RegionHoverTarget-sc-1t85ku0-2 fjPGDI"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
className="TissueExpressionTrack__RegionBackground-sc-1t85ku0-0 laWhbX"
height={20}
width={10}
x={10}
y={0}
/>
<rect
className="TissueExpressionTrack__Region-sc-1t85ku0-1 cckHbF"
fill="#428bca"
height={0}
stroke="#428bca"
width={10}
x={10}
y={20}
/>
</g>
<g
className="TissueExpressionTrack__RegionHoverTarget-sc-1t85ku0-2 fjPGDI"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
className="TissueExpressionTrack__RegionBackground-sc-1t85ku0-0 laWhbX"
height={20}
width={10}
x={20}
y={0}
/>
<rect
className="TissueExpressionTrack__Region-sc-1t85ku0-1 cckHbF"
fill="#428bca"
height={6}
stroke="#428bca"
width={10}
x={20}
y={14}
/>
</g>
<g
className="TissueExpressionTrack__RegionHoverTarget-sc-1t85ku0-2 fjPGDI"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
className="TissueExpressionTrack__RegionBackground-sc-1t85ku0-0 laWhbX"
height={20}
width={20}
x={40}
y={0}
/>
<rect
className="TissueExpressionTrack__Region-sc-1t85ku0-1 cckHbF"
fill="#428bca"
height={14}
stroke="#428bca"
width={20}
x={40}
y={6}
/>
</g>
</svg>
<svg
height={1}
width={500}
>
<line
stroke="rgba(0,0,0,0)"
strokeWidth={1}
x1={0}
x2={500}
y1={0.5}
y2={0.5}
/>
<rect
fill="#000"
height={1}
stroke="none"
width={10}
x={10}
y={0}
/>
<rect
fill="#000"
height={1}
stroke="none"
width={10}
x={20}
y={0}
/>
<rect
fill="#000"
height={1}
stroke="none"
width={20}
x={40}
y={0}
/>
</svg>
</div>
</div>
<div
className="Track__SidePanel-sc-1sdyh2h-3 iSYzDq"
style={
{
"width": 100,
}
}
>
<svg
height={31}
width={100}
>
<line
stroke="#333"
x1={0}
x2={0}
y1={6}
y2={25}
/>
<g
transform="translate(0, 6)"
>
<line
stroke="#333"
x1={0}
x2={3}
y1={0}
y2={0}
/>
<text
dy="0.45em"
fill="#000"
fontSize={10}
textAnchor="start"
x={5}
y={0}
>
1
</text>
</g>
<g
transform="translate(0, 24)"
>
<line
stroke="#333"
x1={0}
x2={3}
y1={0}
y2={0}
/>
<text
dy="0.1em"
fill="#000"
fontSize={10}
textAnchor="start"
x={5}
y={0}
>
0
</text>
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
`;
6 changes: 5 additions & 1 deletion browser/src/__factories__/Gene.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Factory } from 'fishery'
import { Gene, GeneMetadata } from '../GenePage/GenePage'
import { Gene, GeneMetadata, Pext } from '../GenePage/GenePage'

Check failure on line 2 in browser/src/__factories__/Gene.ts

View workflow job for this annotation

GitHub Actions / Checks

'Pext' is defined but never used. Allowed unused vars must match /^_/u
import { Transcript } from '../TranscriptPage/TranscriptPage'
import transcriptFactory from './Transcript'
import {
HeterozygousVariantCooccurrenceCountsPerSeverityAndAfFactory,
HomozygousVariantCooccurrenceCountsPerSeverityAndAfFactory,
} from './VariantCooccurrenceCountsPerSeverityAndAf'
import { pextFactory } from './TissueExpression'

const geneFactory = Factory.define<Gene>(({ params, associations }) => {
const {
Expand Down Expand Up @@ -50,6 +51,8 @@ const geneFactory = Factory.define<Gene>(({ params, associations }) => {
]
: []

const pext = pextFactory.build()

return {
gene_id,
gene_version,
Expand All @@ -69,6 +72,7 @@ const geneFactory = Factory.define<Gene>(({ params, associations }) => {
structural_variants,
clinvar_variants,
copy_number_variants,
pext,
}
})

Expand Down
Loading

0 comments on commit 3c6d5f7

Please sign in to comment.