|
@@ -23,6 +23,24 @@ describe('Vuex', () => {
|
|
expect(store.state.a).toBe(3)
|
|
expect(store.state.a).toBe(3)
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ it('committing with object style', () => {
|
|
|
|
+ const store = new Vuex.Store({
|
|
|
|
+ state: {
|
|
|
|
+ a: 1
|
|
|
|
+ },
|
|
|
|
+ mutations: {
|
|
|
|
+ [TEST] (state, payload) {
|
|
|
|
+ state.a += payload.amount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ store.commit({
|
|
|
|
+ type: TEST,
|
|
|
|
+ amount: 2
|
|
|
|
+ })
|
|
|
|
+ expect(store.state.a).toBe(3)
|
|
|
|
+ })
|
|
|
|
+
|
|
it('dispatching actions, sync', () => {
|
|
it('dispatching actions, sync', () => {
|
|
const store = new Vuex.Store({
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
state: {
|
|
@@ -43,6 +61,29 @@ describe('Vuex', () => {
|
|
expect(store.state.a).toBe(3)
|
|
expect(store.state.a).toBe(3)
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ it('dispatching with object style', () => {
|
|
|
|
+ const store = new Vuex.Store({
|
|
|
|
+ state: {
|
|
|
|
+ a: 1
|
|
|
|
+ },
|
|
|
|
+ mutations: {
|
|
|
|
+ [TEST] (state, n) {
|
|
|
|
+ state.a += n
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ actions: {
|
|
|
|
+ [TEST] ({ commit }, payload) {
|
|
|
|
+ commit(TEST, payload.amount)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ store.dispatch({
|
|
|
|
+ type: TEST,
|
|
|
|
+ amount: 2
|
|
|
|
+ })
|
|
|
|
+ expect(store.state.a).toBe(3)
|
|
|
|
+ })
|
|
|
|
+
|
|
it('dispatching actions, with returned Promise', done => {
|
|
it('dispatching actions, with returned Promise', done => {
|
|
const store = new Vuex.Store({
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
state: {
|