MyCrypto/spec/sagas/rates.spec.ts
Daniel Ternyak e7f88a6a0a
Remove redux-promise-middleware (#1022)
* Use shapeshift for all swaps.

* Replace existing redux-promise-middleware based CCRequest action with saga based action.

* Remove module from package.json, store middleware, webpack_config.

* fix snapshot

* Add return typing

* Add test for saga
2018-02-07 17:59:55 -06:00

28 lines
992 B
TypeScript

import { fetchRatesSaga } from 'sagas/rates';
import { call, put } from 'redux-saga/effects';
import { fetchCCRatesSucceeded, fetchCCRatesFailed, fetchCCRatesRequested } from 'actions/rates';
import { fetchRates } from 'api/rates';
describe('fetch rates saga success', () => {
const saga = fetchRatesSaga(fetchCCRatesRequested());
it('should fetch the rates', () => {
expect(saga.next().value).toEqual(call(fetchRates, []));
});
it('should dispatch a success action', () => {
expect(saga.next({}).value).toEqual(put(fetchCCRatesSucceeded({})));
});
it('should be done', () => {
expect(saga.next().done).toEqual(true);
});
});
describe('fetch rates saga failure', () => {
const saga = fetchRatesSaga(fetchCCRatesRequested());
it('it should throw and dispatch a failure action', () => {
saga.next();
expect(saga.throw!().value).toEqual(put(fetchCCRatesFailed()));
});
it('should be done', () => {
expect(saga.next().done).toEqual(true);
});
});