Skip to content

Commit

Permalink
Update test expect assertions according to new queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Feb 5, 2024
1 parent cfd0406 commit 0ef9b9c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 54 deletions.
4 changes: 0 additions & 4 deletions api/src/modules/h3-data/h3-data.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,6 @@ export class H3DataRepository extends Repository<H3Data> {
}

/** Retrieves single crop data by a given resolution
*
* @param materialH3Data: H3 Data table and column name for a specific material
* @param resolution: An integer between 1 (min resolution) and 6 (max resolution).
* Resolution validation done at route handler
*
*/
async getMaterialMapByResolution(
Expand Down
83 changes: 40 additions & 43 deletions api/test/e2e/h3-data/h3-impact-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a6fffffff', v: '500.0000' },
{ h: '861203a6fffffff', v: '500' },
{
h: '861203a5fffffff',
v: '617.0000',
v: '617',
},
{ h: '861203a4fffffff', v: '1117.0000' },
{ h: '861203a4fffffff', v: '1117' },
]),
);
expect(response.body.metadata.unit).toEqual('tonnes');
expect(
toBeCloseToArray(
response.body.metadata.quantiles,
[0, 539.0078, 578.0858, 617, 783.699999, 950.7, 1117],
[0, 2.2, 9.3, 30, 100, 300, 1000],
5,
),
).toBeTruthy();
Expand All @@ -140,10 +140,10 @@ describe('H3 Data Module (e2e) - Impact map', () => {
});

expect(response.body.data).toEqual(
expect.arrayContaining([{ h: '821207fffffffff', v: '2234.0000' }]),
expect.arrayContaining([{ h: '821207fffffffff', v: '2234' }]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 2234, 2234, 2234, 2234, 2234, 2234],
quantiles: [0, 2.6, 10, 50, 200, 600, 2000],
unit: 'tonnes',
});
});
Expand All @@ -159,10 +159,10 @@ describe('H3 Data Module (e2e) - Impact map', () => {
});

