/** * Selected-service chips on the Checkout rates screen. */ import { serviceChipLabel } from '../features/settings/utils/serviceChipLabel'; import type { Service } from '../types/quote'; const service = (slug: string, courier: string, name: string) => ({ slug, courier, name, courierSlug: '', dropOffProviderGroup: '' }) as Service; describe('serviceChipLabel', () => { it('shows courier and service', () => { expect(serviceChipLabel(service('rm48', 'Royal Mail', '48 Tracked Small Collection'))).toBe( 'Royal Mail – 48 Tracked Small Collection' ); }); it('shows the courier when the service name is empty (e.g. Evri Collection)', () => { expect(serviceChipLabel(service('hermes-uk-economy', 'Evri Collection', ''))).toBe('Evri Collection'); }); it('shows the courier when the saved name is only the slug', () => { expect(serviceChipLabel(service('hermes-uk-economy', 'Evri Collection', 'hermes-uk-economy'))).toBe('Evri Collection'); }); it('drops a dash left over from taking the courier out', () => { expect(serviceChipLabel(service('dhl-som-s2c-nd', 'DHL eCommerce UK', '- Drop Off'))).toBe( 'DHL eCommerce UK – Drop Off' ); }); it('falls back to the slug when there is nothing else', () => { expect(serviceChipLabel(service('some-slug', '', ''))).toBe('some-slug'); }); });