-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(browser): add TissueExpressionTrack tests
- Loading branch information
1 parent
91d7fc7
commit 3c6d5f7
Showing
4 changed files
with
411 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
||
import TissueExpressionTrack, { TranscriptWithTissueExpression } from './TissueExpressionTrack' | ||
|
||
import { BrowserRouter } from 'react-router-dom' | ||
import { RegionViewerContext } from '@gnomad/region-viewer' | ||
Check failure on line 8 in browser/src/GenePage/TissueExpressionTrack.spec.tsx GitHub Actions / Checks
|
||
|
||
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'} | ||
/> | ||
</RegionViewerContext.Provider> | ||
) | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) | ||
}) |
284 changes: 284 additions & 0 deletions
284
browser/src/GenePage/__snapshots__/TissueExpressionTrack.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.