Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

177 chore refactor scxa marker geneheatmap enzyme tests with react 17 #178

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions packages/scxa-marker-gene-heatmap/__test__/CalloutAlert.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import React from 'react'
import Enzyme from 'enzyme'
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom' // for matcher like toBeInTheDocument
import renderer from 'react-test-renderer'
import { shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

import CalloutAlert from '../src/CalloutAlert'

Enzyme.configure({ adapter: new Adapter() })

describe(`CalloutAlert`, () => {
describe('CalloutAlert', () => {
const props = {
error: {
description: `A human-readable description of the error, hopefully useful to the user`,
name: `Error name`,
message: `Error message`
description: 'A human-readable description of the error, hopefully useful to the user',
name: 'Error name',
message: 'Error message',
}
}

it(`prints all the relevant error information`, () => {
const wrapper = shallow(<CalloutAlert {...props} />)
expect(wrapper.text()).toMatch(props.error.description)
expect(wrapper.text()).toMatch(props.error.name)
expect(wrapper.text()).toMatch(props.error.message)
it('prints all the relevant error information', () => {
render(<CalloutAlert {...props} />)

expect(screen.getByText((content, element) => {
return content.includes(props.error.description)
})).toBeInTheDocument()

expect(screen.getByText((content, element) => {
return content.includes(props.error.name)
})).toBeInTheDocument()

expect(screen.getByText((content, element) => {
return content.includes(props.error.message)
})).toBeInTheDocument()
})

it(`matches snapshot`, () => {
it('matches snapshot', () => {
const tree = renderer.create(<CalloutAlert {...props} />).toJSON()
expect(tree).toMatchSnapshot()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React from 'react'
import { mount } from 'enzyme'
import { render } from '@testing-library/react'

import LoadingOverlay from '../src/LoadingOverlay'

describe(`LoadingOverlay`, () => {
test(`matches snapshot when shown`, () => {
expect(mount(<LoadingOverlay show={true}/>)).toMatchSnapshot()
describe('LoadingOverlay', () => {
test('matches snapshot when shown', () => {
const { asFragment } = render(<LoadingOverlay show={true} />)
expect(asFragment()).toMatchSnapshot()
})

test(`matches snapshot when hidden`, () => {
expect(mount(<LoadingOverlay show={false}/>)).toMatchSnapshot()
test('matches snapshot when hidden', () => {
const { asFragment } = render(<LoadingOverlay show={false} />)
expect(asFragment()).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -1,163 +1,103 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HeatmapView matches snapshot when heatmap type is celltypes 1`] = `
<HeatmapView
defaultHeatmapHeight={300}
hasDynamicHeight={true}
heatmapRowHeight={20}
heatmapType="celltypes"
host="foo/"
plotWrapperClassName=""
resource="bar"
species="species"
wrapperClassName=""
>
<CalloutAlert
error={
Object {
"description": "There was a problem communicating with the server. Please try again later.",
"message": "fetch is not defined",
"name": "ReferenceError",
}
}
<DocumentFragment>
<div
class="row"
>
<div
className="row"
class="columns large-9 large-centered"
>
<div
className="columns large-9 large-centered"
class="callout alert small"
>
<div
className="callout alert small"
>
<h5>
Oops!
</h5>
<p>
There was a problem communicating with the server. Please try again later.
<br />
If the error persists, in order to help us debug the issue, please copy the URL and this message and send it to us via
<a
href="https://www.ebi.ac.uk/support/gxasc"
>
the EBI Support & Feedback system
</a>
:
</p>
<code>
ReferenceError: fetch is not defined
</code>
</div>
<h5>
Oops!
</h5>
<p>
There was a problem communicating with the server. Please try again later.
<br />
If the error persists, in order to help us debug the issue, please copy the URL and this message and send it to us via
<a
href="https://www.ebi.ac.uk/support/gxasc"
>
the EBI Support & Feedback system
</a>
:
</p>
<code>
ReferenceError: fetch is not defined
</code>
</div>
</div>
</CalloutAlert>
</HeatmapView>
</div>
</DocumentFragment>
`;

exports[`HeatmapView matches snapshot when heatmap type is clusters 1`] = `
<HeatmapView
defaultHeatmapHeight={300}
hasDynamicHeight={true}
heatmapRowHeight={20}
heatmapType="clusters"
host="foo/"
plotWrapperClassName=""
resource="bar"
species="species"
wrapperClassName=""
>
<CalloutAlert
error={
Object {
"description": "There was a problem communicating with the server. Please try again later.",
"message": "fetch is not defined",
"name": "ReferenceError",
}
}
<DocumentFragment>
<div
class="row"
>
<div
className="row"
class="columns large-9 large-centered"
>
<div
className="columns large-9 large-centered"
class="callout alert small"
>
<div
className="callout alert small"
>
<h5>
Oops!
</h5>
<p>
There was a problem communicating with the server. Please try again later.
<br />
If the error persists, in order to help us debug the issue, please copy the URL and this message and send it to us via
<a
href="https://www.ebi.ac.uk/support/gxasc"
>
the EBI Support & Feedback system
</a>
:
</p>
<code>
ReferenceError: fetch is not defined
</code>
</div>
<h5>
Oops!
</h5>
<p>
There was a problem communicating with the server. Please try again later.
<br />
If the error persists, in order to help us debug the issue, please copy the URL and this message and send it to us via
<a
href="https://www.ebi.ac.uk/support/gxasc"
>
the EBI Support & Feedback system
</a>
:
</p>
<code>
ReferenceError: fetch is not defined
</code>
</div>
</div>
</CalloutAlert>
</HeatmapView>
</div>
</DocumentFragment>
`;

exports[`HeatmapView matches snapshot when heatmap type is multiexperimentcelltypes 1`] = `
<HeatmapView
defaultHeatmapHeight={300}
hasDynamicHeight={true}
heatmapRowHeight={20}
heatmapType="multiexperimentcelltypes"
host="foo/"
plotWrapperClassName=""
resource="bar"
species="species"
wrapperClassName=""
>
<CalloutAlert
error={
Object {
"description": "There was a problem communicating with the server. Please try again later.",
"message": "fetch is not defined",
"name": "ReferenceError",
}
}
<DocumentFragment>
<div
class="row"
>
<div
className="row"
class="columns large-9 large-centered"
>
<div
className="columns large-9 large-centered"
class="callout alert small"
>
<div
className="callout alert small"
>
<h5>
Oops!
</h5>
<p>
There was a problem communicating with the server. Please try again later.
<br />
If the error persists, in order to help us debug the issue, please copy the URL and this message and send it to us via
<a
href="https://www.ebi.ac.uk/support/gxasc"
>
the EBI Support & Feedback system
</a>
:
</p>
<code>
ReferenceError: fetch is not defined
</code>
</div>
<h5>
Oops!
</h5>
<p>
There was a problem communicating with the server. Please try again later.
<br />
If the error persists, in order to help us debug the issue, please copy the URL and this message and send it to us via
<a
href="https://www.ebi.ac.uk/support/gxasc"
>
the EBI Support & Feedback system
</a>
:
</p>
<code>
ReferenceError: fetch is not defined
</code>
</div>
</div>
</CalloutAlert>
</HeatmapView>
</div>
</DocumentFragment>
`;
Original file line number Diff line number Diff line change
@@ -1,45 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LoadingOverlay matches snapshot when hidden 1`] = `
<LoadingOverlay
resourcesUrl=""
show={false}
>
<styled.div
show={false}
<DocumentFragment>
<div
class="sc-aXZVg kYawNo"
>
<div
className="sc-bdnylx bqQJZW"
>
<p>
Loading, please wait...
</p>
<img
src="test-file-stub"
/>
</div>
</styled.div>
</LoadingOverlay>
<p>
Loading, please wait...
</p>
<img
src="test-file-stub"
/>
</div>
</DocumentFragment>
`;

exports[`LoadingOverlay matches snapshot when shown 1`] = `
<LoadingOverlay
resourcesUrl=""
show={true}
>
<styled.div
show={true}
<DocumentFragment>
<div
class="sc-aXZVg bGqqkF"
>
<div
className="sc-bdnylx dRCoQz"
>
<p>
Loading, please wait...
</p>
<img
src="test-file-stub"
/>
</div>
</styled.div>
</LoadingOverlay>
<p>
Loading, please wait...
</p>
<img
src="test-file-stub"
/>
</div>
</DocumentFragment>
`;
Loading