- )
- .withVariables({
- id: 'pineapple'
- })
- .willRespondWith({
- status: 200,
- headers: {
- 'Content-Type': 'application/json; charset=utf-8'
- },
- body: {
- data: {
- tag: {
- id: like('pineapple'),
- topics: eachLike({
- id: like('cd038ae7-e8b4-4e38-9543-3d697e69ac34'),
- title: like('This topic is about pineapples'),
- updated_at: like(1619978944077),
- ttl: like(3555)
- })
- }
- }
- }
- });
- return await internals.provider.addInteraction(tagQuery);
- });
-
- test('it returns the tag', async () => {
-
- const tag = getTag('pineapple');
- const { counter, promise: resolveAfterTwo } = resolveAfter(2);
- let response = null;
- tag.subscribe((tagValue) => {
-
- response = tagValue;
- counter();
- });
- expect(response.data).toBe(null);
- expect(response.loading).toBe(true);
- expect(response.error).toBe(undefined);
- await resolveAfterTwo;
- expect(response.data).toEqual({
- id: 'pineapple',
- topics: [{
- id: 'cd038ae7-e8b4-4e38-9543-3d697e69ac34',
- title: 'This topic is about pineapples',
- updated_at: 1619978944077,
- ttl: 3555
- }]
- });
- expect(response.loading).toBe(false);
- expect(response.error).toBe(undefined);
- });
- });
- });
-
- describe('When there\'s no data', () => {
-
- describe('GetTag', () => {
-
- beforeAll(async () => {
-
- const tagQuery = new GraphQLInteraction()
- .given('there\'s no data')
- .uponReceiving('a request to get a single tag')
- .withRequest({
- path: '/graphql',
- method: 'POST'
- })
- .withOperation('GetTag')
- .withQuery(
- `query GetTag($id: ID!) {
+ )
+ .withVariables({
+ id: 'pineapple'
+ })
+ .willRespondWith({
+ status: 200,
+ headers: {
+ 'Content-Type': 'application/json; charset=utf-8'
+ },
+ body: {
+ data: {
+ tag: {
+ id: like('pineapple'),
+ topics: eachLike({
+ id: like('cd038ae7-e8b4-4e38-9543-3d697e69ac34'),
+ title: like('This topic is about pineapples'),
+ updated_at: like(1619978944077),
+ ttl: like(3555)
+ })
+ }
+ }
+ }
+ });
+ return await internals.provider.addInteraction(tagQuery);
+ });
+
+ test('it returns the tag', async () => {
+ const tag = getTag('pineapple');
+ const { counter, promise: resolveAfterTwo } = resolveAfter(2);
+ let response = null;
+ tag.subscribe((tagValue) => {
+ response = tagValue;
+ counter();
+ });
+ expect(response.data).toBe(null);
+ expect(response.loading).toBe(true);
+ expect(response.error).toBe(undefined);
+ await resolveAfterTwo;
+ expect(response.data).toEqual({
+ id: 'pineapple',
+ topics: [
+ {
+ id: 'cd038ae7-e8b4-4e38-9543-3d697e69ac34',
+ title: 'This topic is about pineapples',
+ updated_at: 1619978944077,
+ ttl: 3555
+ }
+ ]
+ });
+ expect(response.loading).toBe(false);
+ expect(response.error).toBe(undefined);
+ });
+ });
+ });
+
+ describe("When there's no data", () => {
+ describe('GetTag', () => {
+ beforeAll(async () => {
+ const tagQuery = new GraphQLInteraction()
+ .given("there's no data")
+ .uponReceiving('a request to get a single tag')
+ .withRequest({
+ path: '/graphql',
+ method: 'POST'
+ })
+ .withOperation('GetTag')
+ .withQuery(
+ `query GetTag($id: ID!) {