@@ -97,6 +97,41 @@ describe(`index`, () => {
9797
9898 expect ( commitMock ) . toBeCalledWith ( `updateField` , { path : `bar.baz` , value : `newFieldValue` } ) ;
9999 } ) ;
100+
101+ describe ( `Namespacing` , ( ) => {
102+ test ( `It should call the namespaced getter function.` , ( ) => {
103+ const mockGetter = jest . fn ( ) ;
104+ const objectOfFields = { foo : `foo` } ;
105+ const mappedFields = mapFields ( `fooModule/` , objectOfFields ) ;
106+
107+ mappedFields . foo . get . apply ( { $store : { getters : { 'fooModule/getField' : mockGetter } } } ) ;
108+
109+ expect ( mockGetter ) . toBeCalledWith ( `foo` ) ;
110+ } ) ;
111+
112+ test ( `It should call the namespaced getter function even if no trailing slash is provided.` , ( ) => {
113+ const mockGetter = jest . fn ( ) ;
114+ const objectOfFields = { foo : `foo` } ;
115+ const mappedFields = mapFields ( `fooModule` , objectOfFields ) ;
116+
117+ mappedFields . foo . get . apply ( { $store : { getters : { 'fooModule/getField' : mockGetter } } } ) ;
118+
119+ expect ( mockGetter ) . toBeCalledWith ( `foo` ) ;
120+ } ) ;
121+
122+ test ( `It should commit the namespaced mutation function.` , ( ) => {
123+ const commitMock = jest . fn ( ) ;
124+ const objectOfFields = {
125+ foo : `foo` ,
126+ bar : `bar.baz` ,
127+ } ;
128+ const mappedFields = mapFields ( `fooModule` , objectOfFields ) ;
129+
130+ mappedFields . bar . set . apply ( { $store : { commit : commitMock } } , [ `newFieldValue` ] ) ;
131+
132+ expect ( commitMock ) . toBeCalledWith ( `fooModule/updateField` , { path : `bar.baz` , value : `newFieldValue` } ) ;
133+ } ) ;
134+ } ) ;
100135 } ) ;
101136
102137 describe ( `mapMultiRowFields()` , ( ) => {
0 commit comments