Skip to content

Commit

Permalink
Merge pull request #2541 from fedspendingtransparency/about-the-data-…
Browse files Browse the repository at this point in the history
…publications-null-handler

[bug-about-the-data] handle null for values on publications tab on current_total_budget_authority_amount.
  • Loading branch information
ebdabbs authored May 3, 2021
2 parents 7b979ae + 14f817a commit 1845f0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/js/models/v2/aboutTheData/PublicationOverviewRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PublicationOverviewRow = {
this._name = data.agency_name || '';
this._abbreviation = data.abbreviation || '';
this.code = data.toptier_code || '';
this._budgetAuthority = data.current_total_budget_authority_amount || 0;
this._budgetAuthority = data.current_total_budget_authority_amount;
this._federalTotal = federalTotal;
this.periods = data.periods
.map(({ submission_dates: { publication_date: p, certification_date: c }, quarterly: isQuarterly, period }) => {
Expand Down
15 changes: 12 additions & 3 deletions tests/models/aboutTheData/PublicationOverviewRow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ test('should handle an agency with no abbreviation', () => {
expect(mockDatesRowMod.name).toEqual('Mock Agency');
});

test('should format the percent of total federal budget', () => {
// 8000.72 / 10000
expect(mockDatesRow.percentageOfTotalFederalBudget).toEqual('80.01%');
test.each([
[mockTotal, 8000.72, '80.01%'],
[mockTotal, null, '--'],
[null, 100, '--']
])('when overall total is %s and agency total is %s, percent of total budget is %s ', (overallTotal, agencyTotal, expected) => {
const model = Object.create(PublicationOverviewRow);
const results = {
...mockRow,
current_total_budget_authority_amount: agencyTotal
};
model.populate(results, overallTotal);
expect(model.percentageOfTotalFederalBudget).toEqual(expected);
});

0 comments on commit 1845f0e

Please sign in to comment.