Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
conbrad committed Aug 17, 2023
1 parent adb2967 commit 44eac62
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export class GridComponentRenderer {
return actualField
}

public valueGetter = (params: Pick<GridValueGetterParams, 'row' | 'value'>, precision: number, field: string) => {
public valueGetter = (
params: Pick<GridValueGetterParams, 'row' | 'value'>,
precision: number,
field: string
): string => {
const actualField = this.getActualField(field)
const actual = params.row[actualField]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,24 @@ describe('GridComponentRenderer', () => {
)
expect(itemValue).toEqual('1.1')
})

it('should return an actual field', () => {
const actualField = gridComponentRenderer.getActualField('testForecast')
expect(actualField).toEqual('testActual')
})

it('should return an actual over a prediction if it exists', () => {
const itemValue = gridComponentRenderer.valueGetter(
{
row: {
testForecast: { choice: ModelChoice.GDPS, value: 1.11 },
testActual: 2.22
},
value: { choice: ModelChoice.GDPS, value: 1.11 }
},
1,
'testForecast'
)
expect(itemValue).toEqual('2.2')
})
})

0 comments on commit 44eac62

Please sign in to comment.