From 1472d61c36970dcad459b02dd8115baea4ae8028 Mon Sep 17 00:00:00 2001 From: jmc Date: Fri, 15 Sep 2023 14:44:41 +0100 Subject: [PATCH] fix boavizta test Signed-off-by: jmc --- src/lib/boavizta/index.test.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/boavizta/index.test.ts b/src/lib/boavizta/index.test.ts index c1bdb4f11..798429942 100644 --- a/src/lib/boavizta/index.test.ts +++ b/src/lib/boavizta/index.test.ts @@ -1,5 +1,5 @@ -import {describe, expect, jest, test} from '@jest/globals'; -import {BoaviztaCloudImpactModel, BoaviztaCpuImpactModel} from './index'; +import { describe, expect, jest, test } from '@jest/globals'; +import { BoaviztaCloudImpactModel, BoaviztaCpuImpactModel } from './index'; import axios from 'axios'; import * as PROVIDERS from '../../__mocks__/boavizta/providers.json'; import * as COUNTRIES from '../../__mocks__/boavizta/countries.json'; @@ -13,9 +13,9 @@ const mockAxios = axios as jest.Mocked; mockAxios.get.mockImplementation(url => { switch (url) { case 'https://api.boavizta.org/v1/cloud/all_providers': - return Promise.resolve({data: PROVIDERS}); + return Promise.resolve({ data: PROVIDERS }); case 'https://api.boavizta.org/v1/utils/country_code': - return Promise.resolve({data: COUNTRIES}); + return Promise.resolve({ data: COUNTRIES }); case 'https://api.boavizta.org/v1/cloud/all_instances?provider=aws': return Promise.resolve({ data: INSTANCE_TYPES['aws'], @@ -29,15 +29,15 @@ mockAxios.post.mockImplementation(url => { case 'https://api.boavizta.org/v1/component/cpu?verbose=false&allocation=LINEAR': return Promise.resolve({ data: { - gwp: {manufacture: 0.1, use: 1.0, unit: 'kgCO2eq'}, - pe: {manufacture: 0.1, use: 1.0, unit: 'MJ'}, + gwp: { manufacture: 0.1, use: 1.0, unit: 'kgCO2eq' }, + pe: { manufacture: 0.1, use: 1.0, unit: 'MJ' }, }, }); case 'https://api.boavizta.org/v1/cloud/?verbose=false&allocation=LINEAR': return Promise.resolve({ data: { - gwp: {manufacture: 0.1, use: 1.0, unit: 'kgCO2eq'}, - pe: {manufacture: 0.1, use: 1.0, unit: 'MJ'}, + gwp: { manufacture: 0.1, use: 1.0, unit: 'kgCO2eq' }, + pe: { manufacture: 0.1, use: 1.0, unit: 'MJ' }, }, }); } @@ -48,7 +48,7 @@ describe('cpu:configure test', () => { const impactModel = new BoaviztaCpuImpactModel(); await expect( - impactModel.configure('test', {allocation: 'wrong'}) + impactModel.configure('test', { allocation: 'wrong' }) ).rejects.toThrowError(); expect(impactModel.name).toBe('test'); }); @@ -68,7 +68,7 @@ describe('cpu:configure test', () => { ); // improper observations will throw a invalid observations error await expect( - impactModel.calculate([{invalid: 'observation'}]) + impactModel.calculate([{ invalid: 'observation' }]) ).rejects.toStrictEqual( Error('Invalid Input: Invalid observations parameter') ); @@ -97,7 +97,7 @@ describe('cpu:initialize with params', () => { ]) ).resolves.toStrictEqual([ { - embodied_emission: 100, + 'embodied-carbon': 100, energy: 0.2777777777777778, }, ]); @@ -141,7 +141,7 @@ describe('cloud:initialize with params', () => { ]) ).resolves.toStrictEqual([ { - embodied_emission: 100, + 'embodied-carbon': 100, energy: 0.2777777777777778, }, ]);