Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should call next with multiple results for subscription', done => {
const results = [
{ data: { data: 'result1' } },
{ data: { data: 'result2' } },
];
const client: any = {};
client.__proto__ = SubscriptionClient.prototype;
client.request = jest.fn(() => {
const copy = [...results];
return new Observable(observer => {
observer.next(copy[0]);
observer.next(copy[1]);
});
});
const link = new WebSocketLink(client);
execute(link, { query: subscription }).subscribe(data => {
expect(client.request).toHaveBeenCalledTimes(1);
expect(data).toEqual(results.shift());
if (results.length === 0) {
done();
}
it('constructs', () => {
const client: any = {};
client.__proto__ = SubscriptionClient.prototype;
expect(() => new WebSocketLink(client)).not.toThrow();
});