Merge pull request #1344 from automatisch/test/healthcheck-query
test: Add test for healthcheck graphQL query
This commit is contained in:
		| @@ -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'; | ||||||
|   | |||||||
| @@ -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'; | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								packages/backend/src/graphql/queries/healthcheck.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/backend/src/graphql/queries/healthcheck.test.ts
									
									
									
									
									
										Normal 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); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
		Reference in New Issue
	
	Block a user
	 Ömer Faruk Aydın
					Ömer Faruk Aydın