import gql from 'graphql-tag'; import { execute as executeWithoutAuth, startSession } from 'test/graphql'; jest.mock('../../services/s3'); describe('Query:me', () => { afterEach(() => { jest.restoreAllMocks(); }); const query = gql` query { me { id } } `; test('should return me if signed in', async () => { const { execute, user } = await startSession(); const response = await execute({ query, }); expect(response.errors?.length).toBeFalsy(); expect(response.data?.me.id).toBe(user.id); }); test('should not return me if not signed in', async () => { const response = await executeWithoutAuth({ query, }); expect(response.errors).toHaveLength(1); const errors = response.errors || []; expect(errors[0].message).toMatchSnapshot('no auth error'); expect(response.data?.me).toBeNull(); }); });