diff --git a/src/config/index.ts b/src/config/index.ts index d444037..a5299b3 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,6 +1,6 @@ import { getEnvironmentValue } from '../utils/getEnvironmentValue'; -export const SERVICE_NAME = 'GitHub Requests Application '; +export const SERVICE_NAME = 'GitHub Requests'; export const PATH_SSL_PRIVATE_KEY = getEnvironmentValue('PATH_SSL_PRIVATE_KEY', 'false'); export const PATH_SSL_CERTIFICATE = getEnvironmentValue('PATH_SSL_CERTIFICATE', 'false'); @@ -19,16 +19,13 @@ export const START = 'start'; export const HOME = 'home'; export const ADD_MEMBER = 'add-member'; export const REMOVE_MEMBER = 'remove-member'; -export const MEMBER_REQUST = 'member-request'; export const NOT_FOUND = 'page-not-found'; export const NOT_AVAILABLE = 'not-available'; export const ERROR_PAGE = 'error'; export const CONFIRMATION = 'confirmation'; export const ADD_TEAM = 'add-team'; -export const TEAM_REQUEST = 'team-request'; export const ADD_TEAM_MEMBER = 'add-team-member'; export const ADD_REPO = 'add-repo'; -export const REPO_REQUEST = 'repo-request'; // Routing paths @@ -36,14 +33,11 @@ export const START_URL = '/start'; export const HOME_URL = '/home'; export const ADD_MEMBER_URL = '/add-member'; export const REMOVE_MEMBER_URL = '/remove-member'; -export const MEMBER_REQUST_URL = '/member-request'; export const HEALTHCHECK_URL = '/healthcheck'; export const CONFIRMATION_URL = '/confirmation'; export const ADD_TEAM_URL = '/add-team'; -export const TEAM_REQUEST_URL = '/team-request'; export const ADD_TEAM_MEMBER_URL = '/add-team-member'; export const ADD_REPO_URL = '/add-repo'; -export const REPO_REQUEST_URL = '/repo-request'; export const SERVICE_URL = `${BASE_URL}${CONFIRMATION_URL}`; diff --git a/src/controller/member-request.controller.ts b/src/controller/member-request.controller.ts deleted file mode 100644 index 4eacf0b..0000000 --- a/src/controller/member-request.controller.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Request, Response } from 'express'; -import { log } from '../utils/logger'; -import * as config from '../config'; - -export const get = (_req: Request, res: Response) => { - return res.render(config.MEMBER_REQUST); -}; - -export const post = (req: Request, res: Response) => { - - const githubHandle = req.body.github_handle; - - // validation middleware and data assignment to be implemented - - log.info(`GitHub Handle: ${githubHandle}`); - - return res.redirect(config.HOME); -}; diff --git a/src/controller/repo-request.controller.ts b/src/controller/repo-request.controller.ts deleted file mode 100644 index 874f9a2..0000000 --- a/src/controller/repo-request.controller.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Request, Response } from 'express'; -import { log } from '../utils/logger'; -import * as config from '../config'; - -export const get = (_req: Request, res: Response) => { - return res.render(config.REPO_REQUEST); -}; - -export const post = (req: Request, res: Response) => { - - const repoName = req.body.repo_name; - - // validation middleware and data assignment to be implemented - - log.info(`Repository Name: ${repoName}`); - - return res.redirect(config.HOME); -}; diff --git a/src/controller/team-request.controller.ts b/src/controller/team-request.controller.ts deleted file mode 100644 index 3753999..0000000 --- a/src/controller/team-request.controller.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Request, Response } from 'express'; -import { log } from '../utils/logger'; -import * as config from '../config'; - -export const get = (_req: Request, res: Response) => { - return res.render(config.TEAM_REQUEST); -}; - -export const post = (req: Request, res: Response) => { - - const teamName = req.body.team_name; - - // validation middleware and data assignment to be implemented - - log.info(`Team Name: ${teamName}`); - - return res.redirect(config.HOME); -}; diff --git a/src/routes/index.ts b/src/routes/index.ts index 663693b..8d6e022 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -10,10 +10,7 @@ import addRepoRouter from './add-repo'; import addMemberRouter from './add-member'; import addTeamRouter from './add-team'; import removeMemberRouter from './remove-member'; -import teamRequestRouter from './team-request'; import addTeamMemberRouter from './add-team-member'; -import memberRequestRouter from './member-request'; -import repoRequestRouter from './repo-request'; const router = Router(); @@ -29,9 +26,6 @@ router.use(healthcheckRouter); router.use(addRepoRouter); router.use(addTeamRouter); router.use(removeMemberRouter); -router.use(teamRequestRouter); router.use(addTeamMemberRouter); -router.use(memberRequestRouter); -router.use(repoRequestRouter); export default router; diff --git a/src/routes/member-request.ts b/src/routes/member-request.ts deleted file mode 100644 index 2862d73..0000000 --- a/src/routes/member-request.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Router } from 'express'; - -import { authentication } from '../middleware/authentication.middleware'; - -import { get, post } from '../controller/member-request.controller'; -import * as config from '../config'; -import { memberRequest } from '../validation/member-request.validation'; -import { checkValidations } from '../middleware/validation.middleware'; - -const memberRequestRouter = Router(); - -memberRequestRouter.get(config.MEMBER_REQUST_URL, authentication, get); -memberRequestRouter.post(config.MEMBER_REQUST_URL, authentication, ...memberRequest, checkValidations, post); - -export default memberRequestRouter; diff --git a/src/routes/repo-request.ts b/src/routes/repo-request.ts deleted file mode 100644 index 11c634f..0000000 --- a/src/routes/repo-request.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Router } from 'express'; - -import { authentication } from '../middleware/authentication.middleware'; - -import { get, post } from '../controller/repo-request.controller'; -import * as config from '../config'; -import { repoRequest } from '../validation/repo-request.validation'; -import { checkValidations } from '../middleware/validation.middleware'; - -const addRepoRouter = Router(); - -addRepoRouter.get(config.REPO_REQUEST_URL, authentication, get); -addRepoRouter.post(config.REPO_REQUEST_URL, authentication, ...repoRequest, checkValidations, post); - -export default addRepoRouter; diff --git a/src/routes/team-request.ts b/src/routes/team-request.ts deleted file mode 100644 index 973c42d..0000000 --- a/src/routes/team-request.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Router } from 'express'; - -import { authentication } from '../middleware/authentication.middleware'; -import { checkValidations } from '../middleware/validation.middleware'; -import { teamRequest } from '../validation/team-request.validation'; -import { get, post } from '../controller/team-request.controller'; -import * as config from '../config'; - -const teamRequestRouter = Router(); - -teamRequestRouter.get(config.TEAM_REQUEST_URL, authentication, get); -teamRequestRouter.post(config.TEAM_REQUEST_URL, authentication, ...teamRequest, checkValidations, post); - -export default teamRequestRouter; diff --git a/src/validation/member-request.validation.ts b/src/validation/member-request.validation.ts deleted file mode 100644 index ea2f5a7..0000000 --- a/src/validation/member-request.validation.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { descriptionValidation } from './fields/description.validation'; -import { githubHandleValidation } from './fields/github-handle.validation'; - -export const memberRequest = [ - ...githubHandleValidation, ...descriptionValidation -]; diff --git a/src/validation/repo-request.validation.ts b/src/validation/repo-request.validation.ts deleted file mode 100644 index 041aa61..0000000 --- a/src/validation/repo-request.validation.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { descriptionValidation } from './fields/description.validation'; -import { repoNameValidation } from './fields/repo-name.validation'; - -export const repoRequest = [ - ...repoNameValidation, ...descriptionValidation -]; diff --git a/src/validation/team-request.validation.ts b/src/validation/team-request.validation.ts deleted file mode 100644 index b9a6a50..0000000 --- a/src/validation/team-request.validation.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { descriptionValidation } from './fields/description.validation'; -import { teamNameValidation } from './fields/team-name.validation'; - -export const teamRequest = [ - ...teamNameValidation, ...descriptionValidation -]; diff --git a/src/views/home.html b/src/views/home.html index 4faa096..6a9e07b 100644 --- a/src/views/home.html +++ b/src/views/home.html @@ -3,53 +3,42 @@ {% block content %}
-
- -

