File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -4,29 +4,24 @@ import {render, fireEvent} from '@testing-library/vue'
44import Component from './components/Fetch.vue'
55
66test ( '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} )
You can’t perform that action at this time.
0 commit comments