Merge pull request #1344 from automatisch/test/healthcheck-query

test: Add test for healthcheck graphQL query
This commit is contained in:
Ömer Faruk Aydın
2023-10-14 21:20:55 +02:00
committed by GitHub
3 changed files with 28 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ import createRole from '../../../test/fixtures/role';
import createUser from '../../../test/fixtures/user'; import createUser from '../../../test/fixtures/user';
import { IRole, IUser } from '@automatisch/types'; import { IRole, IUser } from '@automatisch/types';
describe('getCurrentUser', () => { describe('graphQL getCurrentUser query', () => {
describe('with unauthorized user', () => { describe('with unauthorized user', () => {
it('should throw not authorized error', async () => { it('should throw not authorized error', async () => {
const invalidUserToken = 'invalid-token'; const invalidUserToken = 'invalid-token';

View File

@@ -7,7 +7,7 @@ import createPermission from '../../../test/fixtures/permission';
import createUser from '../../../test/fixtures/user'; import createUser from '../../../test/fixtures/user';
import { IRole, IUser } from '@automatisch/types'; import { IRole, IUser } from '@automatisch/types';
describe('getUser', () => { describe('graphQL getUser query', () => {
describe('with unauthorized user', () => { describe('with unauthorized user', () => {
it('should throw not authorized error', async () => { it('should throw not authorized error', async () => {
const invalidUserId = '123123123'; const invalidUserId = '123123123';

View File

@@ -0,0 +1,26 @@
import request from 'supertest';
import app from '../../app';
import appConfig from '../../config/app';
describe('graphQL healthcheck query', () => {
it('should return application version', async () => {
const query = `
query {
healthcheck {
version
}
}
`;
const response = await request(app)
.post('/graphql')
.send({ query })
.expect(200);
const expectedResponsePayload = {
data: { healthcheck: { version: appConfig.version } },
};
expect(response.body).toEqual(expectedResponsePayload);
});
});