Skip to content

Commit 237efeb

Browse files
author
Luke Bowerman
authored
test: Deprecate Dialog layout snapshot tests (#1897)
1 parent bacb301 commit 237efeb

File tree

6 files changed

+31
-520
lines changed

6 files changed

+31
-520
lines changed

packages/components/src/Dialog/Layout/DialogContent.test.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@
2424
2525
*/
2626

27-
import 'jest-styled-components'
2827
import React from 'react'
29-
import { assertSnapshot } from '@looker/components-test-utils'
28+
import { renderWithTheme } from '@looker/components-test-utils'
29+
import { screen } from '@testing-library/react'
3030
import { DialogContent } from './DialogContent'
3131

3232
describe('DialogContent', () => {
33-
test('Snapshot', () => {
34-
assertSnapshot(<DialogContent>Stuff</DialogContent>)
33+
test('basic', () => {
34+
renderWithTheme(<DialogContent>Stuff</DialogContent>)
35+
expect(screen.getByText('Stuff')).toBeInTheDocument()
3536
})
3637

37-
test('Snapshot - No overflow', () => {
38-
assertSnapshot(
39-
<DialogContent>
40-
<div style={{ height: '4rem' }}>Stuff</div>
38+
test('hasHeader & hasFooter', () => {
39+
renderWithTheme(
40+
<DialogContent hasHeader hasFooter>
41+
Stuff
4142
</DialogContent>
4243
)
44+
expect(screen.getByText('Stuff')).toBeInTheDocument()
4345
})
4446
})

packages/components/src/Dialog/Layout/DialogFooter.test.tsx

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,27 @@
2424
2525
*/
2626

27-
import 'jest-styled-components'
2827
import React from 'react'
29-
import { assertSnapshot } from '@looker/components-test-utils'
30-
import { DialogContext } from '../DialogContext'
28+
import { renderWithTheme } from '@looker/components-test-utils'
29+
import { screen } from '@testing-library/react'
3130
import { DialogFooter } from './DialogFooter'
3231

33-
test('DialogFooter with Button', () => {
34-
assertSnapshot(
35-
<DialogFooter>
36-
<button>Cancel</button>
37-
</DialogFooter>
38-
)
39-
})
40-
41-
test('DialogFooter with DialogContext', () => {
42-
assertSnapshot(
43-
<DialogContext.Consumer>
44-
{({ closeModal }) => (
45-
<DialogFooter>
46-
<button onClick={closeModal}>Cancel</button>
47-
<button
48-
onClick={() => {
49-
alert('Doing things...')
50-
closeModal()
51-
}}
52-
>
53-
Yes, Delete "Stuff"
54-
</button>
55-
</DialogFooter>
56-
)}
57-
</DialogContext.Consumer>
58-
)
32+
describe('DialogFooter', () => {
33+
test('basic', () => {
34+
renderWithTheme(
35+
<DialogFooter>
36+
<button>Cancel</button>
37+
</DialogFooter>
38+
)
39+
expect(screen.getByRole('button')).toBeInTheDocument()
40+
})
41+
42+
test('secondary', () => {
43+
renderWithTheme(
44+
<DialogFooter secondary={<button>Nevermind</button>}>
45+
<button>Cancel</button>
46+
</DialogFooter>
47+
)
48+
expect(screen.getByText('Nevermind')).toBeInTheDocument()
49+
})
5950
})

packages/components/src/Dialog/Layout/DialogHeader.test.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,11 @@
2626

2727
import 'jest-styled-components'
2828
import React from 'react'
29-
import { assertSnapshot, renderWithTheme } from '@looker/components-test-utils'
29+
import { renderWithTheme } from '@looker/components-test-utils'
3030
import { screen } from '@testing-library/react'
3131
import { DialogHeader } from './DialogHeader'
3232

3333
describe('DialogHeader', () => {
34-
test('Snapshot', () => {
35-
assertSnapshot(
36-
<DialogHeader id="test-DialogHeader">
37-
The Heading for a Dialog
38-
</DialogHeader>
39-
)
40-
})
41-
4234
test('Passes through DOM props', async () => {
4335
renderWithTheme(
4436
<DialogHeader aria-label="ARIA label">Heading</DialogHeader>

packages/components/src/Dialog/Layout/__snapshots__/DialogContent.test.tsx.snap

Lines changed: 0 additions & 89 deletions
This file was deleted.

packages/components/src/Dialog/Layout/__snapshots__/DialogFooter.test.tsx.snap

Lines changed: 0 additions & 180 deletions
This file was deleted.

0 commit comments

Comments
 (0)