Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangoulding committed Aug 22, 2024
1 parent 40f96d3 commit 0b96829
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 11 deletions.
5 changes: 5 additions & 0 deletions app/controllers/import.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const ImportLegacyProcessLicenceService = require('../services/import/legacy/pro

/**
* Controller for /import
* @param request - the hapi request object
* @param h - the hapi response object
*
* @returns {object}
*
* @module ImportController
*/
async function licence (request, h) {
Expand Down
5 changes: 4 additions & 1 deletion app/presenters/import/legacy/licence.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function _mapLicence (licence, licenceVersions) {
/**
* Creates a JSON object of the region data
* This is stored as a JSON object in the licence.regions column.
* @param licenceData
*
* @returns {object} - the json structure to persist in the licence.regions column
*/
const _regions = (licenceData) => {
const historicalAreaCode = licenceData.AREP_AREA_CODE
Expand All @@ -56,7 +59,7 @@ const _regions = (licenceData) => {
*
* @param {object} licence - the legacy licence data
* @param {object[]} licenceVersions - the legacy licence versions
* @return {String} YYYY-MM-DD
* @returns {string} YYYY-MM-DD
*/
const _startDate = (licence, licenceVersions) => {
if (licence.ORIG_EFF_DATE !== 'null') {
Expand Down
4 changes: 2 additions & 2 deletions app/services/import/legacy/fetch-licence-versions.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {

/**
* A legacy licence version
* @typedef {Object} ImportLegacyLicenceVersionsType
* @typedef {object} ImportLegacyLicenceVersionsType
*
* @property {string} EFF_END_DATE - date in UK format - can be 'null'
* @property {string} EFF_ST_DATE - date in UK format
Expand All @@ -86,7 +86,7 @@ module.exports = {
*/

/**
* @typedef {Object} ImportLegacyLicenceVersionsPurposesType
* @typedef {object} ImportLegacyLicenceVersionsPurposesType
*
* @property {string} PERIOD_END_DAY - The end day of the period.
* @property {string} PERIOD_END_MONTH - The end month of the period.
Expand Down
2 changes: 1 addition & 1 deletion app/services/import/legacy/fetch-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
/**
* An Import legacy licence
*
* @typedef {Object} ImportLegacyLicenceType
* @typedef {object} ImportLegacyLicenceType
*
* @property {string} AREP_AREA_CODE - historicalAreaCode
* @property {string} AREP_EIUC_CODE - regionPrefix / regionalChargeArea
Expand Down
3 changes: 2 additions & 1 deletion app/services/import/legacy/process-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const { currentTimeInNanoseconds, calculateAndLogTimeTaken } = require('../../..
* Imports a licence from the legacy import tables. Maps and validates the data and then saves to the database.
*
* @param {string} licenceRef - The licence reference of the licence
* @returns {Promise<Object>} an object representing the saved licence in the database
*
* @returns {Promise<object>} an object representing the saved licence in the database
*/
async function go (licenceRef) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Joi = require('joi')
*
* @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If
* any errors are found the `error:` property will also exist detailing what the issues were
*/
*/
function go (data) {
const schema = Joi.object({
licenceVersionPurposeId: Joi.string().guid().optional(),
Expand Down
7 changes: 7 additions & 0 deletions app/validators/import/licence.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const Joi = require('joi')
* @throws {Error} - throw an error if any of the validations fail
*/

/**
* Validate an import licence to persist in the database
*
* @param data
*
* @throws {error} - the first error from the validation failure
*/
function go (data) {
const result = _schema.validate(data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ function _createtLicenceVersion () {
}
}

function create (data) {
/**
* Creates a test import licence versions object with purposes
*
* This is the object we expect to see when we persist the data for the licence versions and purposes
*
* This object should pass the validation
*
* @returns {object} - an import licence object with purposes
*/
function create () {
const defaults = [
{
..._createtLicenceVersion(),
Expand Down
11 changes: 10 additions & 1 deletion test/services/import/_fixtures/import-licence.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ function importLicence () {
}
}

function create (data) {
/**
* Creates a test import licence object
*
* This is the object we expect to see when we persist the data
*
* This object should pass the validation
*
* @returns {object} - an import licence object
*/
function create () {
return {
...importLicence()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ function purpose () {
}
}

function create (data) {
/**
* Creates a test legacy import licence versions purpose object
*
* @returns {object} - a legacy import licence versions purpose object
*/
function create () {
return {
...purpose()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ function legacyLicenceVersionFixture () {
}
}

function create (data) {
/**
* Creates a test legacy import licence versions object
*
* @returns {object} - a legacy import licence versions object
*/
function create () {
return {
...legacyLicenceVersionFixture()
}
Expand Down
7 changes: 6 additions & 1 deletion test/services/import/_fixtures/legacy-licence.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ function legacyLicenceFixture () {
}
}

function create (data) {
/**
* Creates a test legacy import licence object
*
* @returns {object} - a legacy import licence object
*/
function create () {
return {
...legacyLicenceFixture()
}
Expand Down

0 comments on commit 0b96829

Please sign in to comment.