mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
tests(@nestjs) push basic integration tests
This commit is contained in:
71
integration/microservices/e2e/sum-redis.spec.ts
Normal file
71
integration/microservices/e2e/sum-redis.spec.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import * as express from 'express';
|
||||
import * as request from 'supertest';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Transport } from '@nestjs/microservices';
|
||||
import { RedisController } from '../src/redis/redis.controller';
|
||||
|
||||
describe('REDIS transport', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
controllers: [RedisController],
|
||||
}).compile();
|
||||
|
||||
server = express();
|
||||
app = module.createNestApplication(server);
|
||||
app.connectMicroservice({
|
||||
transport: Transport.REDIS,
|
||||
});
|
||||
await app.startAllMicroservicesAsync();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`/POST`, () => {
|
||||
return request(server)
|
||||
.post('/?command=sum')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (Promise/async)`, () => {
|
||||
return request(server)
|
||||
.post('/?command=asyncSum')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.expect(200)
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (Observable stream)`, () => {
|
||||
return request(server)
|
||||
.post('/?command=streamSum')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (concurrent)`, () => {
|
||||
return request(server)
|
||||
.post('/concurrent')
|
||||
.send([
|
||||
[1, 2, 3, 4, 5],
|
||||
[6, 7, 8, 9, 10],
|
||||
[11, 12, 13, 14, 15],
|
||||
[16, 17, 18, 19, 20],
|
||||
[21, 22, 23, 24, 25],
|
||||
])
|
||||
.expect(200, 'true');
|
||||
});
|
||||
|
||||
it(`/POST (streaming)`, () => {
|
||||
return request(server)
|
||||
.post('/stream')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user