- )
- .withVariables({
- id: 'freezer'
- })
- .willRespondWith({
- status: 200,
- headers: {
- 'Content-Type': 'application/json; charset=utf-8'
- },
- body: {
- data: {
- forum: like({
- id: 'freezer',
- glyph: like('✭'),
- label: like('test_forums.freezer'),
- position: like(3),
- topics: eachLike({
- id: like('629de02c-151a-4db7-bb86-43b2add8a15a'),
- title: like('Very pacty topic'),
- updated_at: like(1619954611616),
- ttl: like(3601)
- })
- })
- }
- }
- });
- 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.id).toBe('freezer');
- expect(response.data.glyph).toBe('✭');
- expect(response.data.label).toBe('test_forums.freezer');
- expect(response.data.position).toBe(3);
- expect(response.data.topics).toEqual(expect.arrayContaining([{
- id: '629de02c-151a-4db7-bb86-43b2add8a15a',
- title: 'Very pacty topic',
- updated_at: 1619954611616,
- ttl: 3601
- }]));
- expect(response.loading).toBe(false);
- expect(response.error).toBe(undefined);
- });
- });
- });
-
- describe('When there\'s no data', () => {
-
- describe('GetForums', () => {
-
- beforeAll(async () => {
-
- const forumQuery = new GraphQLInteraction()
- .given('there\'s no data')
- .uponReceiving('a request to list the forums')
- .withRequest({
- path: '/graphql',
- method: 'POST'
- })
- .withOperation('GetForums')
- .withQuery(
- `query GetForums {
+ )
+ .withVariables({
+ id: 'freezer'
+ })
+ .willRespondWith({
+ status: 200,
+ headers: {
+ 'Content-Type': 'application/json; charset=utf-8'
+ },
+ body: {
+ data: {
+ forum: like({
+ id: 'freezer',
+ glyph: like('✭'),
+ label: like('test_forums.freezer'),
+ position: like(3),
+ topics: eachLike({
+ id: like('629de02c-151a-4db7-bb86-43b2add8a15a'),
+ title: like('Very pacty topic'),
+ updated_at: like(1619954611616),
+ ttl: like(3601)
+ })
+ })
+ }
+ }
+ });
+ 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.id).toBe('freezer');
+ expect(response.data.glyph).toBe('✭');
+ expect(response.data.label).toBe('test_forums.freezer');
+ expect(response.data.position).toBe(3);
+ expect(response.data.topics).toEqual(
+ expect.arrayContaining([
+ {
+ id: '629de02c-151a-4db7-bb86-43b2add8a15a',
+ title: 'Very pacty topic',
+ updated_at: 1619954611616,
+ ttl: 3601
+ }
+ ])
+ );
+ expect(response.loading).toBe(false);
+ expect(response.error).toBe(undefined);
+ });
+ });
+ });
+
+ describe("When there's no data", () => {
+ describe('GetForums', () => {
+ beforeAll(async () => {
+ const forumQuery = new GraphQLInteraction()
+ .given("there's no data")
+ .uponReceiving('a request to list the forums')
+ .withRequest({
+ path: '/graphql',
+ method: 'POST'
+ })
+ .withOperation('GetForums')
+ .withQuery(
+ `query GetForums {