import * as assert from 'power-assert' ; import Vue from 'vue' ; import * as Vuex from 'vuex' ; import { mapLocalModule } from '../src/map' ; Vue . use ( Vuex ) ; describe ( 'Map Local Module' , ( ) => { let store ; const localModule = { name : 'test' , state : { count : 0 } , getters : { plus10 : ( state ) => state . count + 10 } , actions : { foo ( _ , fn ) { fn ( ) ; } } , mutations : { bar ( state , amount ) { state . count += amount ; } } } ; beforeEach ( ( ) => { store = new Vuex . Store ( { modules : { test : { state : localModule . state , getters : { 'local/test/plus10' : localModule . getters . plus10 } , actions : { 'local/test/foo' : localModule . actions . foo } , mutations : { 'local/test/bar' : localModule . mutations . bar } } } } ) ; } ) ; it ( 'maps local module' , done => { const vm = new Vue ( { store , beforeCreate ( ) { mapLocalModule ( this , [ 'test' ] , localModule ) ; } } ) ; assert ( vm . count === 0 ) ; assert ( vm . plus10 === 10 ) ; vm . bar ( 3 ) ; assert ( vm . count === 3 ) ; vm . foo ( done ) ; } ) ; } ) ;