Skip to content

Commit

Permalink
unit: fixing unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Gnanakeethan Balasubramaniam <[email protected]>
  • Loading branch information
gnanakeethan committed Dec 5, 2023
1 parent 00620f0 commit 447d9e9
Showing 1 changed file with 97 additions and 1 deletion.
98 changes: 97 additions & 1 deletion src/__tests__/unit/lib/co2js/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,103 @@ import {Co2jsModel} from '../../../../lib/co2js';

jest.setTimeout(30000);

describe('sci:configure test', () => {
describe('co2js-test', () => {
test('initialize and test', async () => {
const model = await new Co2jsModel().configure({
type: '1byte',
});
expect(model).toBeInstanceOf(Co2jsModel);
await expect(
model.execute([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
},
])
).resolves.toStrictEqual([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
'operational-carbon': 0.023195833333333332,
},
]);
});
test('initialize and test', async () => {
const model = await new Co2jsModel().configure({
type: '1byte',
});
expect(model).toBeInstanceOf(Co2jsModel);
await expect(
model.execute([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
},
])
).resolves.toStrictEqual([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
'operational-carbon': 0.023195833333333332,
},
]);
});
test('initialize and test', async () => {
const model = await new Co2jsModel().configure({
type: '1byte',
});
expect(model).toBeInstanceOf(Co2jsModel);
await expect(
model.execute([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
},
])
).resolves.toStrictEqual([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
'operational-carbon': 0.023195833333333332,
},
]);
});
test('initialize and test', async () => {
const model = await new Co2jsModel().configure({
type: '1byte',
});
expect(model).toBeInstanceOf(Co2jsModel);
await expect(
model.execute([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
},
])
).resolves.toStrictEqual([
{
timestamp: '2021-01-01T00:00:00Z',
duration: 3600,
bytes: 100000,
'green-web-host': true,
'operational-carbon': 0.023195833333333332,
},
]);
});
test('initialize and test', async () => {
const model = await new Co2jsModel().configure({
type: '1byte',
Expand Down

0 comments on commit 447d9e9

Please sign in to comment.