feat: more accurate industry tracking
This commit is contained in:
@@ -4,3 +4,37 @@ export const findMatchingOption = (value, options, defaultValue) => {
|
||||
);
|
||||
return match ? match.value || match : defaultValue;
|
||||
};
|
||||
|
||||
export const findIndustryOptions = subIndustry => {
|
||||
const industryMap = {
|
||||
'Information Technology': [
|
||||
'Semiconductors & Semiconductor Equipment',
|
||||
'Internet Software & Services',
|
||||
'IT Services',
|
||||
'Software',
|
||||
'Communications Equipment',
|
||||
'Electronic Equipment, Instruments & Components',
|
||||
'Technology Hardware, Storage & Peripherals',
|
||||
],
|
||||
Financials: [
|
||||
'Banks',
|
||||
'Diversified Financial Services',
|
||||
'Capital Markets',
|
||||
'Insurance',
|
||||
],
|
||||
'Health & Medicine': [
|
||||
'Health Care Equipment & Supplies',
|
||||
'Health Care Providers & Services',
|
||||
'Biotechnology',
|
||||
'Life Sciences Tools & Services',
|
||||
'Pharmaceuticals',
|
||||
],
|
||||
Education: ['Education Services'],
|
||||
};
|
||||
|
||||
const industry = Object.entries(industryMap).find(([, value]) =>
|
||||
value.includes(subIndustry)
|
||||
);
|
||||
|
||||
return industry ? industry[0] : 'Other';
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { findMatchingOption } from '../OnboardingHelper';
|
||||
import { findMatchingOption, findIndustryOptions } from '../OnboardingHelper';
|
||||
|
||||
describe('findMatchingOption', () => {
|
||||
const options = [{ value: 'option1' }, { value: 'option2' }];
|
||||
@@ -13,3 +13,28 @@ describe('findMatchingOption', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findIndustryOptions', () => {
|
||||
it('should return the correct industry for a given sub-industry', () => {
|
||||
expect(
|
||||
findIndustryOptions('Semiconductors & Semiconductor Equipment')
|
||||
).toBe('Information Technology');
|
||||
expect(findIndustryOptions('Banks')).toBe('Financials');
|
||||
expect(findIndustryOptions('Health Care Equipment & Supplies')).toBe(
|
||||
'Health & Medicine'
|
||||
);
|
||||
expect(findIndustryOptions('Education Services')).toBe('Education');
|
||||
});
|
||||
|
||||
it('should return "Other" for a sub-industry not in the map', () => {
|
||||
expect(findIndustryOptions('Non-existing Sub-industry')).toBe('Other');
|
||||
});
|
||||
|
||||
it('should return "Other" for an empty string', () => {
|
||||
expect(findIndustryOptions('')).toBe('Other');
|
||||
});
|
||||
|
||||
it('should return "Other" for a null value', () => {
|
||||
expect(findIndustryOptions(null)).toBe('Other');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user