GitHub request application

-

This application has been designed to streamline and enhance the management of GitHub member requests. This tool will allow GitHub administrators to efficiently handle member-related tasks, including adding, deleting, and amending user permissions.

-

- Please choose from one of the following options: -

-

Member Requests

-
-{% endblock %} \ No newline at end of file + +{% endblock %} diff --git a/src/views/member-request.html b/src/views/member-request.html deleted file mode 100644 index fcf4935..0000000 --- a/src/views/member-request.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "layout.html" %} - -{% block beforeContent %} - {% include "include/back-link.html" %} -{% endblock %} - -{% block content %} -
-
-

Additional Member Requests

- -

- To request a more specific member request that is not covered by the other options. -

- - {% include "include/error-list.html" %} - -
- - {% set githubHandleText = "GitHub Handle" %} - {% include "include/inputs/github-handle.html" %} - - {% set descriptionText = "Description - Permission changes (required)" %} - {% set descriptionHint = "Explain the reason for making this member request." %} - - {% include "include/description.html" %} - - {% include "include/save-button.html" %} - -
-
-
-{% endblock %} diff --git a/src/views/repo-request.html b/src/views/repo-request.html deleted file mode 100644 index 64e8aab..0000000 --- a/src/views/repo-request.html +++ /dev/null @@ -1,32 +0,0 @@ -{% extends "layout.html" %} - -{% block beforeContent %} - {% include "include/back-link.html" %} -{% endblock %} - -{% block content %} -
-
-

