File tree Expand file tree Collapse file tree 3 files changed +31
-16
lines changed Expand file tree Collapse file tree 3 files changed +31
-16
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,9 @@ const mutations = {
201201 } ,
202202 [ types . ADD_TO_COMPONENT_ACTIONS ] : ( state , payload ) => {
203203 state . componentMap [ state . activeComponent ] . componentActions . push ( payload )
204+ } ,
205+ [ types . ADD_TO_COMPONENT_STATE ] : ( state , payload ) => {
206+ state . componentMap [ state . activeComponent ] . componentState . push ( payload )
204207 }
205208}
206209
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export const PARENT_SELECTED = 'PARENT_SELECTED'
4242export const DELETE_ROUTE = 'DELETE_ROUTE'
4343export const DELETE_COMPONENT = 'DELETE_COMPONENT'
4444export const ADD_TO_COMPONENT_ACTIONS = 'ADD_TO_COMPONENT_ACTIONS'
45+ export const ADD_TO_COMPONENT_STATE = 'ADD_TO_COMPONENT_STATE'
4546
4647// Actions
4748export const registerComponent = 'registerComponent'
Original file line number Diff line number Diff line change @@ -27,22 +27,33 @@ describe('Dummy test', () => {
2727 } )
2828} )
2929
30- describe ( 'Adding actions to components' , ( ) => {
31- const state = {
32- componentMap : {
33- testComponent : {
34- componentName : 'testComponent' ,
35- children : [ ] ,
36- htmlList : [ ] ,
37- componentActions : [ ] ,
38- componentState : [ ]
39- }
40- } ,
41- activeComponent : 'testComponent'
42- }
43- it ( 'should add a single action to a component based on active component' , ( ) => {
44- mutations . ADD_TO_COMPONENT_ACTIONS ( state , 'testAction' )
45- expect ( state . componentMap [ state . activeComponent ] . componentActions ) . toEqual ( [ 'testAction' ] )
30+ describe ( 'Adding actions and state to components' , ( ) => {
31+ let state ;
32+ beforeEach ( ( ) => {
33+ state = {
34+ componentMap : {
35+ testComponent : {
36+ componentName : 'testComponent' ,
37+ children : [ ] ,
38+ htmlList : [ ] ,
39+ componentActions : [ ] ,
40+ componentState : [ ]
41+ }
42+ } ,
43+ activeComponent : 'testComponent'
44+ }
45+ } )
46+ describe ( 'Adding actions to components' , ( ) => {
47+ it ( 'should add a single action to active component' , ( ) => {
48+ mutations . ADD_TO_COMPONENT_ACTIONS ( state , 'testAction' )
49+ expect ( state . componentMap [ state . activeComponent ] . componentActions ) . toEqual ( [ 'testAction' ] )
50+ } )
51+ } )
52+ describe ( 'Adding state to components' , ( ) => {
53+ it ( 'should add a single state string to active component' , ( ) => {
54+ mutations . ADD_TO_COMPONENT_STATE ( state , 'testState' )
55+ expect ( state . componentMap [ state . activeComponent ] . componentState ) . toEqual ( [ 'testState' ] )
56+ } )
4657 } )
4758} )
4859
You can’t perform that action at this time.
0 commit comments