@kenniy/godeye-data-contracts
Version:
Enterprise-grade base repository architecture for GOD-EYE microservices with zero overhead and maximum code reuse
88 lines (87 loc) • 3.15 kB
JavaScript
;
/**
* Bootstrap System Tests
* Tests the application bootstrap functionality
*/
Object.defineProperty(exports, "__esModule", { value: true });
const app_bootstrap_1 = require("../setup/app.bootstrap");
// Mock module for testing
class TestModule {
}
describe('Bootstrap System', () => {
let app;
describe('bootstrap function', () => {
it('should create and configure a NestJS application', async () => {
const config = {
serviceName: 'test-service',
port: 3999,
enableSwagger: false, // Disable for testing
corsEnabled: false
};
// Note: In a real test, we would mock NestFactory.create
// For now, this is a structure test
expect(typeof app_bootstrap_1.bootstrap).toBe('function');
expect(config.serviceName).toBe('test-service');
});
it('should handle custom swagger configuration', () => {
const config = {
serviceName: 'test-service',
swagger: {
enabled: true,
title: 'Custom API',
description: 'Custom description',
version: '2.0.0',
path: 'api-docs'
}
};
expect(config.swagger?.title).toBe('Custom API');
expect(config.swagger?.path).toBe('api-docs');
});
it('should handle CORS configuration', () => {
const config = {
serviceName: 'test-service',
cors: {
enabled: true,
origins: ['http://localhost:3000'],
credentials: true
}
};
expect(config.cors?.origins).toContain('http://localhost:3000');
expect(config.cors?.credentials).toBe(true);
});
it('should handle validation configuration', () => {
const config = {
serviceName: 'test-service',
validation: {
whitelist: true,
forbidNonWhitelisted: true,
transform: true
}
};
expect(config.validation?.whitelist).toBe(true);
expect(config.validation?.transform).toBe(true);
});
});
describe('BootstrapConfig interface', () => {
it('should require serviceName', () => {
const config = {
serviceName: 'required-service'
};
expect(config.serviceName).toBe('required-service');
});
it('should have optional port with default behavior', () => {
const configWithPort = {
serviceName: 'test-service',
port: 4000
};
const configWithoutPort = {
serviceName: 'test-service'
};
expect(configWithPort.port).toBe(4000);
expect(configWithoutPort.port).toBeUndefined();
});
});
afterEach(async () => {
// No cleanup needed for structure tests
});
});