Additional Repository Requests

- -

- Use this page for more specific repository requests which are not covered by the other options. -

- - {% include "include/error-list.html" %} - -
- - {% include "include/inputs/repo-name.html" %} - - {% set descriptionText = "Description - Permission changes (required)" %} - {% set descriptionHint = "Explain the reason for making this repository request." %} - - {% include "include/description.html" %} - - {% include "include/save-button.html" %} - -
-
-
-{% endblock %} \ No newline at end of file diff --git a/src/views/team-request.html b/src/views/team-request.html deleted file mode 100644 index 6468250..0000000 --- a/src/views/team-request.html +++ /dev/null @@ -1,32 +0,0 @@ -{% extends "layout.html" %} - -{% block beforeContent %} - {% include "include/back-link.html" %} -{% endblock %} - -{% block content %} -
-
-

Additional Team Request

- -

- Use this page to request a more specific request that is not covered by the other options. -

- - {% include "include/error-list.html" %} - -
- - {% include "include/inputs/team-name.html" %} - - {% set descriptionText = "Description - Permission changes (required)" %} - {% set descriptionHint = "Explain the reason for making this team request (e.g. parent team changes)." %} - - {% include "include/description.html" %} - - {% include "include/save-button.html" %} - -
-
-
-{% endblock %} diff --git a/test/integration/routes/member-request.spec.ts b/test/integration/routes/member-request.spec.ts deleted file mode 100644 index e7d1d92..0000000 --- a/test/integration/routes/member-request.spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -jest.mock('../../../src/middleware/logger.middleware'); -jest.mock('../../../src/middleware/authentication.middleware'); -jest.mock('../../../src/utils/logger'); - -import { jest, beforeEach, describe, expect, test } from '@jest/globals'; -import { Request, Response, NextFunction } from 'express'; -import request from 'supertest'; - -import app from '../../../src/app'; -import * as config from '../../../src/config'; -import { logger } from '../../../src/middleware/logger.middleware'; -import { log } from '../../../src/utils/logger'; -import { authentication } from '../../../src/middleware/authentication.middleware'; - -import { MOCK_REDIRECT_MESSAGE, MOCK_GET_MEMBER_REQUEST_RESPONSE, MOCK_POST_MEMBER_REQUEST_RESPONSE } from '../../mock/text.mock'; -import { MOCK_POST_MEMBER_REQUEST } from '../../mock/data'; -import { ErrorMessages } from '../../../src/validation/error.messages'; - -const mockedLogger = logger as jest.Mock; -mockedLogger.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); -const mockedAuth = authentication as jest.Mock; -mockedAuth.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next()); - -describe('Member-request endpoint integration tests', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - describe('GET tests', () => { - test('renders the member-request page', async () => { - const res = await request(app).get(config.MEMBER_REQUST_URL); - - expect(res.status).toEqual(200); - expect(res.text).toContain(MOCK_GET_MEMBER_REQUEST_RESPONSE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - }); - describe('POST tests', () => { - test('Should redirect to home page after POST request', async () => { - const res = await request(app).post(config.MEMBER_REQUST_URL).send(MOCK_POST_MEMBER_REQUEST); - - expect(res.status).toEqual(302); - expect(res.text).toContain(MOCK_REDIRECT_MESSAGE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - test('Should render the same page with error messages after POST request', async () => { - const res = await request(app).post(config.MEMBER_REQUST_URL).send({ - github_handle: '', - description: '1000chars.'.repeat(100) + ':)' - }); - - expect(res.status).toEqual(200); - expect(res.text).toContain(ErrorMessages.GIT_HANDLE); - expect(res.text).toContain(ErrorMessages.DESCRIPTION_LENGTH); - expect(res.text).toContain(MOCK_GET_MEMBER_REQUEST_RESPONSE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - - test('Should log the github handle and on POST request.', async () => { - const res = await request(app).post(config.MEMBER_REQUST_URL).send(MOCK_POST_MEMBER_REQUEST); - - const mockLog = log.info as jest.Mock; - - expect(mockLog).toBeCalledWith(MOCK_POST_MEMBER_REQUEST_RESPONSE); - expect(res.text).toContain(MOCK_REDIRECT_MESSAGE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - }); -}); diff --git a/test/integration/routes/repo-request.spec.ts b/test/integration/routes/repo-request.spec.ts deleted file mode 100644 index 840d0e8..0000000 --- a/test/integration/routes/repo-request.spec.ts +++ /dev/null @@ -1,74 +0,0 @@ -jest.mock('../../../src/middleware/logger.middleware'); -jest.mock('../../../src/middleware/authentication.middleware'); -jest.mock('../../../src/utils/logger'); - -import { jest, beforeEach, describe, expect, test } from '@jest/globals'; -import { Request, Response, NextFunction } from 'express'; -import request from 'supertest'; - -import app from '../../../src/app'; -import * as config from '../../../src/config'; -import { logger } from '../../../src/middleware/logger.middleware'; -import { log } from '../../../src/utils/logger'; -import { authentication } from '../../../src/middleware/authentication.middleware'; - -import { MOCK_REDIRECT_MESSAGE, MOCK_GET_REPO_REQUEST_RESPONSE, MOCK_POST_REPO_REQUEST_RESPONSE } from '../../mock/text.mock'; -import { MOCK_POST_REPO_REQUEST } from '../../mock/data'; -import { ErrorMessages } from '../../../src/validation/error.messages'; - -const mockedLogger = logger as jest.Mock; -mockedLogger.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next()); -const mockedAuth = authentication as jest.Mock; -mockedAuth.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next()); - -describe('repo-request endpoint integration tests', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - describe('GET tests', () => { - test('renders the repo-request page', async () => { - const res = await request(app).get(config.REPO_REQUEST_URL); - - expect(res.status).toEqual(200); - expect(res.text).toContain(MOCK_GET_REPO_REQUEST_RESPONSE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - }); - describe('POST tests', () => { - test('Should redirect to home page after POST request', async () => { - const res = await request(app).post(config.REPO_REQUEST_URL).send(MOCK_POST_REPO_REQUEST); - - expect(res.status).toEqual(302); - expect(res.text).toContain(MOCK_REDIRECT_MESSAGE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - - test('Should render the same page with error messages after POST request', async () => { - const res = await request(app).post(config.REPO_REQUEST_URL).send({ - repo_name: '', - description: '1000chars.'.repeat(100) + ':)' - }); - - expect(res.status).toEqual(200); - expect(res.text).toContain(ErrorMessages.REPO_NAME); - expect(res.text).toContain(ErrorMessages.DESCRIPTION_LENGTH); - expect(res.text).toContain(MOCK_GET_REPO_REQUEST_RESPONSE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - - test('Should log the repository name and description on POST request', async () => { - const res = await request(app).post(config.REPO_REQUEST_URL).send(MOCK_POST_REPO_REQUEST); - - const mockLog = log.info as jest.Mock; - - expect(mockLog).toBeCalledWith(MOCK_POST_REPO_REQUEST_RESPONSE); - expect(res.text).toContain(MOCK_REDIRECT_MESSAGE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - }); -}); diff --git a/test/integration/routes/team-request.spec.ts b/test/integration/routes/team-request.spec.ts deleted file mode 100644 index 8fd0c8e..0000000 --- a/test/integration/routes/team-request.spec.ts +++ /dev/null @@ -1,72 +0,0 @@ -jest.mock('../../../src/middleware/logger.middleware'); -jest.mock('../../../src/middleware/authentication.middleware'); -jest.mock('../../../src/utils/logger'); - -import { jest, beforeEach, describe, expect, test } from '@jest/globals'; -import { Request, Response, NextFunction } from 'express'; -import request from 'supertest'; - -import app from '../../../src/app'; -import * as config from '../../../src/config'; -import { logger } from '../../../src/middleware/logger.middleware'; -import { log } from '../../../src/utils/logger'; -import { authentication } from '../../../src/middleware/authentication.middleware'; - -import { MOCK_REDIRECT_MESSAGE, MOCK_GET_TEAM_REQUEST_RESPONSE, MOCK_POST_TEAM_REQUEST_RESPONSE } from '../../mock/text.mock'; -import { MOCK_POST_TEAM_REQUEST } from '../../mock/data'; -import { ErrorMessages } from '../../../src/validation/error.messages'; - -const mockedLogger = logger as jest.Mock; -mockedLogger.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); -const mockedAuth = authentication as jest.Mock; -mockedAuth.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next()); - -describe('Team-request endpoint integration tests', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - describe('GET tests', () => { - test('renders the team-request page', async () => { - const res = await request(app).get(config.TEAM_REQUEST_URL); - - expect(res.status).toEqual(200); - expect(res.text).toContain(MOCK_GET_TEAM_REQUEST_RESPONSE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - }); - describe('POST tests', () => { - test('Should redirect to home page after POST request', async () => { - const res = await request(app).post(config.TEAM_REQUEST_URL).send(MOCK_POST_TEAM_REQUEST); - - expect(res.status).toEqual(302); - expect(res.text).toContain(MOCK_REDIRECT_MESSAGE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - test('Should render the same page with error messages after POST request', async () => { - const res = await request(app).post(config.TEAM_REQUEST_URL).send({ - team_name: '', - description: '1000chars.'.repeat(100) + ':)' - }); - - expect(res.status).toEqual(200); - expect(res.text).toContain(ErrorMessages.TEAM_NAME); - expect(res.text).toContain(ErrorMessages.DESCRIPTION_LENGTH); - expect(res.text).toContain(MOCK_GET_TEAM_REQUEST_RESPONSE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - test('Should log the team name and description on POST request.', async () => { - const res = await request(app).post(config.TEAM_REQUEST_URL).send(MOCK_POST_TEAM_REQUEST); - - const mockLog = log.info as jest.Mock; - - expect(mockLog).toBeCalledWith(MOCK_POST_TEAM_REQUEST_RESPONSE); - expect(res.text).toContain(MOCK_REDIRECT_MESSAGE); - expect(mockedLogger).toHaveBeenCalledTimes(1); - expect(mockedAuth).toHaveBeenCalledTimes(1); - }); - }); -}); diff --git a/test/mock/text.mock.ts b/test/mock/text.mock.ts index 480b831..520e786 100644 --- a/test/mock/text.mock.ts +++ b/test/mock/text.mock.ts @@ -1,7 +1,7 @@ export const MOCK_OK_RESPONSE = 'OK'; export const MOCK_GET_CONFIRMATION_RESPONSE = 'GitHub request complete'; export const MOCK_GET_START_RESPONSE = 'GitHub Requests'; -export const MOCK_GET_HOME_RESPONSE = 'GitHub request application'; +export const MOCK_GET_HOME_RESPONSE = 'GitHub Requests'; export const MOCK_GET_ADD_REPO_RESPONSE = 'Add a GitHub Repository'; export const MOCK_POST_ADD_REPO_RESPONSE = 'Repository Name: repo1, Visibility: public'; diff --git a/test/unit/controller/member-request.controller.spec.ts b/test/unit/controller/member-request.controller.spec.ts deleted file mode 100644 index 4087176..0000000 --- a/test/unit/controller/member-request.controller.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -jest.mock('../../../src/utils/logger'); - -import { describe, expect, afterEach, test, jest } from '@jest/globals'; -import { Request, Response } from 'express'; - -import { get, post } from '../../../src/controller/member-request.controller'; -import * as config from '../../../src/config'; -import { log } from '../../../src/utils/logger'; - -import { MOCK_POST_MEMBER_REQUEST } from '../../mock/data'; -import { MOCK_POST_MEMBER_REQUEST_RESPONSE } from '../../mock/text.mock'; - -const req = { - body: MOCK_POST_MEMBER_REQUEST -} as Request; - -const mockResponse = () => { - const res = {} as Response; - res.render = jest.fn().mockReturnValue(res) as any; - res.redirect = jest.fn().mockReturnValue(res) as any; - return res; -}; - -describe('Member-request controller test suites', () => { - afterEach(() => { - jest.resetAllMocks(); - }); - - describe('member-request GET tests', () => { - - test('should render member-request page', () => { - const res = mockResponse(); - - get(req, res); - - expect(res.render).toHaveBeenCalledWith(config.MEMBER_REQUST); - }); - }); - - describe('member-request POST tests', () => { - - test('should redirect to home page on POST request', () => { - const res = mockResponse(); - - post(req, res); - - expect(res.redirect).toBeCalledWith(config.HOME); - }); - test('Should log the github handle on POST request.', () => { - const res = mockResponse(); - - const mockLogInfo = log.info as jest.Mock; - - post(req, res); - - expect(mockLogInfo).toHaveBeenCalledWith(MOCK_POST_MEMBER_REQUEST_RESPONSE); - - }); - }); -}); diff --git a/test/unit/controller/repo-request.controller.spec.ts b/test/unit/controller/repo-request.controller.spec.ts deleted file mode 100644 index 6d768b3..0000000 --- a/test/unit/controller/repo-request.controller.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -jest.mock('../../../src/utils/logger'); -import { describe, expect, afterEach, test, jest } from '@jest/globals'; -import { Request, Response } from 'express'; - -import { get, post } from '../../../src/controller/repo-request.controller'; -import * as config from '../../../src/config'; -import { log } from '../../../src/utils/logger'; - -import { MOCK_POST_REPO_REQUEST } from '../../mock/data'; -import { MOCK_POST_REPO_REQUEST_RESPONSE } from '../../mock/text.mock'; - -const req = { - body: MOCK_POST_REPO_REQUEST -} as Request; - -const mockResponse = () => { - const res = {} as Response; - res.render = jest.fn().mockReturnValue(res) as any; - res.redirect = jest.fn().mockReturnValue(res) as any; - return res; -}; - -describe('repo-request controller test suites', () => { - afterEach(() => { - jest.resetAllMocks(); - }); - - describe('repo-request GET tests', () => { - - test('should render repo request page', () => { - const res = mockResponse(); - - get(req, res); - - expect(res.render).toHaveBeenCalledWith(config.REPO_REQUEST); - }); - }); - - describe('repo-request POST tests', () => { - - test('should redirect to home page on POST request', () => { - const res = mockResponse(); - - post(req, res); - - expect(res.redirect).toBeCalledWith(config.HOME); - }); - test('should log Repository Name on POST request', () => { - const res = mockResponse(); - - const mockLogInfo = log.info as jest.Mock; - - post(req, res); - - expect(mockLogInfo).toHaveBeenCalledWith(MOCK_POST_REPO_REQUEST_RESPONSE); - }); - }); -}); diff --git a/test/unit/controller/team-request.controller.spec.ts b/test/unit/controller/team-request.controller.spec.ts deleted file mode 100644 index d89d951..0000000 --- a/test/unit/controller/team-request.controller.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -jest.mock('../../../src/utils/logger'); - -import { describe, expect, afterEach, test, jest } from '@jest/globals'; -import { Request, Response } from 'express'; - -import { get, post } from '../../../src/controller/team-request.controller'; -import * as config from '../../../src/config'; -import { log } from '../../../src/utils/logger'; - -import { MOCK_POST_TEAM_REQUEST } from '../../mock/data'; -import { MOCK_POST_TEAM_REQUEST_RESPONSE } from '../../mock/text.mock'; - -const req = { - body: MOCK_POST_TEAM_REQUEST -} as Request; - -const mockResponse = () => { - const res = {} as Response; - res.render = jest.fn().mockReturnValue(res) as any; - res.redirect = jest.fn().mockReturnValue(res) as any; - return res; -}; - -describe('Team-request controller test suites', () => { - afterEach(() => { - jest.resetAllMocks(); - }); - - describe('team-request GET tests', () => { - - test('should render team-request page', () => { - const res = mockResponse(); - - get(req, res); - - expect(res.render).toHaveBeenCalledWith(config.TEAM_REQUEST); - }); - }); - - describe('team-request POST tests', () => { - - test('should redirect to home page on POST request', () => { - const res = mockResponse(); - - post(req, res); - - expect(res.redirect).toBeCalledWith(config.HOME); - }); - test('Should log the team name and description on POST request.', () => { - const res = mockResponse(); - - const mockLogInfo = log.info as jest.Mock; - - post(req, res); - - expect(mockLogInfo).toHaveBeenCalledWith(MOCK_POST_TEAM_REQUEST_RESPONSE); - - }); - }); -});