Skip to content

Commit 779639d

Browse files
committed
Fix inline snapshot
1 parent 5e72319 commit 779639d

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/__tests__/axios-mock.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,24 @@ import {render, fireEvent} from '@testing-library/vue'
44
import Component from './components/Fetch.vue'
55

66
test('mocks an API call when load-greeting is clicked', async () => {
7-
axiosMock.get.mockImplementationOnce(() =>
8-
Promise.resolve({
9-
data: {greeting: 'hello there'},
10-
}),
11-
)
7+
axiosMock.get.mockResolvedValueOnce({
8+
data: {greeting: 'hello there'},
9+
})
1210

1311
const {html, getByText} = render(Component, {props: {url: '/greeting'}})
1412

1513
await fireEvent.click(getByText('Fetch'))
1614

1715
expect(axiosMock.get).toHaveBeenCalledTimes(1)
1816
expect(axiosMock.get).toHaveBeenCalledWith('/greeting')
17+
1918
getByText('hello there')
2019

2120
// You can render component snapshots by using html(). However, bear in mind
2221
// that Snapshot Testing should not be treated as a replacement for regular
2322
// tests.
2423
// More about the topic: https://twitter.com/searls/status/919594505938112512
25-
expect(html()).toMatchInlineSnapshot(`
26-
<div><button>
27-
Fetch
28-
</button> <span>
29-
hello there
30-
</span></div>
31-
`)
24+
expect(html()).toMatchInlineSnapshot(
25+
`<div><button> Fetch </button><span>hello there</span></div>`,
26+
)
3227
})

0 commit comments

Comments
 (0)