Created
February 8, 2018 16:54
-
-
Save IsTheJack/83cee7280d1538f39c7f8ed06fc21568 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // actions.test.js | |
| // Importando o arquivo onde terá a função acoplada à função testada | |
| import * as punkapi from './path/to/file'; | |
| // Importando o aquivo onde terá a função testada | |
| import * as actions from './actions'; | |
| // Arquivo com as constantes dos types usados nas actions | |
| import * as types from './types'; | |
| // ... | |
| it('must to return success action on success', () => { | |
| jest | |
| .spyOn(punkapi, 'getBeers') | |
| .mockImplementation(() => Promise.resolve({ data: { mock: 'mock' } })); | |
| // Fazendo um mock simples da função de dispatch | |
| const dispatchMock = jest.fn() | |
| // Chamando a função testada e passando o mock do dispatch | |
| const promise = actions.fetchBeers()(dispatchMock); | |
| }); | |
| // ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment