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 create resolver with tags & filter", async () => {
svc.pubsub.asyncIterator.mockClear();
broker.call.mockClear();
withFilter.mockImplementation((fn1, fn2) => [fn1, fn2]);
const res = svc.createAsyncIteratorResolver("posts.find", ["a", "b"], "posts.filter");
expect(res).toEqual({
subscribe: [expect.any(Function), expect.any(Function)],
resolve: expect.any(Function),
});
// Test first function
expect(res.subscribe[0]()).toBe("iterator-result");
expect(svc.pubsub.asyncIterator).toBeCalledTimes(1);
expect(svc.pubsub.asyncIterator).toBeCalledWith(["a", "b"]);
// Test second function without payload
expect(await res.subscribe[1]()).toBe(false);