diff --git a/src/__tests__/fetchMore.ts b/src/__tests__/fetchMore.ts index 823f31c5fce..aa74cecfaee 100644 --- a/src/__tests__/fetchMore.ts +++ b/src/__tests__/fetchMore.ts @@ -58,11 +58,9 @@ describe("updateQuery on a simple query", () => { const observable = client.watchQuery({ query }); const stream = new ObservableStream(observable); - { - const result = await stream.takeNext(); - - expect(result.data.entry.value).toBe(1); - } + await expect(stream).toEmitMatchedValue({ + data: { entry: { value: 1 } }, + }); observable.updateQuery((prevResult: any) => { const res = cloneDeep(prevResult); @@ -70,11 +68,9 @@ describe("updateQuery on a simple query", () => { return res; }); - { - const result = await stream.takeNext(); - - expect(result.data.entry.value).toBe(2); - } + await expect(stream).toEmitMatchedValue({ + data: { entry: { value: 2 } }, + }); }); }); @@ -124,11 +120,9 @@ describe("updateQuery on a query with required and optional variables", () => { const stream = new ObservableStream(observable); - { - const result = await stream.takeNext(); - - expect(result.data.entry.value).toBe(1); - } + await expect(stream).toEmitMatchedValue({ + data: { entry: { value: 1 } }, + }); observable.updateQuery((prevResult: any) => { const res = cloneDeep(prevResult); @@ -136,11 +130,9 @@ describe("updateQuery on a query with required and optional variables", () => { return res; }); - { - const result = await stream.takeNext(); - - expect(result.data.entry.value).toBe(2); - } + await expect(stream).toEmitMatchedValue({ + data: { entry: { value: 2 } }, + }); }); }); diff --git a/src/cache/inmemory/__tests__/fragmentRegistry.ts b/src/cache/inmemory/__tests__/fragmentRegistry.ts index 960a0f8216e..b04b57255f7 100644 --- a/src/cache/inmemory/__tests__/fragmentRegistry.ts +++ b/src/cache/inmemory/__tests__/fragmentRegistry.ts @@ -90,35 +90,27 @@ describe("FragmentRegistry", () => { client.watchQuery({ query, fetchPolicy: "cache-and-network" }) ); - { - const result = await stream.takeNext(); - - expect(result).toEqual({ - loading: true, - networkStatus: NetworkStatus.loading, - data: { - __typename: "Query", - source: "local", - }, - }); - } - - { - const result = await stream.takeNext(); - - expect(result).toEqual({ - loading: false, - networkStatus: NetworkStatus.ready, - data: { - __typename: "Query", - source: "link", - }, - }); + await expect(stream).toEmitValue({ + loading: true, + networkStatus: NetworkStatus.loading, + data: { + __typename: "Query", + source: "local", + }, + }); - expect(cache.readQuery({ query })).toEqual({ + await expect(stream).toEmitValue({ + loading: false, + networkStatus: NetworkStatus.ready, + data: { + __typename: "Query", source: "link", - }); - } + }, + }); + + expect(cache.readQuery({ query })).toEqual({ + source: "link", + }); }); it("throws an error when not all used fragments are defined", () => { diff --git a/src/cache/inmemory/__tests__/policies.ts b/src/cache/inmemory/__tests__/policies.ts index 25d7536a06d..701347d2cc8 100644 --- a/src/cache/inmemory/__tests__/policies.ts +++ b/src/cache/inmemory/__tests__/policies.ts @@ -4090,22 +4090,18 @@ describe("type policies", function () { const stream = new ObservableStream(observable); - { - const result = await stream.takeNext(); - - expect(result).toEqual({ - loading: false, - networkStatus: NetworkStatus.ready, - data: { - search: { - edges: firstEdges, - pageInfo: firstPageInfo, - totalCount: 1292, - }, + await expect(stream).toEmitValue({ + loading: false, + networkStatus: NetworkStatus.ready, + data: { + search: { + edges: firstEdges, + pageInfo: firstPageInfo, + totalCount: 1292, }, - }); - expect(cache.extract()).toMatchSnapshot(); - } + }, + }); + expect(cache.extract()).toMatchSnapshot(); observable.fetchMore({ variables: secondVariables });