Initial commit - Event Planner application
This commit is contained in:
159
node_modules/@nestjs/serve-static/tests/e2e/express-adapter.e2e-spec.ts
generated
vendored
Normal file
159
node_modules/@nestjs/serve-static/tests/e2e/express-adapter.e2e-spec.ts
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { Server } from 'net';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { NoopLogger } from '../utils/noop-logger';
|
||||
|
||||
describe('Express adapter', () => {
|
||||
let server: Server;
|
||||
let app: INestApplication;
|
||||
|
||||
describe('when middleware throws generic error', () => {
|
||||
beforeAll(async () => {
|
||||
app = await NestFactory.create(AppModule.withDefaults(), {
|
||||
logger: new NoopLogger()
|
||||
});
|
||||
app.use((_req, _res, next) => next(new Error('Something went wrong')));
|
||||
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
describe('GET /index.html', () => {
|
||||
it('should return Iternal Server Error', async () => {
|
||||
return request(server).get('/index.html').expect(500);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when "fallthrough" option is set to "true"', () => {
|
||||
beforeAll(async () => {
|
||||
app = await NestFactory.create(AppModule.withFallthrough(), {
|
||||
logger: new NoopLogger()
|
||||
});
|
||||
app.setGlobalPrefix('api');
|
||||
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
describe('GET /api', () => {
|
||||
it('should return "Hello, world!"', async () => {
|
||||
return request(server).get('/api').expect(200).expect('Hello, world!');
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /', () => {
|
||||
it('should return HTML file', async () => {
|
||||
return request(server)
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /html/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /index.html', () => {
|
||||
it('should return index page', async () => {
|
||||
return request(server)
|
||||
.get('/index.html')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /html/)
|
||||
.expect(/Static website/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /logo.svg', () => {
|
||||
it('should return logo', async () => {
|
||||
return request(server)
|
||||
.get('/logo.svg')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /image/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when trying to get a non-existing file', () => {
|
||||
it('should return index page', async () => {
|
||||
return request(server)
|
||||
.get('/404')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /html/)
|
||||
.expect(/Static website/);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when "fallthrough" option is set to "false"', () => {
|
||||
beforeAll(async () => {
|
||||
app = await NestFactory.create(AppModule.withoutFallthrough(), {
|
||||
logger: new NoopLogger()
|
||||
});
|
||||
app.setGlobalPrefix('api');
|
||||
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
describe('GET /api', () => {
|
||||
it('should return "Hello, world!"', async () => {
|
||||
return request(server).get('/api').expect(200).expect('Hello, world!');
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /', () => {
|
||||
it('should return HTML file', async () => {
|
||||
return request(server)
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /html/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /index.html', () => {
|
||||
it('should return index page', async () => {
|
||||
return request(server)
|
||||
.get('/index.html')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /html/)
|
||||
.expect(/Static website/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /logo.svg', () => {
|
||||
it('should return logo', async () => {
|
||||
return request(server)
|
||||
.get('/logo.svg')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /image/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when trying to get a non-existing file', () => {
|
||||
it('should return 404', async () => {
|
||||
return request(server)
|
||||
.get('/404')
|
||||
.expect(404)
|
||||
.expect(/Not Found/)
|
||||
.expect(/ENOENT/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when trying to hit a non-existing route under the excluded path', () => {
|
||||
it('should return 404', async () => {
|
||||
return request(server)
|
||||
.get('/api/404')
|
||||
.expect(404)
|
||||
.expect(/Not Found/)
|
||||
.expect(/Cannot GET \/api\/404/);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
193
node_modules/@nestjs/serve-static/tests/e2e/fastify-adapter.e2e-spec.ts
generated
vendored
Normal file
193
node_modules/@nestjs/serve-static/tests/e2e/fastify-adapter.e2e-spec.ts
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import {
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { NoopLogger } from '../utils/noop-logger';
|
||||
import request from 'supertest';
|
||||
|
||||
describe('Fastify adapter', () => {
|
||||
let app: NestFastifyApplication;
|
||||
|
||||
describe('when "fallthrough" option is set to "true"', () => {
|
||||
beforeAll(async () => {
|
||||
app = await NestFactory.create(
|
||||
AppModule.withFallthrough(),
|
||||
new FastifyAdapter(),
|
||||
{
|
||||
logger: new NoopLogger()
|
||||
}
|
||||
);
|
||||
app.setGlobalPrefix('api');
|
||||
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
});
|
||||
|
||||
describe('GET /api', () => {
|
||||
it('should return "Hello, world!"', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/api'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.payload).toEqual('Hello, world!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /', () => {
|
||||
it('should return HTML file', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.headers['content-type']).toMatch(/html/);
|
||||
expect(result.payload).toContain('Static website');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /index.html', () => {
|
||||
it('should return index page', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/index.html'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.payload).toContain('Static website');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /logo.svg', () => {
|
||||
it('should return logo', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/logo.svg'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.headers['content-type']).toMatch(/image/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when trying to get a non-existing file', () => {
|
||||
it('should returns index page', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/404'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.payload).toContain('Static website');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when "fallthrough" option is set to "false"', () => {
|
||||
beforeAll(async () => {
|
||||
app = await NestFactory.create(
|
||||
AppModule.withoutFallthrough(),
|
||||
new FastifyAdapter(),
|
||||
{
|
||||
logger: new NoopLogger()
|
||||
}
|
||||
);
|
||||
app.setGlobalPrefix('api');
|
||||
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
});
|
||||
|
||||
describe('GET /api', () => {
|
||||
it('should return "Hello, world!"', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/api'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.payload).toEqual('Hello, world!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /', () => {
|
||||
it('should return HTML file', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.headers['content-type']).toMatch(/html/);
|
||||
expect(result.payload).toContain('Static website');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /index.html', () => {
|
||||
it('should return index page', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/index.html'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.payload).toContain('Static website');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /logo.svg', () => {
|
||||
it('should return logo', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/logo.svg'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.headers['content-type']).toMatch(/image/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when trying to get a non-existing file', () => {
|
||||
it('should return 404', async () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/404'
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.statusCode).toEqual(404);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user