@@ -4,6 +4,27 @@ import {render, fireEvent} from '..'
4
4
import VuexTest from './components/Store/VuexTest'
5
5
import { store } from './components/Store/store'
6
6
7
+ test ( 'basic test with Vuex store' , async ( ) => {
8
+ const storeInstance = createStore ( store )
9
+
10
+ const { getByTestId, getByText} = render ( VuexTest , {
11
+ global : {
12
+ plugins : [ storeInstance ] ,
13
+ } ,
14
+ } )
15
+
16
+ expect ( getByTestId ( 'count-value' ) ) . toHaveTextContent ( '0' )
17
+
18
+ await fireEvent . click ( getByText ( '+' ) )
19
+ expect ( getByTestId ( 'count-value' ) ) . toHaveTextContent ( '1' )
20
+
21
+ await fireEvent . click ( getByText ( '+' ) )
22
+ expect ( getByTestId ( 'count-value' ) ) . toHaveTextContent ( '2' )
23
+
24
+ await fireEvent . click ( getByText ( '-' ) )
25
+ expect ( getByTestId ( 'count-value' ) ) . toHaveTextContent ( '1' )
26
+ } )
27
+
7
28
// A common testing pattern is to create a custom renderer for a specific test
8
29
// file. This way, common operations such as registering a Vuex store can be
9
30
// abstracted out while avoiding sharing mutable state.
@@ -13,11 +34,11 @@ import {store} from './components/Store/store'
13
34
function renderVuexTestComponent ( customStore ) {
14
35
// Create a custom store with the original one and the one coming as a
15
36
// parameter. This way we can alter some of its values.
16
- const mergedStore = createStore ( { ...store , ...customStore } )
37
+ const mergedStoreInstance = createStore ( { ...store , ...customStore } )
17
38
18
39
return render ( VuexTest , {
19
40
global : {
20
- plugins : [ mergedStore ] ,
41
+ plugins : [ mergedStoreInstance ] ,
21
42
} ,
22
43
} )
23
44
}
0 commit comments