Skip to content

Commit

Permalink
ap - change Address country input to countryCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Panchal committed Jan 26, 2017
1 parent 616491b commit 9d9efe5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/components/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ class Address extends Component {
<FormGroup>
<Select
className="w-100"
name="country"
name="countryCode"
options={COUNTRIES}
placeholder="Country"
{...this.propsFor('country')}
onChange={selection => this.onChange({ country: selection && selection.value })}
{...this.propsFor('countryCode')}
onChange={selection => this.onChange({ countryCode: selection && selection.value })}
/>
</FormGroup>
</div>
Expand All @@ -101,7 +101,7 @@ const fieldTypes = {
city: React.PropTypes.string,
state: React.PropTypes.string,
postal: React.PropTypes.string,
country: React.PropTypes.string
countryCode: React.PropTypes.string
};

Address.propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions stories/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ storiesOf('Address', module)
city: 'Smallsville',
state: 'AL',
postal: '12345-1234',
country: 'US'
countryCode: 'US'
}}
onChange={action('address onChange')}
/>
Expand All @@ -30,7 +30,7 @@ storiesOf('Address', module)
city: text('city', 'Smallsville'),
state: select('state', states.map(s => s.value), 'AL'),
postal: text('postal', '12345-1234'),
country: 'US'
countryCode: 'US'
}}
onChange={action('address onChange')}
/>
Expand Down
16 changes: 8 additions & 8 deletions test/components/Address.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('<Address />', () => {
city: 'Gotham',
state: 'NJ',
postal: '07001',
country: 'US'
countryCode: 'US'
}}
onChange={callback}
/>
Expand Down Expand Up @@ -82,17 +82,17 @@ describe('<Address />', () => {
});

it('should have country', () => {
const input = component.find('[name="country"]');
const input = component.find('[name="countryCode"]');
assert.equal(input.type(), Select);
assert.equal(input.prop('placeholder'), 'Country');
assert.equal(input.prop('defaultValue'), 'US');
assert.equal(input.prop('value'), undefined);

input.simulate('change', { label: 'USA', value: 'US' });
assert(callback.calledWith({ country: 'US' }));
assert(callback.calledWith({ countryCode: 'US' }));

input.simulate('change', null);
assert(callback.calledWith({ country: null }));
assert(callback.calledWith({ countryCode: null }));
});
});

Expand All @@ -104,7 +104,7 @@ describe('<Address />', () => {
city: 'Gotham',
state: 'NJ',
postal: '07001',
country: 'US'
countryCode: 'US'
}
const component = shallow(
<Address
Expand Down Expand Up @@ -162,15 +162,15 @@ describe('<Address />', () => {
});

it('should update country', () => {
const input = component.find('[name="country"]');
const input = component.find('[name="countryCode"]');
assert.equal(input.prop('value'), 'US');
assert.equal(input.prop('defaultValue'), '');

input.simulate('change', { label: 'USA', value: 'US' });
assert(callback.calledWith(Object.assign({}, addressData, { country: 'US' })));
assert(callback.calledWith(Object.assign({}, addressData, { countryCode: 'US' })));

input.simulate('change', null);
assert(callback.calledWith(Object.assign({}, addressData, { country: null })));
assert(callback.calledWith(Object.assign({}, addressData, { countryCode: null })));
});
});
});

0 comments on commit 9d9efe5

Please sign in to comment.