-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Uptime] Remove prototype overwrite in unit test #73709
Changes from all commits
ef05965
56fed24
15cfb3b
69628a5
afea632
0ec06b0
97d57a6
3294340
05b0b6b
dd1da2c
c9e4fd6
6501666
c3f5112
0b5f791
959c45e
48f1536
4f57662
aa70db5
5ade268
6a2cc03
fd10c59
c8d188f
f143036
50949ec
f7ba9eb
98bdfe0
2a22f29
a98b048
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,23 @@ | |
*/ | ||
|
||
import React from 'react'; | ||
import DateMath from '@elastic/datemath'; | ||
import { PingHistogramComponent, PingHistogramComponentProps } from './ping_histogram'; | ||
import { renderWithRouter, shallowWithRouter, MountWithReduxProvider } from '../../../lib'; | ||
import moment from 'moment'; | ||
import { render } from '../../../lib/helper/rtl_helpers'; | ||
import { mockDataPlugin, mockMoment, mockMomentTimezone } from '../../../lib/helper/test_helpers'; | ||
|
||
describe('PingHistogram component', () => { | ||
let dateMathSpy: any; | ||
beforeAll(() => { | ||
moment.prototype.fromNow = jest.fn(() => 'a year ago'); | ||
mockMoment(); | ||
mockMomentTimezone(); | ||
mockDataPlugin(); | ||
dateMathSpy = jest.spyOn(DateMath, 'parse'); | ||
dateMathSpy.mockReturnValue(20); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const props: PingHistogramComponentProps = { | ||
|
@@ -48,18 +58,13 @@ describe('PingHistogram component', () => { | |
}, | ||
}; | ||
|
||
it('shallow renders the component without errors', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided this test wasn't worth keeping. It asserted that the Rendering these components doesn't yield SVG or any other method of ensuring the data is rendered by Elastic Charts, but we also should not be testing those capabilities in our repo. |
||
const component = shallowWithRouter(<PingHistogramComponent {...props} />); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the component without errors', () => { | ||
const component = renderWithRouter( | ||
<MountWithReduxProvider> | ||
<PingHistogramComponent {...props} /> | ||
</MountWithReduxProvider> | ||
const { getByLabelText, getByText } = render(<PingHistogramComponent {...props} />); | ||
expect(getByText('Pings over time')); | ||
expect( | ||
getByLabelText( | ||
'Bar Chart showing uptime status over time from 15 minutes ago to 15 minutes ago.' | ||
) | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of running these in each test, do you think we should move these as part of jest setup?
in uptime jest.config.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do this in a follow-up: elastic/uptime#283