Skip to content

Commit

Permalink
chore: add test for no votes case
Browse files Browse the repository at this point in the history
  • Loading branch information
1emu committed Sep 6, 2023
1 parent ad8ed0f commit 7087199
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/back/services/vote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { SNAPSHOT_VOTES_AUGUST_2023 } from '../../utils/votes/utils.testData'

import { VoteService } from './vote'

import clearAllMocks = jest.clearAllMocks

describe('getTopVoters', () => {
const firstOfAugust = Time.utc('2023-08-1T00:00:000Z').toDate()
const { start, end } = getPreviousMonthStartAndEnd(firstOfAugust)
Expand Down Expand Up @@ -63,5 +65,16 @@ describe('getTopVoters', () => {
},
])
})

describe('when there are no votes on the selected time period', () => {
beforeEach(() => {
clearAllMocks()
jest.spyOn(SnapshotService, 'getAllVotesBetweenDates').mockResolvedValue([])
})

it('should return an empty array', async () => {
expect(await get.topVoters).toEqual([])
})
})
})
})

0 comments on commit 7087199

Please sign in to comment.