Skip to content

Commit

Permalink
unit test for handling multiple fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rosado committed Sep 30, 2024
1 parent bba1631 commit e8841f1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unit/middleware/overview.middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ describe('overview.middleware', () => {
expect(aggregated[0].status).toBe('Error')
expect(aggregated[1].status).toBe('Needs fixing')
})

it('handles multiple fields', () => {
const exampleData = [
{ endpoint: 'https://example.com/2', status: 'Needs fixing', dataset: 'dataset1', entity_count: 5, issue_count: 5, fields: 'foo,bar' },
{ endpoint: 'https://example.com/2', status: 'Needs fixing', dataset: 'dataset2', entity_count: 5, issue_count: 2, fields: 'baz,qux' }
]

const aggregated = aggregateOverviewData(exampleData)
aggregated.sort((a, b) => a.slug.localeCompare(b.slug))

expect(aggregated[0].status).toBe('Needs fixing')
expect(aggregated[0].issue_count).toBe(2) // 2 columns affected
expect(aggregated[1].status).toBe('Needs fixing')
expect(aggregated[0].issue_count).toBe(2) // 2 rows affected (in the same two fields)
})
})

describe('getOverview', () => {
Expand Down

0 comments on commit e8841f1

Please sign in to comment.