Improved VisitsParser test

This commit is contained in:
Alejandro Celaya 2021-03-28 21:03:46 +02:00
parent db778a73f7
commit c3e38fd580

View file

@ -64,7 +64,7 @@ describe('VisitsParser', () => {
}), }),
Mock.of<OrphanVisit>({ Mock.of<OrphanVisit>({
type: 'invalid_short_url', type: 'invalid_short_url',
visitedUrl: 'baz', visitedUrl: 'bar',
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
referer: 'https://m.facebook.com', referer: 'https://m.facebook.com',
visitLocation: { visitLocation: {
@ -153,6 +153,15 @@ describe('VisitsParser', () => {
}, },
}); });
}); });
it('properly parses visited URL stats', () => {
const { visitedUrls } = processStatsFromVisits(normalizeVisits(orphanVisits));
expect(visitedUrls).toEqual({
foo: 1,
bar: 2,
});
});
}); });
describe('normalizeVisits', () => { describe('normalizeVisits', () => {
@ -247,7 +256,7 @@ describe('VisitsParser', () => {
latitude: 123.45, latitude: 123.45,
longitude: -543.21, longitude: -543.21,
type: 'invalid_short_url', type: 'invalid_short_url',
visitedUrl: 'baz', visitedUrl: 'bar',
}, },
]); ]);
}); });