Skip to content

Commit

Permalink
more integration tests for conditional state #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Pollock committed Apr 9, 2019
1 parent c2d6923 commit c7776c6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/forms/src/CalderaForm/state/ConditionalState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ describe( 'ConditionalState set value', () => {
expect(state.getValue('x')).toEqual('five');
});

it( 'Does not change other values', () => {
let r = 1;
let z = 'fff';

const state = new ConditionalState({
x:7,
r,
z
});
state.setValue('x', 'five' );
expect(state.getValue('x')).toEqual('five');
expect(state.getValue('r')).toEqual(r);
expect(state.getValue('z')).toEqual(z);
state.setValue('x', 5 );
expect(state.getValue('x')).toEqual(5);
expect(state.getValue('r')).toEqual(r);
expect(state.getValue('z')).toEqual(z);


state.setValue('z', 'z2' );
expect(state.getValue('x')).toEqual(5);
expect(state.getValue('r')).toEqual(r);
expect(state.getValue('z')).toEqual('z2');

});

});

describe( 'ConditionalState Hiding fields', () => {
Expand Down

0 comments on commit c7776c6

Please sign in to comment.