Review fixes
This commit is contained in:
@@ -6,10 +6,12 @@ export const findMatchingOption = (value, options, defaultValue) => {
|
||||
};
|
||||
|
||||
export const findCompanySizeMatch = (options, size) => {
|
||||
if (!size) return undefined;
|
||||
if (Number.isNaN(size)) return undefined;
|
||||
return (
|
||||
options.find(option => {
|
||||
const upperLimit = option.value.split('-')[1]?.split('+')[0];
|
||||
return size < (upperLimit ? Number(upperLimit) : Infinity);
|
||||
})?.value || this.companySizeOptions[0].value
|
||||
})?.value || options[0].value
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,8 +8,8 @@ describe('getBrowserLocale', () => {
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'en-US' }];
|
||||
expect(getBrowserLocale(languages)).toBe('en-US');
|
||||
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'en_US' }];
|
||||
expect(getBrowserLocale(languages)).toBe('en');
|
||||
});
|
||||
|
||||
it('should return the correct locale code when only a partial match is found', () => {
|
||||
|
||||
@@ -25,11 +25,16 @@ describe('findCompanySizeMatch', () => {
|
||||
|
||||
it('should return the correct company size range', () => {
|
||||
const size = 25;
|
||||
expect(findCompanySizeMatch(size, mockCompanySizeOptions)).toBe('11-50');
|
||||
expect(findCompanySizeMatch(mockCompanySizeOptions, size)).toBe('11-50');
|
||||
});
|
||||
|
||||
it('should return the first company size range when no match is found', () => {
|
||||
it('should return the last company size range when limit exceeds', () => {
|
||||
const size = 1500;
|
||||
expect(findCompanySizeMatch(size, mockCompanySizeOptions)).toBe('1-10');
|
||||
expect(findCompanySizeMatch(mockCompanySizeOptions, size)).toBe('1001+');
|
||||
});
|
||||
|
||||
it('should return the undefined when no match is found', () => {
|
||||
const size = undefined;
|
||||
expect(findCompanySizeMatch(mockCompanySizeOptions, size)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user