Skip to content

Instantly share code, notes, and snippets.

@Pyrolistical
Last active October 9, 2021 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pyrolistical/238d5d1fd8dceb06c9dbf686bf9cebb3 to your computer and use it in GitHub Desktop.
Save Pyrolistical/238d5d1fd8dceb06c9dbf686bf9cebb3 to your computer and use it in GitHub Desktop.
separate business layer from infrastructure layer after test
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