UNPKG

@aller/blink

Version:

A library for tracking user behaviour.

37 lines (31 loc) 1.04 kB
import getIdFromUrl from '../get-id-from-url'; describe('getIdFromUrl', () => { it('should get id from normal db url', () => { expect(getIdFromUrl('https://www.dagbladet.no/a/89324982')).toBe( 'dagbladet.no/89324982', ); }); it('should get id from dagbladet video url', () => { expect( getIdFromUrl( 'https://www.dagbladet.no/video/r6V6X_1TPw4', 'www.dagbladet.no', ), ).toBe('dagbladet.no/b6ad2c67eaf3f6b760eea09f0de0ae2e'); }); it('should get fallback id for a front', () => { expect(getIdFromUrl('https://www.dagbladet.no/', 'www.fallback.no')).toBe( 'www.fallback.no', ); }); it('should get fallback id for a front with query params', () => { expect( getIdFromUrl('https://www.dagbladet.no/?meta=1', 'www.fallback.no'), ).toBe('www.fallback.no'); }); it('should get fallback id for a front with hash', () => { expect( getIdFromUrl('https://www.dagbladet.no/#tag', 'www.fallback.no'), ).toBe('www.fallback.no'); }); });