Created
April 1, 2016 22:01
-
-
Save laurelnaiad/3f5e59527cc0863bb7562cbd5fcbdb61 to your computer and use it in GitHub Desktop.
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 {Injector} from 'angular2/core' | |
import RESPOND_PROVIDERS, {Respond} from 'respond-ng' | |
import {SagaTester} from 'store-saga/testing' | |
import * as moment from 'moment' | |
import { actionKeys } from './alertsSchema' | |
import * as saga from './alertsSaga'; | |
import * as schema from './alertsSchema' | |
import * as mocks from './alertsMocks' | |
function sagaTests() { | |
let sagaTester: SagaTester | |
let respond: Respond | |
describe('ALERTS_SEARCH', function () { | |
beforeEach(() => { | |
// spyOn(Cookies, 'set').and.stub() | |
const injector = Injector.resolveAndCreate([ | |
SagaTester, | |
RESPOND_PROVIDERS | |
]) | |
sagaTester = injector.get(SagaTester) | |
respond = injector.get(Respond) | |
sagaTester.run(saga.alertsSearch) | |
sagaTester.run(saga.getOlderRecords) | |
}) | |
it('should search for some alerts', () => { | |
let payload: schema.IPayloadAlertsSearch = { | |
count: 2, | |
from: moment().toISOString(), | |
direction: 'le' | |
} | |
let data: schema.IAlertsSearchResponse= { | |
facets: { | |
category: { 'warning': 8 } | |
}, | |
items: mocks.twoConsecutiveAlerts, | |
estimate: 8 | |
} | |
respond.ok(data).when.post(saga.searchUrl(payload)) | |
sagaTester.sendAction({ type: actionKeys.ALERTS_SEARCH, payload }) | |
expect(sagaTester.last).toEqual({ | |
type: schema.actionKeys.ALERTS_SEARCH_SUCCESS, | |
payload: data | |
}) | |
}); | |
}) | |
} | |
export default function myExport () { | |
return describe('saga', sagaTests) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment