Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Apr 25, 2024
1 parent de739ab commit b40f7be
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions components/src/query/queryAggregateData.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, test } from 'vitest';

import { queryAggregateData } from './queryAggregateData';
import { DUMMY_LAPIS_URL, lapisRequestMocks } from '../../vitest.setup';

describe('queryAggregateData', () => {
test('should fetch aggregate data', async () => {
const fields = ['division', 'host'];
const filter = { country: 'USA' };

lapisRequestMocks.aggregated(
{ fields, ...filter },
{
data: [
{ count: 4, region: 'region1', host: 'host1' },
{ count: 4, region: 'region1', host: 'host2' },
{ count: 8, region: 'region2', host: 'host1' },
{ count: 16, region: 'region2', host: 'host2' },
],
},
);

const result = await queryAggregateData(filter, fields, DUMMY_LAPIS_URL);

expect(result).to.deep.equal([
{ proportion: 0.125, count: 4, region: 'region1', host: 'host1' },
{ proportion: 0.125, count: 4, region: 'region1', host: 'host2' },
{ proportion: 0.25, count: 8, region: 'region2', host: 'host1' },
{ proportion: 0.5, count: 16, region: 'region2', host: 'host2' },
]);
});
});

0 comments on commit b40f7be

Please sign in to comment.