Skip to content

Instantly share code, notes, and snippets.

@laurelnaiad laurelnaiad/test.ts
Created Apr 1, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.