Skip to content

Commit

Permalink
Merge pull request #107 from TNG/fershad/patch-1
Browse files Browse the repository at this point in the history
Fershad/patch 1
  • Loading branch information
alexzurbonsen authored Feb 5, 2025
2 parents f3c93f4 + 2b19e35 commit 2124368
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/__tests__/unit/lib/co2js/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {ERRORS} from '@grnsft/if-core/utils';
const {ConfigError, InputValidationError} = ERRORS;

/**
* Disclaimer: the tests relying on carbon-operational values are unstable.
* Disclaimer: the tests relying on estimated-carbon values are unstable.
*
* The models used by co2js contain unversioned changes in the constants that
* go into the calculation of the carbon-operational value.
* go into the calculation of the estimated-carbon value.
*
* AzB copied these tests from the original plugin implementation
* https://github.com/Green-Software-Foundation/if-unofficial-plugins/tree/main/src/lib/co2js
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('lib/co2js: ', () => {
duration: 3600,
'network/data/bytes': 100000,
'green-web-host': true,
'carbon-operational': 0.023,
'estimated-carbon': 0.023,
},
]);
});
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('lib/co2js: ', () => {
duration: 3600,
'network/data': 10,
'green-web-host': true,
'carbon-operational': 2319.583,
'estimated-carbon': 2319.583,
},
]);
});
Expand All @@ -157,7 +157,7 @@ describe('lib/co2js: ', () => {
duration: 3600,
'network/data/bytes': 100000,
'green-web-host': false,
'carbon-operational': 0.029,
'estimated-carbon': 0.029,
},
]);
});
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('lib/co2js: ', () => {
duration: 3600,
'network/data/bytes': 100000,
'green-web-host': true,
'carbon-operational': 0.025,
'estimated-carbon': 0.025,
},
]);
});
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('lib/co2js: ', () => {
duration: 3600,
'network/data/bytes': 100000,
'green-web-host': true,
'carbon-operational': 0.012,
'estimated-carbon': 0.012,
},
]);
});
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('lib/co2js: ', () => {
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
'network/data/bytes': 100000,
'carbon-operational': 0.037,
'estimated-carbon': 0.037,
'green-web-host': false,
options: {
dataReloadRatio: 0.6,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/co2js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The value for `device`, `dataCenter`, or `networks` can be a number representing

## Returns

- `carbon-operational`: carbon emissions from the operation of the website, in grams of CO2e
- `estimated-carbon`: carbon emissions from the operation of the website, in grams of CO2e

# IF Implementation

Expand Down Expand Up @@ -87,7 +87,7 @@ You can run this by passing it to `if-run`. To compute the manifest file, first

```sh
npm i -g @grnsft/if
npm i -g @tngtech/if-webpage-plugin
npm i -g @tngtech/if-webpage-plugins
```

Then, use the following command run from the project root to compute the manifest:
Expand Down Expand Up @@ -144,7 +144,7 @@ tree:
device: 560.98
dataCenter:
country: TWN
carbon-operational: 0.11880509600000001
carbon-operational: 0.119
```

## TypeScript
Expand Down

0 comments on commit 2124368

Please sign in to comment.