Last active
October 9, 2021 22:25
-
-
Save Pyrolistical/238d5d1fd8dceb06c9dbf686bf9cebb3 to your computer and use it in GitHub Desktop.
separate business layer from infrastructure layer after test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {jest} from '@jest/globals' | |
import Service from './service'; | |
test('teams with disqualified players cannot check-in', async () => { | |
const repository = { | |
findDisqualifiedPlayers: jest.fn() | |
.mockResolvedValueOnce([ | |
{ | |
teamID: 'some team id', | |
reason: 'was a big meanie' | |
} | |
]), | |
checkInTeam: jest.fn() | |
}; | |
const service = Service(repository); | |
await expect(service.checkIn('some team id')).rejects.toThrow(); | |
expect(repository.findDisqualifiedPlayers).toHaveBeenNthCalledWith(1, 'some team id'); | |
expect(repository.checkInTeam).not.toHaveBeenCalled(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment