Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanrdsch committed Nov 6, 2023
1 parent b090c73 commit 6889d65
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions frontend/src/DataProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const DATA = Map<number, Data2>([
[1, 1],
[2, 2],
[3, 3],
[4, 4],
],
],
])
Expand All @@ -21,6 +22,18 @@ const DATA_2 = Map<number, Data2>([
[1, 100],
[2, 20],
[3, 30],
[4, 40],
],
],
])
const DATA_3 = Map<number, Data2>([
[
2,
[
[0, 0],
[1, 1],
[2, 2],
[3, 3],
],
],
])
Expand All @@ -37,6 +50,7 @@ test('it returns a single dataset, not normalized', () => {
[1, 1],
[2, 2],
[3, 3],
[4, 4],
])
)
})
Expand All @@ -53,7 +67,8 @@ test('it returns a single dataset, normalized', () => {
[0, 0],
[1, 0.25],
[2, 0.5],
[3, 1],
[3, 0.75],
[4, 1],
])
)
})
Expand All @@ -73,6 +88,7 @@ test('it returns two datasets, added, if they are both selected', () => {
[1, 101],
[2, 22],
[3, 33],
[4, 44],
])
)
})
Expand All @@ -90,9 +106,10 @@ test('it returns two datasets, normalized then averaged, if they are both select
).toEqual(
Map([
[0, 0],
[1, 0.625],
[1, 0.5],
[2, 0.375],
[3, 0.75],
[3, 0.625],
[4, 0.75],
])
)
})
Expand Down Expand Up @@ -147,6 +164,7 @@ test('it weights datasets when normalizing', () => {
[1, 0.75],
[2, 0.125],
[3, 0.625],
[4, 0.75],
])
)
})
Expand All @@ -166,6 +184,7 @@ test("it doesn't weight datasets when not normalizing", () => {
[1, 101],
[2, 22],
[3, 33],
[4, 44],
])
)
})
Expand All @@ -182,23 +201,24 @@ test('it filters geoIds', () => {
[0, 0],
[1, 1],
[3, 3],
[4, 4],
])
)
})

test('it filters by geoIds, then normalizes with respect to only those ids', () => {
expect(
DataProcessor({
data: DATA,
data: DATA_3,
params: [{ mapId: 1, weight: 1, invertNormalized: false }],
filter: (geoId) => geoId !== 3,
normalize: true,
})
).toEqual(
Map([
[0, 0],
[1, 0.33],
[2, 1],
[1, 0.5],
[2, 0.1],
])
)
})

0 comments on commit 6889d65

Please sign in to comment.