UNPKG

rx-elasticsearch

Version:

RxJS Observables for the Elasticsearch client

26 lines (22 loc) 736 B
import 'expectations'; import * as sinon from 'sinon'; import * as elasticsearch from 'elasticsearch'; import {Search} from '../src/Search'; describe("Basic search wrap test", () => { let client:any = new elasticsearch.Client({}); let response = { hits: {hits: [{}, {}, {}, {}, {}]} }; beforeEach(() => { sinon .stub(client, 'search', null) .returns(Promise.resolve(response)); }); it('check if search is successfully wrapped to an observable', () => { return Search .search({}, client) .do((res) => expect(res).toEqual(response)) .toPromise() .then(() => expect(client.search.calledOnce).toBe(true)) }); });