Skip to content

Commit

Permalink
test(lib): update explain feature's tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manushak committed Oct 29, 2024
1 parent 890a9c5 commit 50fe84e
Showing 1 changed file with 60 additions and 65 deletions.
125 changes: 60 additions & 65 deletions src/__tests__/if-run/lib/explain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ describe('lib/explain: ', () => {
const mockData = {
pluginName: 'divide',
metadata: {kind: 'execute', inputs: undefined, outputs: undefined},
pluginData: {
path: 'builtin',
method: 'Divide',
},
};

addExplainData(mockData);
Expand Down Expand Up @@ -50,30 +46,29 @@ describe('lib/explain: ', () => {
},
},
},
pluginData: {
path: 'builtin',
method: 'Sum',
},
};

const expectedResult = {
'cpu/energy': {
plugins: ['sum'],
unit: 'kWh',
description: 'energy consumed by the cpu',
'aggregation-method': 'sum',
},
'network/energy': {
plugins: ['sum'],
unit: 'kWh',
description: 'energy consumed by data ingress and egress',
'aggregation-method': 'sum',
},
'energy-sum': {
plugins: ['sum'],
unit: 'kWh',
description: 'sum of energy components',
'aggregation-method': 'sum',
sum: {
inputs: {
'cpu/energy': {
unit: 'kWh',
description: 'energy consumed by the cpu',
'aggregation-method': 'sum',
},
'network/energy': {
unit: 'kWh',
description: 'energy consumed by data ingress and egress',
'aggregation-method': 'sum',
},
},
outputs: {
'energy-sum': {
unit: 'kWh',
description: 'sum of energy components',
'aggregation-method': 'sum',
},
},
},
};

Expand Down Expand Up @@ -111,42 +106,50 @@ describe('lib/explain: ', () => {
},
},
},
pluginData: {
path: 'builtin',
method: 'Sum',
},
};

const expectedResult = {
'cpu/energy': {
plugins: ['sum', 'sum-energy'],
unit: 'kWh',
description: 'energy consumed by the cpu',
'aggregation-method': 'sum',
},
'network/energy': {
plugins: ['sum'],
unit: 'kWh',
description: 'energy consumed by data ingress and egress',
'aggregation-method': 'sum',
},
'energy-sum': {
plugins: ['sum'],
unit: 'kWh',
description: 'sum of energy components',
'aggregation-method': 'sum',
},
'memory/energy': {
plugins: ['sum-energy'],
unit: 'kWh',
description: 'energy consumed by data from memory',
'aggregation-method': 'sum',
sum: {
inputs: {
'cpu/energy': {
unit: 'kWh',
description: 'energy consumed by the cpu',
'aggregation-method': 'sum',
},
'network/energy': {
unit: 'kWh',
description: 'energy consumed by data ingress and egress',
'aggregation-method': 'sum',
},
},
outputs: {
'energy-sum': {
unit: 'kWh',
description: 'sum of energy components',
'aggregation-method': 'sum',
},
},
},
'total/energy': {
plugins: ['sum-energy'],
unit: 'kWh',
description: 'sum of energy components',
'aggregation-method': 'sum',
'sum-energy': {
inputs: {
'cpu/energy': {
unit: 'kWh',
description: 'energy consumed by the cpu',
'aggregation-method': 'sum',
},
'memory/energy': {
unit: 'kWh',
description: 'energy consumed by data from memory',
'aggregation-method': 'sum',
},
},
outputs: {
'total/energy': {
unit: 'kWh',
description: 'sum of energy components',
'aggregation-method': 'sum',
},
},
},
};

Expand Down Expand Up @@ -184,10 +187,6 @@ describe('lib/explain: ', () => {
},
},
},
pluginData: {
path: 'builtin',
method: 'Sum',
},
};

expect.assertions(2);
Expand Down Expand Up @@ -239,10 +238,6 @@ describe('lib/explain: ', () => {
},
},
},
pluginData: {
path: 'builtin',
method: 'Sum',
},
};

expect.assertions(2);
Expand Down

0 comments on commit 50fe84e

Please sign in to comment.