2023-06-08 20:42:58 +03:00
|
|
|
import type { INestApplication } from '@nestjs/common';
|
2023-09-29 06:02:26 +03:00
|
|
|
import ava, { type TestFn } from 'ava';
|
2023-04-19 02:14:25 +03:00
|
|
|
import request from 'supertest';
|
|
|
|
|
2024-01-14 08:47:56 +03:00
|
|
|
import { AppModule } from '../src/app.module';
|
2024-01-11 09:40:55 +03:00
|
|
|
import { createTestingApp } from './utils';
|
2023-04-19 02:14:25 +03:00
|
|
|
|
|
|
|
const gql = '/graphql';
|
|
|
|
|
2023-09-08 08:15:33 +03:00
|
|
|
const test = ava as TestFn<{
|
|
|
|
app: INestApplication;
|
|
|
|
}>;
|
2023-04-19 02:14:25 +03:00
|
|
|
|
2023-09-08 08:15:33 +03:00
|
|
|
test.beforeEach(async t => {
|
2024-01-11 09:40:55 +03:00
|
|
|
const { app } = await createTestingApp({
|
2023-09-01 22:41:29 +03:00
|
|
|
imports: [AppModule],
|
2023-04-19 02:14:25 +03:00
|
|
|
});
|
2024-01-11 09:40:55 +03:00
|
|
|
|
|
|
|
t.context.app = app;
|
2023-09-01 22:41:29 +03:00
|
|
|
});
|
2023-04-19 02:14:25 +03:00
|
|
|
|
2023-09-11 12:30:39 +03:00
|
|
|
test.afterEach.always(async t => {
|
2023-09-08 08:15:33 +03:00
|
|
|
await t.context.app.close();
|
2023-09-01 22:41:29 +03:00
|
|
|
});
|
2023-04-19 02:14:25 +03:00
|
|
|
|
2023-09-05 11:01:45 +03:00
|
|
|
test('should init app', async t => {
|
2023-09-08 08:15:33 +03:00
|
|
|
await request(t.context.app.getHttpServer())
|
2023-09-01 22:41:29 +03:00
|
|
|
.post(gql)
|
|
|
|
.send({
|
|
|
|
query: `
|
2023-04-28 02:02:05 +03:00
|
|
|
query {
|
|
|
|
error
|
|
|
|
}
|
|
|
|
`,
|
2023-09-01 22:41:29 +03:00
|
|
|
})
|
|
|
|
.expect(400);
|
2023-04-28 02:02:05 +03:00
|
|
|
|
2024-03-12 13:00:09 +03:00
|
|
|
const response = await request(t.context.app.getHttpServer())
|
2023-09-01 22:41:29 +03:00
|
|
|
.post(gql)
|
|
|
|
.send({
|
2024-03-12 13:00:09 +03:00
|
|
|
query: `query {
|
|
|
|
serverConfig {
|
|
|
|
name
|
|
|
|
version
|
|
|
|
type
|
|
|
|
features
|
2023-04-19 02:14:25 +03:00
|
|
|
}
|
2024-03-12 13:00:09 +03:00
|
|
|
}`,
|
2023-09-01 22:41:29 +03:00
|
|
|
})
|
2024-03-12 13:00:09 +03:00
|
|
|
.expect(200);
|
2023-06-21 09:08:32 +03:00
|
|
|
|
2024-03-12 13:00:09 +03:00
|
|
|
const config = response.body.data.serverConfig;
|
2023-06-21 09:08:32 +03:00
|
|
|
|
2024-03-12 13:00:09 +03:00
|
|
|
t.is(config.type, 'Affine');
|
|
|
|
t.true(Array.isArray(config.features));
|
2023-04-19 02:14:25 +03:00
|
|
|
});
|