Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should render a DropdownList with icons and flags, extending passed props', () => {
render();
const firstFlagIndex = component.find(DropdownList).props().data.length - countries.length;
expect(component.find(DropdownList).props().data.length).toBe(iconNames.length + countries.length + 1);
expect(component.find(DropdownList).props().data[1].type).toBe('Icons');
expect(component.find(DropdownList).props().data[1]._id).toBe(iconNames[0]);
expect(component.find(DropdownList).props().data[1].label).toBe(iconNames[0]);
expect(component.find(DropdownList).props().data[firstFlagIndex].type).toBe('Flags');
expect(component.find(DropdownList).props().data[firstFlagIndex]._id).toBe(countries[0].cca3);
expect(component.find(DropdownList).props().data[firstFlagIndex].label).toBe(countries[0].name.common);
expect(component.find(DropdownList).props().valueComponent).toBe(ListItem);
expect(component.find(DropdownList).props().itemComponent).toBe(ListItem);
expect(component.find(DropdownList).props().defaultValue).toBe(component.find(DropdownList).props().data[0]);
expect(component.find(DropdownList).props().onChange).toBe('Function');
});
});
it('should render a DropdownList with icons and flags, extending passed props', () => {
render();
const firstFlagIndex = component.find(DropdownList).props().data.length - countries.length;
expect(component.find(DropdownList).props().data.length).toBe(iconNames.length + countries.length + 1);
expect(component.find(DropdownList).props().data[1].type).toBe('Icons');
expect(component.find(DropdownList).props().data[1]._id).toBe(iconNames[0]);
expect(component.find(DropdownList).props().data[1].label).toBe(iconNames[0]);
expect(component.find(DropdownList).props().data[firstFlagIndex].type).toBe('Flags');
expect(component.find(DropdownList).props().data[firstFlagIndex]._id).toBe(countries[0].cca3);
expect(component.find(DropdownList).props().data[firstFlagIndex].label).toBe(countries[0].name.common);
expect(component.find(DropdownList).props().valueComponent).toBe(ListItem);
expect(component.find(DropdownList).props().itemComponent).toBe(ListItem);
expect(component.find(DropdownList).props().defaultValue).toBe(component.find(DropdownList).props().data[0]);
expect(component.find(DropdownList).props().onChange).toBe('Function');
});
});
getCountries() {
const array = [];
for (let i = 0; i < countries.length; i++) {
if (countries[i].callingCode.length > 1) {
for (let j = 0; j < countries[i].callingCode.length; j++) {
array.push({
cca2: `${countries[i].cca2} ( ${countries[i].callingCode[j]} )`,
callingCode: countries[i].callingCode[j],
});
}
} else {
array.push({
cca2: countries[i].cca2,
callingCode: countries[i].callingCode[0],
});
}
}
return array;
}