From f7993603092f91de768dab6f7fce574785f01961 Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Thu, 4 Jan 2024 14:04:30 +0000 Subject: [PATCH] test re-add unit tests --- test/unit/utils/getRequestData.spec.ts | 23 ------------ .../utils/validateEnvironmentValue.spec.ts | 37 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 test/unit/utils/getRequestData.spec.ts delete mode 100644 test/unit/utils/validateEnvironmentValue.spec.ts diff --git a/test/unit/utils/getRequestData.spec.ts b/test/unit/utils/getRequestData.spec.ts deleted file mode 100644 index 0c98285..0000000 --- a/test/unit/utils/getRequestData.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { describe, test, expect } from '@jest/globals'; -import { getRequestData } from '../../../src/utils/getRequestData'; -import { MOCK_REQUEST } from '../../mock/data.mock'; - -describe('getRequestData test suites', () => { - test('Should extract path and method properties from Request object', () => { - const requestData = getRequestData(MOCK_REQUEST); - - expect(requestData).toMatchObject({ - path: MOCK_REQUEST.path, - method: MOCK_REQUEST.method - }); - }); - - test('Should not return other properties which may be present on Request object', () => { - const requestData = getRequestData(MOCK_REQUEST); - - expect(MOCK_REQUEST).toHaveProperty('body'); - expect(MOCK_REQUEST).toHaveProperty('params'); - expect(requestData).not.toHaveProperty('body'); - expect(requestData).not.toHaveProperty('params'); - }); -}); diff --git a/test/unit/utils/validateEnvironmentValue.spec.ts b/test/unit/utils/validateEnvironmentValue.spec.ts deleted file mode 100644 index bb44e36..0000000 --- a/test/unit/utils/validateEnvironmentValue.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { describe, test, expect } from '@jest/globals'; - -import { validateEnvironmentValue } from '../../../src/utils/validateEnvironmentValue'; -import { MOCK_VALID_LEVEL } from '../../mock/data.mock'; - -describe('validateEnvironmentValue test suites', () => { - test('Should return a valid value', () => { - const validValue = 'debug'; - const validatedValue = validateEnvironmentValue(validValue, Object.keys(MOCK_VALID_LEVEL)); - - expect(validatedValue).toEqual('debug'); - }); - - test('Should throw error if value is invalid and no default value provided', () => { - const invalidValue = 'invalid value'; - - expect(() => { - validateEnvironmentValue(invalidValue, Object.keys(MOCK_VALID_LEVEL)); - }).toThrow(); - }); - - test('Should return default value if value is invalid but default value is provided', () => { - const invalidValue = 'invalid value'; - const defaultValue = 'default value'; - - const validatedValue = validateEnvironmentValue(invalidValue, Object.keys(MOCK_VALID_LEVEL), defaultValue); - - expect(validatedValue).toEqual(defaultValue); - }); - - test('Should return value if value is not lowercase but still valid', () => { - const uppercaseValue = 'ERROR'; - const validatedValue = validateEnvironmentValue(uppercaseValue, Object.keys(MOCK_VALID_LEVEL)); - - expect(validatedValue).toEqual('error'); - }); -});