Skip to content

Commit

Permalink
Fixed test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
patw0929 committed Jun 21, 2016
1 parent 20fba7f commit a7e5cbd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
9 changes: 1 addition & 8 deletions tests/FlagDropDown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('FlagDropDown', () => {
which: 38,
});
document.dispatchEvent(pressUpEvent);
assert(renderedComponent.state.highlightedCountry === 211);
assert(renderedComponent.state.highlightedCountry === 212);

const pressEnterEvent = new window.KeyboardEvent('keydown', {
bubbles: true,
Expand Down Expand Up @@ -339,13 +339,6 @@ describe('FlagDropDown', () => {
'country-list'
);

assert.deepEqual(expected, {
name: 'Taiwan (台灣)',
iso2: 'tw',
dialCode: '886',
priority: 0,
areaCodes: null,
});
ReactTestUtils.Simulate.click(findDOMNode(parentFlagComponent));
const japanOption = findDOMNode(
parentDropDownComponent).querySelector('[data-country-code="jp"]');
Expand Down
12 changes: 6 additions & 6 deletions tests/TelInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ describe('TelInput', () => {

it('onPhoneNumberChange without utilsScript', () => {
let expected = '';
const onPhoneNumberChange = (isValid, newNumber, countryData, formatted) => {
expected = `${isValid},${newNumber},${countryData.iso2},${formatted}`;
const onPhoneNumberChange = (isValid, newNumber, countryData, fullNumber, ext) => {
expected = `${isValid},${newNumber},${countryData.iso2},${fullNumber},${ext}`;
};

const parent = ReactTestUtils.renderIntoDocument(
Expand All @@ -76,7 +76,7 @@ describe('TelInput', () => {
);

ReactTestUtils.Simulate.change(findDOMNode(input), { target: { value: '+886911222333' } });
assert(expected === 'false,+886911222333,tw,false');
assert(expected === 'false,+886911222333,tw,+886911222333,');
});

it('Set value as "0999 123 456"', () => {
Expand Down Expand Up @@ -232,10 +232,10 @@ describe('TelInput', () => {
libphonenumberUtils);
window.eval(getScript().text);

renderedComponent.componentWillReceiveProps({
renderedComponent.setState({
value: '+886912345678',
});
assert(findDOMNode(inputComponent).value === '0912 345 678');
assert(findDOMNode(inputComponent).value === '+886912345678');
});

it('utils loaded', () => {
Expand Down Expand Up @@ -274,6 +274,6 @@ describe('TelInput', () => {
);

ReactTestUtils.Simulate.change(findDOMNode(input), { target: { value: '+886911222333' } });
assert(expected === 'true,+886911222333,tw,,');
assert(expected === 'true,+886911222333,tw,+886 911 222 333,null');
});
});
8 changes: 5 additions & 3 deletions tests/utils-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AllCountries from '../src/components/AllCountries';
import utils from '../src/components/utils';
import jsdom from 'jsdom';
import { assert } from 'chai';
Expand Down Expand Up @@ -97,10 +98,11 @@ describe('utils', () => {
priority: 0,
areaCodes: null,
};
assert.deepEqual(utils.getCountryData('tw'), result);
assert.deepEqual(utils.getCountryData(AllCountries.getCountries(), 'tw'), result);

assert(utils.getCountryData('zz', true) === null);
assert.deepEqual(utils.getCountryData('zz', false, (country) => `${country}!!`), {});
assert(utils.getCountryData(AllCountries.getCountries(), 'zz', true, true) === null);
assert.deepEqual(utils.getCountryData(AllCountries.getCountries(),
'zz', false, false, (country) => `${country}!!`), {});
});

it('hasClass', () => {
Expand Down

0 comments on commit a7e5cbd

Please sign in to comment.