mirror of https://github.com/grafana/grafana
Chore: Replace enzyme with RTL (#45434)
parent
5760a18da5
commit
ae8c8a2910
@ -1,33 +1,39 @@ |
|||||||
import React from 'react'; |
import React from 'react'; |
||||||
import { render } from 'enzyme'; |
import { render, screen } from '@testing-library/react'; |
||||||
import { CallToActionCard } from './CallToActionCard'; |
import { CallToActionCard } from './CallToActionCard'; |
||||||
|
import { expect } from '../../../../../public/test/lib/common'; |
||||||
|
|
||||||
describe('CallToActionCard', () => { |
describe('CallToActionCard', () => { |
||||||
describe('rendering', () => { |
describe('rendering', () => { |
||||||
it('when no message and footer provided', () => { |
it('should render callToActionElement', () => { |
||||||
const tree = render(<CallToActionCard callToActionElement={<a href="http://dummy.link">Click me</a>} />); |
render(<CallToActionCard callToActionElement={<a href="http://dummy.link">Click me</a>} />); |
||||||
expect(tree).toMatchSnapshot(); |
expect(screen.getByRole('link', { name: 'Click me' })).toBeInTheDocument(); |
||||||
}); |
}); |
||||||
|
|
||||||
it('when message and no footer provided', () => { |
it('should render message when provided', () => { |
||||||
const tree = render( |
render( |
||||||
<CallToActionCard |
<CallToActionCard message="Click button below" callToActionElement={<a href="http://dummy.link">Click me</a>} /> |
||||||
message="Click button bellow" |
); |
||||||
callToActionElement={<a href="http://dummy.link">Click me</a>} |
expect(screen.getByText('Click button below')).toBeInTheDocument(); |
||||||
/> |
}); |
||||||
|
|
||||||
|
it('should render footer when provided', () => { |
||||||
|
render( |
||||||
|
<CallToActionCard footer="footer content" callToActionElement={<a href="http://dummy.link">Click me</a>} /> |
||||||
); |
); |
||||||
expect(tree).toMatchSnapshot(); |
expect(screen.getByText('footer content')).toBeInTheDocument(); |
||||||
}); |
}); |
||||||
|
|
||||||
it('when message and footer provided', () => { |
it('should render both message and footer when provided', () => { |
||||||
const tree = render( |
render( |
||||||
<CallToActionCard |
<CallToActionCard |
||||||
message="Click button bellow" |
message="Click button below" |
||||||
footer="footer content" |
footer="footer content" |
||||||
callToActionElement={<a href="http://dummy.link">Click me</a>} |
callToActionElement={<a href="http://dummy.link">Click me</a>} |
||||||
/> |
/> |
||||||
); |
); |
||||||
expect(tree).toMatchSnapshot(); |
expect(screen.getByText('Click button below')).toBeInTheDocument(); |
||||||
|
expect(screen.getByText('footer content')).toBeInTheDocument(); |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
|
|||||||
@ -1,52 +0,0 @@ |
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
|
||||||
|
|
||||||
exports[`CallToActionCard rendering when message and footer provided 1`] = ` |
|
||||||
<div |
|
||||||
class="css-xtd6ws-call-to-action-card" |
|
||||||
> |
|
||||||
<div |
|
||||||
class="css-m2iibx" |
|
||||||
> |
|
||||||
Click button bellow |
|
||||||
</div> |
|
||||||
<a |
|
||||||
href="http://dummy.link" |
|
||||||
> |
|
||||||
Click me |
|
||||||
</a> |
|
||||||
<div |
|
||||||
class="css-11lqfaj" |
|
||||||
> |
|
||||||
footer content |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
`; |
|
||||||
|
|
||||||
exports[`CallToActionCard rendering when message and no footer provided 1`] = ` |
|
||||||
<div |
|
||||||
class="css-xtd6ws-call-to-action-card" |
|
||||||
> |
|
||||||
<div |
|
||||||
class="css-m2iibx" |
|
||||||
> |
|
||||||
Click button bellow |
|
||||||
</div> |
|
||||||
<a |
|
||||||
href="http://dummy.link" |
|
||||||
> |
|
||||||
Click me |
|
||||||
</a> |
|
||||||
</div> |
|
||||||
`; |
|
||||||
|
|
||||||
exports[`CallToActionCard rendering when no message and footer provided 1`] = ` |
|
||||||
<div |
|
||||||
class="css-xtd6ws-call-to-action-card" |
|
||||||
> |
|
||||||
<a |
|
||||||
href="http://dummy.link" |
|
||||||
> |
|
||||||
Click me |
|
||||||
</a> |
|
||||||
</div> |
|
||||||
`; |
|
||||||
Loading…
Reference in new issue