mirror of
https://github.com/aleleba/run-app-from-cdn.git
synced 2025-07-04 17:28:11 -06:00
PR-220602: Adding first commit.
This commit is contained in:
24
__tests__/index.test.ts
Normal file
24
__tests__/index.test.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import request from 'supertest';
|
||||
import express from 'express';
|
||||
import { setRoutes } from '../src/routes/index';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
setRoutes(app);
|
||||
|
||||
describe('GET /', () => {
|
||||
it('should redirect to CDN URL', async () => {
|
||||
const response = await request(app).get('/');
|
||||
expect(response.status).toBe(302);
|
||||
expect(response.header.location).toBe(process.env.CDN_URL);
|
||||
});
|
||||
|
||||
it('should return 500 if CDN URL is not configured', async () => {
|
||||
process.env.CDN_URL = '';
|
||||
const response = await request(app).get('/');
|
||||
expect(response.status).toBe(500);
|
||||
expect(response.text).toBe('CDN URL not configured');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user