Allowed visits to be selected on charts so that they get highlighted on the rest of the charts

This commit is contained in:
Alejandro Celaya
2020-04-10 11:59:53 +02:00
parent 05deb1aff0
commit 8f42e65ccd
8 changed files with 169 additions and 90 deletions

View File

@@ -1,4 +1,4 @@
import { processStatsFromVisits } from '../../../src/visits/services/VisitsParser';
import { processStatsFromVisits, normalizeVisits } from '../../../src/visits/services/VisitsParser';
describe('VisitsParser', () => {
const visits = [
@@ -47,7 +47,7 @@ describe('VisitsParser', () => {
let stats;
beforeAll(() => {
stats = processStatsFromVisits({ id: 'id', visits });
stats = processStatsFromVisits(visits);
});
it('properly parses OS stats', () => {
@@ -121,4 +121,51 @@ describe('VisitsParser', () => {
});
});
});
describe('normalizeVisits', () => {
it('properly parses the list of visits', () => {
expect(normalizeVisits(visits)).toEqual([
{
browser: 'Firefox',
os: 'Windows',
referer: 'google.com',
country: 'Spain',
city: 'Zaragoza',
date: undefined,
},
{
browser: 'Firefox',
os: 'MacOS',
referer: 'google.com',
country: 'United States',
city: 'New York',
date: undefined,
},
{
browser: 'Chrome',
os: 'Linux',
referer: 'Direct',
country: 'Spain',
city: 'Unknown',
date: undefined,
},
{
browser: 'Chrome',
os: 'Linux',
referer: 'm.facebook.com',
country: 'Spain',
city: 'Zaragoza',
date: undefined,
},
{
browser: 'Opera',
os: 'Linux',
referer: 'Direct',
country: 'Unknown',
city: 'Unknown',
date: undefined,
},
]);
});
});
});