+ });
+ return await internals.provider.addInteraction(forumQuery);
+ });
+
+ test('it returns the forum', async () => {
+
+ const forum = getForum('freezer');
+ const { counter, promise: resolveAfterTwo } = resolveAfter(2);
+ let response = null;
+ forum.subscribe((forumsValue) => {
+
+ response = forumsValue;
+ counter();
+ });
+ expect(response.data).toBe(null);
+ expect(response.loading).toBe(true);
+ expect(response.error).toBe(undefined);
+ await resolveAfterTwo;
+ expect(response.data).toBe(null);
+ expect(response.loading).toBe(false);
+ expect(response.error).toBe(undefined);
+ });
+ });
+ });
+
+ describe('When there\'s an error', () => {
+
+ describe('GetForums', () => {
+
+ beforeAll(async () => {
+
+ const forumQuery = new GraphQLInteraction()
+ .given('there\'s an error')
+ .uponReceiving('a request to list the forums')
+ .withRequest({
+ path: '/graphql',
+ method: 'POST'
+ })
+ .withOperation('GetForums')
+ .withQuery(
+ `query GetForums {
+ forums {
+ id
+ glyph
+ label
+ position
+ __typename
+ }
+ }`
+ )
+ .withVariables({})
+ .willRespondWith({
+ status: 500
+ });
+ return await internals.provider.addInteraction(forumQuery);
+ });
+
+ test('it returns the error', async () => {
+
+ const forums = getForums();
+ const { counter, promise: resolveAfterTwo } = resolveAfter(2);
+ let response = null;
+ forums.subscribe((forumsValue) => {
+
+ response = forumsValue;
+ counter();