@@ -182,6 +182,92 @@ describe('selectPrimaryWorkExperience', () => {
182182 const result = selectPrimaryWorkExperience ( [ shortRange , longRange ] )
183183 expect ( result . organizationName ) . toBe ( 'LongRange' )
184184 } )
185+
186+ it ( 'email-domain beats enrichment when both are dated' , ( ) => {
187+ const enrichment = makeRow ( {
188+ organizationId : 'enrichment' ,
189+ organizationName : 'Enrichment Org' ,
190+ dateStart : '2020-01-01' ,
191+ source : 'enrichment-progai' ,
192+ } )
193+ const emailDomain = makeRow ( {
194+ organizationId : 'email' ,
195+ organizationName : 'Email Org' ,
196+ dateStart : '2020-01-01' ,
197+ source : 'email-domain' ,
198+ } )
199+ expect ( selectPrimaryWorkExperience ( [ enrichment , emailDomain ] ) . organizationName ) . toBe (
200+ 'Email Org' ,
201+ )
202+ } )
203+
204+ it ( 'ui beats email-domain when both are dated' , ( ) => {
205+ const emailDomain = makeRow ( {
206+ organizationId : 'email' ,
207+ organizationName : 'Email Org' ,
208+ dateStart : '2020-01-01' ,
209+ source : 'email-domain' ,
210+ } )
211+ const ui = makeRow ( {
212+ organizationId : 'ui' ,
213+ organizationName : 'UI Org' ,
214+ dateStart : '2020-01-01' ,
215+ source : 'ui' ,
216+ } )
217+ expect ( selectPrimaryWorkExperience ( [ emailDomain , ui ] ) . organizationName ) . toBe ( 'UI Org' )
218+ } )
219+
220+ it ( 'ui beats enrichment when both are dated' , ( ) => {
221+ const enrichment = makeRow ( {
222+ organizationId : 'enrichment' ,
223+ organizationName : 'Enrichment Org' ,
224+ dateStart : '2020-01-01' ,
225+ source : 'enrichment-clearbit' ,
226+ } )
227+ const ui = makeRow ( {
228+ organizationId : 'ui' ,
229+ organizationName : 'UI Org' ,
230+ dateStart : '2020-01-01' ,
231+ source : 'ui' ,
232+ } )
233+ expect ( selectPrimaryWorkExperience ( [ enrichment , ui ] ) . organizationName ) . toBe ( 'UI Org' )
234+ } )
235+
236+ it ( 'falls through to member count when source tiers are equal' , ( ) => {
237+ const small = makeRow ( {
238+ organizationId : 'small' ,
239+ organizationName : 'Small Enrichment' ,
240+ dateStart : '2020-01-01' ,
241+ memberCount : 10 ,
242+ source : 'enrichment-progai' ,
243+ } )
244+ const large = makeRow ( {
245+ organizationId : 'large' ,
246+ organizationName : 'Large Enrichment' ,
247+ dateStart : '2020-01-01' ,
248+ memberCount : 100 ,
249+ source : 'enrichment-progai' ,
250+ } )
251+ expect ( selectPrimaryWorkExperience ( [ small , large ] ) . organizationName ) . toBe ( 'Large Enrichment' )
252+ } )
253+
254+ it ( 'undated rows are not affected by source priority — dated enrichment beats undated email-domain' , ( ) => {
255+ const undatedEmailDomain = makeRow ( {
256+ organizationId : 'email' ,
257+ organizationName : 'Email Org' ,
258+ dateStart : null ,
259+ source : 'email-domain' ,
260+ } )
261+ const datedEnrichment = makeRow ( {
262+ organizationId : 'enrichment' ,
263+ organizationName : 'Enrichment Org' ,
264+ dateStart : '2020-01-01' ,
265+ source : 'enrichment-progai' ,
266+ } )
267+ expect (
268+ selectPrimaryWorkExperience ( [ undatedEmailDomain , datedEnrichment ] ) . organizationName ,
269+ ) . toBe ( 'Enrichment Org' )
270+ } )
185271} )
186272
187273// ---------------------------------------------------------------------------
0 commit comments