Skip to content

Commit 87b387e

Browse files
committed
tests
1 parent 1b325a6 commit 87b387e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

__tests__/FlagDropDown.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import fs from 'fs';
88
import IntlTelInput from '../src/components/IntlTelInputApp';
99
import FlagDropDown from '../src/components/FlagDropDown';
1010
import CountryList from '../src/components/CountryList';
11+
import TelInput from '../src/components/TelInput';
1112

1213
describe('FlagDropDown', function () { // eslint-disable-line func-names
1314
let libphonenumberUtils;
@@ -440,26 +441,31 @@ describe('FlagDropDown', function () { // eslint-disable-line func-names
440441

441442
it('onSelectFlag', () => {
442443
let expected = '';
443-
const onSelectFlag = (currentNumber, countryData) => {
444-
expected = Object.assign({}, { currentNumber, ...countryData });
444+
const onSelectFlag = (currentNumber, countryData, fullNumber, isValid) => {
445+
expected = Object.assign({}, { currentNumber, fullNumber, isValid, ...countryData });
445446
};
446447

447448
this.params.onSelectFlag = onSelectFlag;
448449
const subject = this.makeSubject();
449450
const flagComponent = subject.find(FlagDropDown);
451+
const inputComponent = subject.find(TelInput);
450452
const countryListComponent = subject.find(CountryList);
451453

452454
requests[0].respond(200,
453455
{ 'Content-Type': 'text/javascript' },
454456
libphonenumberUtils);
457+
window.eval(getScript().text);
455458

459+
inputComponent.simulate('change', { target: { value: '+8109012345678' } });
456460
flagComponent.simulate('click');
457461
const japanOption = countryListComponent.find('[data-country-code="jp"]');
458462

459463
japanOption.simulate('click');
460464

461465
expect(expected).toEqual({
462-
currentNumber: '',
466+
currentNumber: '+8109012345678',
467+
fullNumber: '+81 90-1234-5678',
468+
isValid: true,
463469
name: 'Japan (日本)',
464470
iso2: 'jp',
465471
dialCode: '81',

0 commit comments

Comments
 (0)