expect(response.body.data).toEqual(
expect.arrayContaining([{ h: '841203bffffffff', v: '2234.0000' }]),
expect.arrayContaining([{ h: '841203bffffffff', v: '2234' }]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 2234, 2234, 2234, 2234, 2234, 2234],
quantiles: [0, 2.6, 10, 50, 200, 600, 2000],
unit: 'tonnes',
});
});
Expand All @@ -179,19 +179,19 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a6fffffff', v: '500.0000' },
{ h: '861203a6fffffff', v: '500' },
{
h: '861203a5fffffff',
v: '617.0000',
v: '617',
},
{ h: '861203a4fffffff', v: '1117.0000' },
{ h: '861203a4fffffff', v: '1117' },
]),
);
expect(response.body.metadata.unit).toEqual('tonnes');
expect(
toBeCloseToArray(
response.body.metadata.quantiles,
[0, 539.0078, 578.0858, 617, 783.699999, 950.7, 1117],
[0, 2.2, 9.3, 30, 100, 300, 1000],
5,
),
).toBeTruthy();
Expand All @@ -212,12 +212,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a5fffffff', v: '617.0000' },
{ h: '861203a4fffffff', v: '617.0000' },
{ h: '861203a5fffffff', v: '617' },
{ h: '861203a4fffffff', v: '617' },
]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 617, 617, 617, 617, 617, 617],
quantiles: [0, 1.9, 7.5, 20, 70, 200, 600],
unit: 'tonnes',
materialsH3DataYears: [
{
Expand Down Expand Up @@ -247,12 +247,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a5fffffff', v: '617.0000' },
{ h: '861203a4fffffff', v: '617.0000' },
{ h: '861203a5fffffff', v: '617' },
{ h: '861203a4fffffff', v: '617' },
]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 617, 617, 617, 617, 617, 617],
quantiles: [0, 1.9, 7.5, 20, 70, 200, 600],
unit: 'tonnes',
});
});
Expand All @@ -270,12 +270,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a5fffffff', v: '617.0000' },
{ h: '861203a4fffffff', v: '617.0000' },
{ h: '861203a5fffffff', v: '617' },
{ h: '861203a4fffffff', v: '617' },
]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 617, 617, 617, 617, 617, 617],
quantiles: [0, 1.9, 7.5, 20, 70, 200, 600],
unit: 'tonnes',
});
});
Expand All @@ -293,18 +293,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{
h: '861203a5fffffff',
v: '617.0000',
},
{
h: '861203a4fffffff',
v: '617.0000',
},
{ h: '861203a5fffffff', v: '617' },
{ h: '861203a4fffffff', v: '617' },
]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 617, 617, 617, 617, 617, 617],
quantiles: [0, 1.9, 7.5, 20, 70, 200, 600],
unit: 'tonnes',
});
});
Expand All @@ -323,9 +317,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {
});
expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a6fffffff', v: '500.0000' },
{ h: '861203a5fffffff', v: '617.0000' },
{ h: '861203a4fffffff', v: '1117.0000' },
{ h: '861203a6fffffff', v: '500' },
{
h: '861203a5fffffff',
v: '617',
},
{ h: '861203a4fffffff', v: '1117' },
]),
);
});
Expand All @@ -342,12 +339,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a5fffffff', v: '617.0000' },
{ h: '861203a4fffffff', v: '617.0000' },
{ h: '861203a5fffffff', v: '617' },
{ h: '861203a4fffffff', v: '617' },
]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 617, 617, 617, 617, 617, 617],
quantiles: [0, 1.9, 7.5, 20, 70, 200, 600],
unit: 'tonnes',
});
});
Expand All @@ -365,12 +362,12 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a5fffffff', v: '617.0000' },
{ h: '861203a4fffffff', v: '617.0000' },
{ h: '861203a5fffffff', v: '617' },
{ h: '861203a4fffffff', v: '617' },
]),
);
expect(response.body.metadata).toEqual({
quantiles: [0, 617, 617, 617, 617, 617, 617],
quantiles: [0, 1.9, 7.5, 20, 70, 200, 600],
unit: 'tonnes',
});
});
Expand All @@ -392,20 +389,20 @@ describe('H3 Data Module (e2e) - Impact map', () => {

expect(response.body.data).toEqual(
expect.arrayContaining([
{ h: '861203a6fffffff', v: '450.0000' },
{ h: '861203a6fffffff', v: '450' },
{
h: '861203a5fffffff',
v: '592.0000',
v: '592',
},
{ h: '861203a4fffffff', v: '1042.0000' },
{ h: '861203a4fffffff', v: '1042' },
]),
);
expect(response.body.metadata).toBeDefined();
expect(response.body.metadata.unit).toEqual('tonnes');
expect(
toBeCloseToArray(
response.body.metadata.quantiles,
[0, 497.3428, 544.7708, 592, 742.03, 892.329999, 1042],
[0, 2.2, 9.1, 30, 100, 300, 1000],
5,
),
).toBeTruthy();
Expand Down
9 changes: 2 additions & 7 deletions api/test/e2e/h3-data/h3-material-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ describe('H3 Data Module (e2e) - Material map', () => {
);

expect(responseRes1.body.metadata).toEqual({
quantiles: [
0, 615.037, 800.0275, 812.5, 825.0784999999998, 1218.3635000000002,
1610,
],
quantiles: [0, 2.4, 10, 40, 100, 500, 2000],
unit: 'tonnes',
});

Expand All @@ -197,9 +194,7 @@ describe('H3 Data Module (e2e) - Material map', () => {
);

expect(responseRes3.body.metadata).toEqual({
quantiles: [
0, 200.006, 231.1110000000001, 735, 750.01, 800.1320000000001, 860,
],
quantiles: [0, 2.1, 8.5, 30, 90, 300, 900],
unit: 'tonnes',
});
});
Expand Down

0 comments on commit 0ef9b9c

Please sign in to comment.