From 9d347d123460b30d00d78aa8692a567e83eeb324 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Wed, 6 Dec 2023 11:33:00 +0000 Subject: [PATCH] changed myPageController to pageController --- src/controllers/{MyPageController.js => PageController.js} | 4 ++-- src/controllers/datasetController.js | 4 ++-- src/controllers/errorsController.js | 4 ++-- src/controllers/uploadController.js | 4 ++-- src/routes/form-wizard/steps.js | 4 ++-- test/unit/MyController.test.js | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) rename src/controllers/{MyPageController.js => PageController.js} (87%) diff --git a/src/controllers/MyPageController.js b/src/controllers/PageController.js similarity index 87% rename from src/controllers/MyPageController.js rename to src/controllers/PageController.js index 24c08583..82fb3a95 100644 --- a/src/controllers/MyPageController.js +++ b/src/controllers/PageController.js @@ -2,7 +2,7 @@ import hmpoFormWizard from 'hmpo-form-wizard' import logger from '../utils/logger.js' const { Controller } = hmpoFormWizard -class MyPageController extends Controller { +class PageController extends Controller { locals (req, res, callback) { req.form.options.lastPage = req.journeyModel.get('lastVisited') super.locals(req, res, callback) @@ -20,4 +20,4 @@ class MyPageController extends Controller { } } -export default MyPageController +export default PageController diff --git a/src/controllers/datasetController.js b/src/controllers/datasetController.js index d5d83ca3..e419df64 100644 --- a/src/controllers/datasetController.js +++ b/src/controllers/datasetController.js @@ -1,12 +1,12 @@ 'use strict' -import MyPageController from './MyPageController.js' +import PageController from './PageController.js' // ToDo: we shouldn't hardcode these values here, should we get them from the API // maybe take from specification import { dataSubjects } from '../utils/utils.js' -class DatasetController extends MyPageController { +class DatasetController extends PageController { get (req, res, next) { // const dataset = req.sessionModel.get('data-subject') // const options = datasetOptions[dataset] diff --git a/src/controllers/errorsController.js b/src/controllers/errorsController.js index a6de057b..982b329a 100644 --- a/src/controllers/errorsController.js +++ b/src/controllers/errorsController.js @@ -1,10 +1,10 @@ 'use strict' -import MyPageController from './MyPageController.js' +import PageController from './PageController.js' import { severityLevels, dataSubjects } from '../utils/utils.js' -class ErrorsController extends MyPageController { +class ErrorsController extends PageController { get (req, res, next) { const validationResult = req.sessionModel.get('validationResult') diff --git a/src/controllers/uploadController.js b/src/controllers/uploadController.js index 88da8417..49e97c1f 100644 --- a/src/controllers/uploadController.js +++ b/src/controllers/uploadController.js @@ -3,7 +3,7 @@ import multer from 'multer' import axios from 'axios' import { readFile } from 'fs/promises' import { lookup } from 'mime-types' -import MyPageController from './MyPageController.js' +import PageController from './PageController.js' import config from '../../config/index.js' import { severityLevels } from '../utils/utils.js' @@ -13,7 +13,7 @@ const upload = multer({ dest: 'uploads/' }) const apiRoute = config.api.url + config.api.validationEndpoint -class UploadController extends MyPageController { +class UploadController extends PageController { middlewareSetup () { super.middlewareSetup() this.use('/upload', upload.single('datafile')) diff --git a/src/routes/form-wizard/steps.js b/src/routes/form-wizard/steps.js index 6beb0b31..211b69fc 100644 --- a/src/routes/form-wizard/steps.js +++ b/src/routes/form-wizard/steps.js @@ -1,10 +1,10 @@ -import MyPageController from '../../controllers/MyPageController.js' +import PageController from '../../controllers/PageController.js' import datasetController from '../../controllers/datasetController.js' import uploadController from '../../controllers/uploadController.js' import errorsController from '../../controllers/errorsController.js' const baseSettings = { - controller: MyPageController, + controller: PageController, editable: true, editBackStep: 'check' } diff --git a/test/unit/MyController.test.js b/test/unit/MyController.test.js index a729734b..cce0e233 100644 --- a/test/unit/MyController.test.js +++ b/test/unit/MyController.test.js @@ -1,10 +1,10 @@ -import MyPageController from '../../src/controllers/MyPageController.js' +import PageController from '../../src/controllers/PageController.js' import { describe, it, vi, expect } from 'vitest' import logger from '../../src/utils/logger.js' -describe('MyPageController', () => { +describe('PageController', () => { const loggerInfoMock = vi.fn() vi.mock('../utils/logger.js', () => { @@ -21,7 +21,7 @@ describe('MyPageController', () => { sessionID: '123', ip: '1234' } - const pageController = new MyPageController({ + const pageController = new PageController({ route: '/dataset' }) // pageController.super.get = vi.fn();