Skip to content

Commit

Permalink
test(lib): add test for e-net without global config
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcook1186 committed Mar 28, 2024
1 parent 701ebae commit d37b309
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/__tests__/unit/lib/e-net/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,36 @@ describe('lib/e-net', () => {
});
});
});

describe('execute() without global config: ', () => {
it('calculates energy for each input.', async () => {
const globalConfig = {};
const eNet = ENet(globalConfig);
const inputs = [
{
'network/data-in': 10,
'network/data-out': 5,
duration: 3600,
timestamp: '2022-01-01T01:00:00Z',
},
{
'network/data-in': 20,
'network/data-out': 15,
duration: 3600,
timestamp: '2022-01-01T01:00:00Z',
},
];

expect.assertions(3);

const result = await eNet.execute(inputs);

expect(result).toHaveLength(inputs.length);
result.forEach((output, index) => {
expect(output['network/energy']).toBeCloseTo(
(inputs[index]['network/data-in'] + inputs[index]['network/data-out']) *
0.001
);
});
});
});

0 comments on commit d37b309

Please sign in to comment.