import 'reflect-metadata'; import { CurrentEnvironmentService, } from './current-environment.service'; const initCurrentEnvironmentService = () => { return new CurrentEnvironmentService(); }; describe('isDev', () => { // tslint:disable-next-line test('Returns true if process.env.ENVIRONMENT equals dev', () => { const currentEnvironmentService = initCurrentEnvironmentService(); process.env.ENVIRONMENT = 'dev'; const result = currentEnvironmentService.isDev(); expect(result).toBe(true); }); // tslint:disable-next-line test('Returns false if process.env.ENVIRONMENT does not equal dev', () => { const currentEnvironmentService = initCurrentEnvironmentService(); process.env.ENVIRONMENT = 'NOTDEV'; const result = currentEnvironmentService.isDev(); expect(result).toBe(false); }); }); describe('isStaging', () => { // tslint:disable-next-line test('Returns true if process.env.ENVIRONMENT equals staging', () => { const currentEnvironmentService = initCurrentEnvironmentService(); process.env.ENVIRONMENT = 'staging'; const result = currentEnvironmentService.isStaging(); expect(result).toBe(true); }); // tslint:disable-next-line test('Returns false if process.env.ENVIRONMENT does not equal staging', () => { const currentEnvironmentService = initCurrentEnvironmentService(); process.env.ENVIRONMENT = 'NOTSTAGING'; const result = currentEnvironmentService.isStaging(); expect(result).toBe(false); }); }); describe('isProduction', () => { // tslint:disable-next-line test('Returns true if process.env.ENVIRONMENT equals production', () => { const currentEnvironmentService = initCurrentEnvironmentService(); process.env.ENVIRONMENT = 'production'; const result = currentEnvironmentService.isProduction(); expect(result).toBe(true); }); // tslint:disable-next-line test('Returns false if process.env.ENVIRONMENT does not equal production', () => { const currentEnvironmentService = initCurrentEnvironmentService(); process.env.ENVIRONMENT = 'NOTPRODUCTION'; const result = currentEnvironmentService.isProduction(); expect(result).toBe(false); }); });