Skip to content

Commit

Permalink
update test values
Browse files Browse the repository at this point in the history
  • Loading branch information
fershad committed Feb 21, 2024
1 parent 6b17d40 commit 4e36c6d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
21 changes: 11 additions & 10 deletions src/co2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import pagexray from "pagexray";
import CO2 from "./co2.js";
import { averageIntensity, marginalIntensity } from "./index.js";

const TwnGridIntensityValue = averageIntensity.data["TWN"];

describe("co2", () => {
let har, co2;

describe("1 byte model", () => {
const { TGWF_GREY_VALUE, TGWF_GREEN_VALUE, TGWF_MIXED_VALUE } = ONEBYTE;

Expand Down Expand Up @@ -484,7 +485,7 @@ describe("co2", () => {
expect(
co2.perVisitTrace(MILLION, false, {
gridIntensity: {
device: 565.629,
device: 678.87,
dataCenter: { country: "TWN" },
},
}).co2
Expand All @@ -493,7 +494,7 @@ describe("co2", () => {
expect(
co2.perByteTrace(MILLION, false, {
gridIntensity: {
device: 565.629,
device: 678.87,
dataCenter: { country: "TWN" },
network: { country: "TWN" },
},
Expand Down Expand Up @@ -542,7 +543,7 @@ describe("co2", () => {
co2
.perVisitTrace(MILLION, false, {
gridIntensity: {
device: 561,
device: TwnGridIntensityValue,
},
})
.co2.toPrecision(5)
Expand All @@ -559,7 +560,7 @@ describe("co2", () => {
co2
.perByteTrace(MILLION, false, {
gridIntensity: {
device: 561,
device: TwnGridIntensityValue,
},
})
.co2.toPrecision(4)
Expand Down Expand Up @@ -641,7 +642,7 @@ describe("co2", () => {
co2
.perVisitTrace(MILLION, false, {
gridIntensity: {
dataCenter: 561,
dataCenter: TwnGridIntensityValue,
},
})
.co2.toPrecision(5)
Expand All @@ -657,7 +658,7 @@ describe("co2", () => {
co2
.perByteTrace(MILLION, false, {
gridIntensity: {
dataCenter: 561,
dataCenter: TwnGridIntensityValue,
},
})
.co2.toPrecision(5)
Expand Down Expand Up @@ -740,14 +741,14 @@ describe("co2", () => {
co2
.perVisitTrace(MILLION, false, {
gridIntensity: {
network: 561,
network: TwnGridIntensityValue,
},
})
.co2.toPrecision(5)
)
).toBeCloseTo(
parseFloat(
MILLION_PERVISIT_GREY_NETWORK_GRID_INTENSITY_CHANGE.toPrecision(5)
MILLION_PERVISIT_GREY_NETWORK_GRID_INTENSITY_CHANGE.toFixed(5)
),
3
);
Expand All @@ -756,7 +757,7 @@ describe("co2", () => {
co2
.perByteTrace(MILLION, false, {
gridIntensity: {
network: 561,
network: TwnGridIntensityValue,
},
})
.co2.toPrecision(5)
Expand Down
38 changes: 19 additions & 19 deletions src/constants/test-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ export const ONEBYTE = {
};

export const SWD = {
MILLION_GREY: 0.35418,
MILLION_GREEN: 0.30713,
MILLION_PERVISIT_GREY: 0.26765,
MILLION_PERVISIT_GREEN: 0.23188,
MILLION_GREY: 0.40008,
MILLION_GREEN: 0.34613,
MILLION_PERVISIT_GREY: 0.30206,
MILLION_PERVISIT_GREEN: 0.26133,

TGWF_GREY_VALUE: 0.24963,
TGWF_GREY_VALUE: 0.28198,
TGWF_GREEN_VALUE: 0.54704,
TGWF_MIXED_VALUE: 0.21942,
TGWF_MIXED_VALUE: 0.24734,

MILLION_GREY_DEVICES: 0.18417,
MILLION_GREY_NETWORKS: 0.04959,
MILLION_GREY_DATACENTERS: 0.05313,
MILLION_GREY_DEVICES: 0.20803,
MILLION_GREY_NETWORKS: 0.05601,
MILLION_GREY_DATACENTERS: 0.06001,
MILLION_GREEN_DATACENTERS: 0.00607,
MILLION_GREY_PRODUCTION: 0.06729,
MILLION_GREY_PRODUCTION: 0.07601,

MILLION_PERVISIT_GREY_DEVICE_GRID_INTENSITY_CHANGE: 0.30676,
MILLION_PERVISIT_GREY_DATACENTER_GRID_INTENSITY_CHANGE: 0.27876,
MILLION_PERVISIT_GREY_NETWORK_GRID_INTENSITY_CHANGE: 0.27800,
MILLION_PERVISIT_GREY_DEVICE_GRID_INTENSITY_CHANGE: 0.36087,
MILLION_PERVISIT_GREY_DATACENTER_GRID_INTENSITY_CHANGE: 0.31902,
MILLION_PERVISIT_GREY_NETWORK_GRID_INTENSITY_CHANGE: 0.31789,

MILLION_PERBYTE_GREY_DEVICE_GRID_INTENSITY_CHANGE: 0.40631,
MILLION_PERBYTE_GREY_DATACENTER_GRID_INTENSITY_CHANGE: 0.36922,
MILLION_PERBYTE_GREY_NETWORK_GRID_INTENSITY_CHANGE: 0.36821,
MILLION_PERBYTE_GREY_DEVICE_GRID_INTENSITY_CHANGE: 0.47800,
MILLION_PERBYTE_GREY_DATACENTER_GRID_INTENSITY_CHANGE: 0.42255,
MILLION_PERBYTE_GREY_NETWORK_GRID_INTENSITY_CHANGE: 0.42105,

MILLION_PERVISIT_GREY_DEVICES_FIRST: 0.13813,
MILLION_PERVISIT_GREY_DEVICES_FIRST: 0.15603,
MILLION_PERVISIT_GREY_DEVICES_SECOND: 0.00092,
MILLION_PERVISIT_GREY_NETWORKS_FIRST: 0.03719,
MILLION_PERVISIT_GREY_NETWORKS_SECOND: 0.00025,
MILLION_PERVISIT_GREY_DATACENTERS_FIRST: 0.03985,
MILLION_PERVISIT_GREY_DATACENTERS_FIRST: 0.04501,
MILLION_PERVISIT_GREY_DATACENTERS_SECOND: 0.00027,
MILLION_PERVISIT_GREEN_DATACENTERS_FIRST: 0.00456,
MILLION_PERVISIT_GREEN_DATACENTERS_SECOND: 0.00003,
MILLION_PERVISIT_GREY_PRODUCTION_FIRST: 0.05047,
MILLION_PERVISIT_GREY_PRODUCTION_FIRST: 0.05701,
MILLION_PERVISIT_GREY_PRODUCTION_SECOND: 0.00034,
};
2 changes: 1 addition & 1 deletion src/sustainable-web-design.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("sustainable web design model", () => {
describe("emissionsPerVisitInGrams", () => {
it("should calculate the correct co2 per visit", () => {
const energy = swd.energyPerVisit(averageWebsiteInBytes);
expect(swd.emissionsPerVisitInGrams(energy)).toEqual(0.6);
expect(swd.emissionsPerVisitInGrams(energy)).toEqual(0.68);
});

it("should accept a dynamic KwH value", () => {
Expand Down

0 comments on commit 4e36c6d

Please sign in to comment.