diff --git a/cypress/e2e/01-admin/01-bylaw-maint.cy.js b/cypress/e2e/01-admin/01-bylaw-maint.cy.js index c760ce14..e2c83c61 100644 --- a/cypress/e2e/01-admin/01-bylaw-maint.cy.js +++ b/cypress/e2e/01-admin/01-bylaw-maint.cy.js @@ -33,7 +33,7 @@ describe('Admin - Parking By-Laws', () => { cy.get(".modal [name='bylawNumber']") .invoke('val') .then((bylawNumber) => { - const newBylawDescription = 'Updated By-Law - ' + randomString(); + const newBylawDescription = `Updated By-Law - ${randomString()}`; cy.get(".modal [name='bylawDescription']") .clear() .type(newBylawDescription); diff --git a/cypress/e2e/01-admin/01-bylaw-maint.cy.ts b/cypress/e2e/01-admin/01-bylaw-maint.cy.ts index 2e32f69e..998759fc 100644 --- a/cypress/e2e/01-admin/01-bylaw-maint.cy.ts +++ b/cypress/e2e/01-admin/01-bylaw-maint.cy.ts @@ -49,7 +49,7 @@ describe('Admin - Parking By-Laws', () => { cy.get(".modal [name='bylawNumber']") .invoke('val') .then((bylawNumber: string) => { - const newBylawDescription = 'Updated By-Law - ' + randomString() + const newBylawDescription = `Updated By-Law - ${randomString()}` cy.get(".modal [name='bylawDescription']") .clear() diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index a6fb6d0a..b45934e2 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -1,3 +1,3 @@ import 'cypress-axe'; -export declare const logout: () => void; -export declare const login: (userName: string) => void; +export declare function logout(): void; +export declare function login(userName: string): void; diff --git a/cypress/support/index.js b/cypress/support/index.js index d5a34e3b..f2259b83 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -1,8 +1,8 @@ import 'cypress-axe'; -export const logout = () => { +export function logout() { cy.visit('/logout'); -}; -export const login = (userName) => { +} +export function login(userName) { cy.visit('/login'); cy.get('.message').contains('Testing', { matchCase: false }); cy.get("form [name='userName']").type(userName); @@ -10,4 +10,4 @@ export const login = (userName) => { cy.get('form').submit(); cy.location('pathname').should('not.contain', '/login'); cy.get('.navbar').should('have.length', 1); -}; +} diff --git a/cypress/support/index.ts b/cypress/support/index.ts index cb015101..af063721 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -1,12 +1,10 @@ -/* eslint-disable node/no-unpublished-import */ - import 'cypress-axe' -export const logout = () => { +export function logout(): void { cy.visit('/logout') } -export const login = (userName: string) => { +export function login(userName: string): void { cy.visit('/login') cy.get('.message').contains('Testing', { matchCase: false }) diff --git a/cypress/support/utilities.d.ts b/cypress/support/utilities.d.ts index 356d2e39..9a8d6495 100644 --- a/cypress/support/utilities.d.ts +++ b/cypress/support/utilities.d.ts @@ -1 +1 @@ -export declare const randomString: () => string; +export declare function randomString(): string; diff --git a/cypress/support/utilities.js b/cypress/support/utilities.js index 1669a4ca..9b8cb5db 100644 --- a/cypress/support/utilities.js +++ b/cypress/support/utilities.js @@ -1,3 +1,3 @@ -export const randomString = () => { +export function randomString() { return Math.ceil(Math.random() * 100000).toString(); -}; +} diff --git a/cypress/support/utilities.ts b/cypress/support/utilities.ts index 145d94f1..8e3666c4 100644 --- a/cypress/support/utilities.ts +++ b/cypress/support/utilities.ts @@ -1,3 +1,3 @@ -export const randomString = (): string => { +export function randomString(): string { return Math.ceil(Math.random() * 100_000).toString() } diff --git a/handlers/permissions.js b/handlers/permissions.js index f0b81509..c3fa34cb 100644 --- a/handlers/permissions.js +++ b/handlers/permissions.js @@ -1,39 +1,46 @@ import * as userFunctions from '../helpers/functions.user.js'; +const dashboardRedirectUrl = '/dashboard'; export const adminGetHandler = (request, response, next) => { if (userFunctions.userIsAdmin(request)) { - return next(); + next(); + return; } - return response.redirect('/dashboard'); + response.redirect(dashboardRedirectUrl); }; export const adminPostHandler = (request, response, next) => { if (userFunctions.userIsAdmin(request)) { - return next(); + next(); + return; } - return response.json(userFunctions.forbiddenJSON); + response.json(userFunctions.forbiddenJSON); }; export const updateGetHandler = (request, response, next) => { if (userFunctions.userCanUpdate(request)) { - return next(); + next(); + return; } - return response.redirect('/dashboard'); + response.redirect(dashboardRedirectUrl); }; export const updateOrOperatorGetHandler = (request, response, next) => { if (userFunctions.userCanUpdate(request) || userFunctions.userIsOperator(request)) { - return next(); + next(); + return; } - return response.redirect('/dashboard'); + response.redirect(dashboardRedirectUrl); }; export const updatePostHandler = (request, response, next) => { if (userFunctions.userCanUpdate(request)) { - return next(); + next(); + return; } - return response.json(userFunctions.forbiddenJSON); + response.json(userFunctions.forbiddenJSON); }; export const updateOrOperatorPostHandler = (request, response, next) => { if (userFunctions.userCanUpdate(request) || userFunctions.userIsOperator(request)) { - return next(); + next(); + return; } - return response.json(userFunctions.forbiddenJSON); + response.json(userFunctions.forbiddenJSON); }; diff --git a/handlers/permissions.ts b/handlers/permissions.ts index 02343b35..5373bb3c 100644 --- a/handlers/permissions.ts +++ b/handlers/permissions.ts @@ -2,28 +2,33 @@ import type { RequestHandler } from 'express' import * as userFunctions from '../helpers/functions.user.js' +const dashboardRedirectUrl = '/dashboard' + export const adminGetHandler: RequestHandler = (request, response, next) => { if (userFunctions.userIsAdmin(request)) { - return next() + next() + return } - return response.redirect('/dashboard') + response.redirect(dashboardRedirectUrl) } export const adminPostHandler: RequestHandler = (request, response, next) => { if (userFunctions.userIsAdmin(request)) { - return next() + next() + return } - return response.json(userFunctions.forbiddenJSON) + response.json(userFunctions.forbiddenJSON) } export const updateGetHandler: RequestHandler = (request, response, next) => { if (userFunctions.userCanUpdate(request)) { - return next() + next() + return } - return response.redirect('/dashboard') + response.redirect(dashboardRedirectUrl) } export const updateOrOperatorGetHandler: RequestHandler = ( @@ -35,18 +40,20 @@ export const updateOrOperatorGetHandler: RequestHandler = ( userFunctions.userCanUpdate(request) || userFunctions.userIsOperator(request) ) { - return next() + next() + return } - return response.redirect('/dashboard') + response.redirect(dashboardRedirectUrl) } export const updatePostHandler: RequestHandler = (request, response, next) => { if (userFunctions.userCanUpdate(request)) { - return next() + next() + return } - return response.json(userFunctions.forbiddenJSON) + response.json(userFunctions.forbiddenJSON) } export const updateOrOperatorPostHandler: RequestHandler = ( @@ -58,8 +65,9 @@ export const updateOrOperatorPostHandler: RequestHandler = ( userFunctions.userCanUpdate(request) || userFunctions.userIsOperator(request) ) { - return next() + next() + return } - return response.json(userFunctions.forbiddenJSON) + response.json(userFunctions.forbiddenJSON) } diff --git a/handlers/reports-all/reportName.js b/handlers/reports-all/reportName.js index 14b1324b..91194229 100644 --- a/handlers/reports-all/reportName.js +++ b/handlers/reports-all/reportName.js @@ -1,5 +1,5 @@ -import * as parkingDB_reporting from '../../database/parkingDB-reporting.js'; import papaparse from 'papaparse'; +import * as parkingDB_reporting from '../../database/parkingDB-reporting.js'; export const handler = (request, response) => { const reportName = request.params.reportName; const rows = parkingDB_reporting.getReportData(reportName, request.query); @@ -8,7 +8,7 @@ export const handler = (request, response) => { return; } const csv = papaparse.unparse(rows); - response.setHeader('Content-Disposition', 'attachment; filename=' + reportName + '-' + Date.now().toString() + '.csv'); + response.setHeader('Content-Disposition', `attachment; filename=${reportName}-${Date.now().toString()}.csv`); response.setHeader('Content-Type', 'text/csv'); response.send(csv); }; diff --git a/handlers/reports-all/reportName.ts b/handlers/reports-all/reportName.ts index 1c3b65e5..4d70ddbe 100644 --- a/handlers/reports-all/reportName.ts +++ b/handlers/reports-all/reportName.ts @@ -1,13 +1,15 @@ import type { RequestHandler } from 'express' +import papaparse from 'papaparse' import * as parkingDB_reporting from '../../database/parkingDB-reporting.js' -import papaparse from 'papaparse' - export const handler: RequestHandler = (request, response) => { const reportName = request.params.reportName - const rows = parkingDB_reporting.getReportData(reportName, request.query as Record) + const rows = parkingDB_reporting.getReportData( + reportName, + request.query as Record + ) if (!rows) { response.redirect('/reports/?error=reportNotAvailable') @@ -18,7 +20,7 @@ export const handler: RequestHandler = (request, response) => { response.setHeader( 'Content-Disposition', - 'attachment; filename=' + reportName + '-' + Date.now().toString() + '.csv' + `attachment; filename=${reportName}-${Date.now().toString()}.csv` ) response.setHeader('Content-Type', 'text/csv') diff --git a/handlers/tickets-ontario-get/convict.js b/handlers/tickets-ontario-get/convict.js index c5c6aab7..38c7f36c 100644 --- a/handlers/tickets-ontario-get/convict.js +++ b/handlers/tickets-ontario-get/convict.js @@ -1,5 +1,5 @@ -import * as parkingDB_ontario from '../../database/parkingDB-ontario.js'; import { getConvictionBatch } from '../../database/parkingDB/getConvictionBatch.js'; +import * as parkingDB_ontario from '../../database/parkingDB-ontario.js'; export const handler = (_request, response) => { const tickets = parkingDB_ontario.getParkingTicketsAvailableForMTOConvictionBatch(); const batch = getConvictionBatch(-1); diff --git a/handlers/tickets-ontario-get/convict.ts b/handlers/tickets-ontario-get/convict.ts index 526871a2..4509b182 100644 --- a/handlers/tickets-ontario-get/convict.ts +++ b/handlers/tickets-ontario-get/convict.ts @@ -1,8 +1,7 @@ import type { RequestHandler } from 'express' -import * as parkingDB_ontario from '../../database/parkingDB-ontario.js' - import { getConvictionBatch } from '../../database/parkingDB/getConvictionBatch.js' +import * as parkingDB_ontario from '../../database/parkingDB-ontario.js' export const handler: RequestHandler = (_request, response) => { const tickets = diff --git a/handlers/tickets-post/doQuickReconcileMatches.js b/handlers/tickets-post/doQuickReconcileMatches.js index 06f60d13..78c066ac 100644 --- a/handlers/tickets-post/doQuickReconcileMatches.js +++ b/handlers/tickets-post/doQuickReconcileMatches.js @@ -1,6 +1,6 @@ import { createParkingTicketStatus } from '../../database/parkingDB/createParkingTicketStatus.js'; import { getOwnershipReconciliationRecords } from '../../database/parkingDB/getOwnershipReconciliationRecords.js'; -import * as ownerFunctions from '../../helpers/functions.owner.js'; +import { getFormattedOwnerAddress } from '../../helpers/functions.owner.js'; export const handler = (request, response) => { const records = getOwnershipReconciliationRecords(); const statusRecords = []; @@ -8,7 +8,7 @@ export const handler = (request, response) => { if (!record.isVehicleMakeMatch || !record.isLicencePlateExpiryDateMatch) { continue; } - const ownerAddress = ownerFunctions.getFormattedOwnerAddress(record); + const ownerAddress = getFormattedOwnerAddress(record); const statusResponse = createParkingTicketStatus({ recordType: 'status', ticketID: record.ticket_ticketID, diff --git a/handlers/tickets-post/doQuickReconcileMatches.ts b/handlers/tickets-post/doQuickReconcileMatches.ts index 03c99250..6b872531 100644 --- a/handlers/tickets-post/doQuickReconcileMatches.ts +++ b/handlers/tickets-post/doQuickReconcileMatches.ts @@ -2,7 +2,7 @@ import type { RequestHandler } from 'express' import { createParkingTicketStatus } from '../../database/parkingDB/createParkingTicketStatus.js' import { getOwnershipReconciliationRecords } from '../../database/parkingDB/getOwnershipReconciliationRecords.js' -import * as ownerFunctions from '../../helpers/functions.owner.js' +import { getFormattedOwnerAddress } from '../../helpers/functions.owner.js' export const handler: RequestHandler = (request, response) => { const records = getOwnershipReconciliationRecords() @@ -14,7 +14,7 @@ export const handler: RequestHandler = (request, response) => { continue } - const ownerAddress = ownerFunctions.getFormattedOwnerAddress(record) + const ownerAddress = getFormattedOwnerAddress(record) const statusResponse = createParkingTicketStatus( { diff --git a/helpers/functions.config.d.ts b/helpers/functions.config.d.ts index bad0d95c..b475344c 100644 --- a/helpers/functions.config.d.ts +++ b/helpers/functions.config.d.ts @@ -12,7 +12,7 @@ export declare function getConfigProperty(propertyName: 'parkingTickets.ticketNu export declare function getConfigProperty(propertyName: 'parkingTicketStatuses'): ConfigParkingTicketStatus[]; export declare function getConfigProperty(propertyName: 'users.testing' | 'users.canLogin' | 'users.canUpdate' | 'users.isAdmin' | 'users.isOperator'): string[]; export declare const keepAliveMillis: number; -export declare const getParkingTicketStatus: (statusKey: string) => ConfigParkingTicketStatus | undefined; +export declare function getParkingTicketStatus(statusKey: string): ConfigParkingTicketStatus | undefined; interface LicencePlateLocationProperties { licencePlateCountryAlias: string; licencePlateProvinceAlias: string; @@ -22,5 +22,5 @@ interface LicencePlateLocationProperties { backgroundColor: string; }; } -export declare const getLicencePlateLocationProperties: (originalLicencePlateCountry: string, originalLicencePlateProvince: string) => LicencePlateLocationProperties; +export declare function getLicencePlateLocationProperties(originalLicencePlateCountry: string, originalLicencePlateProvince: string): LicencePlateLocationProperties; export {}; diff --git a/helpers/functions.config.js b/helpers/functions.config.js index edb16721..ae11e024 100644 --- a/helpers/functions.config.js +++ b/helpers/functions.config.js @@ -57,7 +57,7 @@ export const keepAliveMillis = getConfigProperty('session.doKeepAlive') : 0; const parkingTicketStatusMap = new Map(); let parkingTicketStatusMapIsLoaded = false; -export const getParkingTicketStatus = (statusKey) => { +export function getParkingTicketStatus(statusKey) { if (!parkingTicketStatusMapIsLoaded) { const parkingTicketStatusList = getConfigProperty('parkingTicketStatuses'); for (const parkingTicketStatusObject of parkingTicketStatusList) { @@ -66,8 +66,8 @@ export const getParkingTicketStatus = (statusKey) => { parkingTicketStatusMapIsLoaded = true; } return parkingTicketStatusMap.get(statusKey); -}; -export const getLicencePlateLocationProperties = (originalLicencePlateCountry, originalLicencePlateProvince) => { +} +export function getLicencePlateLocationProperties(originalLicencePlateCountry, originalLicencePlateProvince) { const licencePlateProvinceDefault = { provinceShortName: originalLicencePlateProvince, color: '#000', @@ -79,16 +79,18 @@ export const getLicencePlateLocationProperties = (originalLicencePlateCountry, o let licencePlateProvinceAlias = originalLicencePlateProvince; if (Object.hasOwn(getConfigProperty('licencePlateProvinceAliases'), licencePlateCountryAlias)) { licencePlateProvinceAlias = - getConfigProperty('licencePlateProvinceAliases')[licencePlateCountryAlias][originalLicencePlateProvince.toUpperCase()] || originalLicencePlateProvince; + getConfigProperty('licencePlateProvinceAliases')[licencePlateCountryAlias][originalLicencePlateProvince.toUpperCase()] || + originalLicencePlateProvince; } let licencePlateProvince = licencePlateProvinceDefault; if (Object.hasOwn(getConfigProperty('licencePlateProvinces'), licencePlateCountryAlias)) { licencePlateProvince = - getConfigProperty('licencePlateProvinces')[licencePlateCountryAlias].provinces[licencePlateProvinceAlias] || licencePlateProvinceDefault; + getConfigProperty('licencePlateProvinces')[licencePlateCountryAlias] + .provinces[licencePlateProvinceAlias] || licencePlateProvinceDefault; } return { licencePlateCountryAlias, licencePlateProvinceAlias, licencePlateProvince }; -}; +} diff --git a/helpers/functions.config.ts b/helpers/functions.config.ts index ddccdfef..3a587b26 100644 --- a/helpers/functions.config.ts +++ b/helpers/functions.config.ts @@ -194,9 +194,9 @@ export const keepAliveMillis = getConfigProperty('session.doKeepAlive') const parkingTicketStatusMap = new Map() let parkingTicketStatusMapIsLoaded = false -export const getParkingTicketStatus = ( +export function getParkingTicketStatus( statusKey: string -): ConfigParkingTicketStatus | undefined => { +): ConfigParkingTicketStatus | undefined { if (!parkingTicketStatusMapIsLoaded) { const parkingTicketStatusList = getConfigProperty('parkingTicketStatuses') @@ -223,10 +223,10 @@ interface LicencePlateLocationProperties { } } -export const getLicencePlateLocationProperties = ( +export function getLicencePlateLocationProperties( originalLicencePlateCountry: string, originalLicencePlateProvince: string -): LicencePlateLocationProperties => { +): LicencePlateLocationProperties { const licencePlateProvinceDefault = { provinceShortName: originalLicencePlateProvince, color: '#000', @@ -234,7 +234,6 @@ export const getLicencePlateLocationProperties = ( } // Get the country alias - const licencePlateCountryAlias: string = Object.hasOwn( getConfigProperty('licencePlateCountryAliases'), originalLicencePlateCountry.toUpperCase() @@ -245,7 +244,6 @@ export const getLicencePlateLocationProperties = ( : originalLicencePlateCountry // Get the province alias - let licencePlateProvinceAlias = originalLicencePlateProvince if ( @@ -255,13 +253,13 @@ export const getLicencePlateLocationProperties = ( ) ) { licencePlateProvinceAlias = - getConfigProperty('licencePlateProvinceAliases')[licencePlateCountryAlias][ - originalLicencePlateProvince.toUpperCase() - ] || originalLicencePlateProvince + getConfigProperty('licencePlateProvinceAliases')[ + licencePlateCountryAlias + ][originalLicencePlateProvince.toUpperCase()] || + originalLicencePlateProvince } // Get the province object - let licencePlateProvince = licencePlateProvinceDefault if ( @@ -271,13 +269,11 @@ export const getLicencePlateLocationProperties = ( ) ) { licencePlateProvince = - getConfigProperty('licencePlateProvinces')[licencePlateCountryAlias].provinces[ - licencePlateProvinceAlias - ] || licencePlateProvinceDefault + getConfigProperty('licencePlateProvinces')[licencePlateCountryAlias] + .provinces[licencePlateProvinceAlias] || licencePlateProvinceDefault } // Return - return { licencePlateCountryAlias, licencePlateProvinceAlias, diff --git a/helpers/functions.mto.d.ts b/helpers/functions.mto.d.ts index 40a6de75..8df13807 100644 --- a/helpers/functions.mto.d.ts +++ b/helpers/functions.mto.d.ts @@ -31,5 +31,4 @@ interface ImportLicencePlateOwnershipResult { } export declare const importLicencePlateOwnership: (batchID: number, ownershipData: string, sessionUser: PTSUser) => ImportLicencePlateOwnershipResult; export declare function exportLicencePlateBatch(batchID: number, sessionUser: PTSUser): string; -export declare const exportConvictionBatch: (batchID: number, sessionUser: PTSUser) => string; export {}; diff --git a/helpers/functions.mto.js b/helpers/functions.mto.js index 548f2f25..20ec764a 100644 --- a/helpers/functions.mto.js +++ b/helpers/functions.mto.js @@ -1,9 +1,7 @@ import * as dateTimeFns from '@cityssm/utils-datetime'; import sqlite from 'better-sqlite3'; import { parkingDB as databasePath } from '../data/databasePaths.js'; -import { getConvictionBatch } from '../database/parkingDB/getConvictionBatch.js'; import { getLookupBatch } from '../database/parkingDB/getLookupBatch.js'; -import { markConvictionBatchAsSent } from '../database/parkingDB/markConvictionBatchAsSent.js'; import { markLookupBatchAsSent } from '../database/parkingDB/markLookupBatchAsSent.js'; import { getConfigProperty } from './functions.config.js'; let currentDate; @@ -253,8 +251,3 @@ export function exportLicencePlateBatch(batchID, sessionUser) { const batch = getLookupBatch(batchID); return exportBatch(batch.sentDate, batch.mto_includeLabels, batch.batchEntries); } -export const exportConvictionBatch = (batchID, sessionUser) => { - markConvictionBatchAsSent(batchID, sessionUser); - const batch = getConvictionBatch(batchID); - return exportBatch(batch.sentDate, true, batch.batchEntries); -}; diff --git a/helpers/functions.mto.ts b/helpers/functions.mto.ts index 20bd6546..5fcb1a1e 100644 --- a/helpers/functions.mto.ts +++ b/helpers/functions.mto.ts @@ -5,15 +5,9 @@ import * as dateTimeFns from '@cityssm/utils-datetime' import sqlite from 'better-sqlite3' import { parkingDB as databasePath } from '../data/databasePaths.js' -import { getConvictionBatch } from '../database/parkingDB/getConvictionBatch.js' import { getLookupBatch } from '../database/parkingDB/getLookupBatch.js' -import { markConvictionBatchAsSent } from '../database/parkingDB/markConvictionBatchAsSent.js' import { markLookupBatchAsSent } from '../database/parkingDB/markLookupBatchAsSent.js' -import type { - LicencePlateLookupBatch, - ParkingTicketConvictionBatch, - ParkingTicketStatusLog -} from '../types/recordTypes.js' +import type { LicencePlateLookupBatch } from '../types/recordTypes.js' import { getConfigProperty } from './functions.config.js' @@ -551,21 +545,3 @@ export function exportLicencePlateBatch( batch.batchEntries ) } - -/** - * @deprecated - */ -export const exportConvictionBatch = ( - batchID: number, - sessionUser: PTSUser -): string => { - markConvictionBatchAsSent(batchID, sessionUser) - - const batch = getConvictionBatch(batchID) as ParkingTicketConvictionBatch - - return exportBatch( - batch.sentDate as number, - true, - batch.batchEntries as ParkingTicketStatusLog[] - ) -} diff --git a/test/mtoFunctions.js b/test/mtoFunctions.js index 30167711..dc46a200 100644 --- a/test/mtoFunctions.js +++ b/test/mtoFunctions.js @@ -5,23 +5,17 @@ describe('helpers/mtoFunctions', () => { describe('#twoDigitYearToFourDigit()', () => { const currentYear = currentDate.getFullYear(); const currentYearTwoDigits = currentYear % 100; - it('(' + currentYearTwoDigits.toString() + ') => ' + currentYear.toString(), () => { + it(`(${currentYearTwoDigits.toString()}) => ${currentYear.toString()}`, () => { assert.strictEqual(mtoFunctions.twoDigitYearToFourDigit(currentYearTwoDigits), currentYear); }); const futureYear = currentYear + 5; const futureYearTwoDigits = futureYear % 100; - it('should convert ' + - futureYearTwoDigits.toString() + - ' to ' + - futureYear.toString(), () => { + it(`should convert ${futureYearTwoDigits.toString()} to ${futureYear.toString()}`, () => { assert.strictEqual(mtoFunctions.twoDigitYearToFourDigit(futureYearTwoDigits), futureYear); }); const pastYear = currentYear + 15 - 100; const pastYearTwoDigits = pastYear % 100; - it('should convert ' + - pastYearTwoDigits.toString() + - ' to ' + - pastYear.toString(), () => { + it(`should convert ${pastYearTwoDigits.toString()} to ${pastYear.toString()}`, () => { assert.strictEqual(mtoFunctions.twoDigitYearToFourDigit(pastYearTwoDigits), pastYear); }); }); @@ -30,10 +24,7 @@ describe('helpers/mtoFunctions', () => { (currentDate.getMonth() + 1) * 100 + currentDate.getDate(); const currentDateSixDigits = Number.parseInt(currentDateEightDigits.toString().slice(-6), 10); - it('should convert ' + - currentDateSixDigits.toString() + - ' to ' + - currentDateEightDigits.toString(), () => { + it(`should convert ${currentDateSixDigits.toString()} to ${currentDateEightDigits.toString()}`, () => { assert.strictEqual(mtoFunctions.sixDigitDateNumberToEightDigit(currentDateSixDigits), currentDateEightDigits); }); }); diff --git a/test/mtoFunctions.ts b/test/mtoFunctions.ts index b7a5e683..014ad710 100644 --- a/test/mtoFunctions.ts +++ b/test/mtoFunctions.ts @@ -9,15 +9,12 @@ describe('helpers/mtoFunctions', () => { const currentYear = currentDate.getFullYear() const currentYearTwoDigits = currentYear % 100 - it( - '(' + currentYearTwoDigits.toString() + ') => ' + currentYear.toString(), - () => { - assert.strictEqual( - mtoFunctions.twoDigitYearToFourDigit(currentYearTwoDigits), - currentYear - ) - } - ) + it(`(${currentYearTwoDigits.toString()}) => ${currentYear.toString()}`, () => { + assert.strictEqual( + mtoFunctions.twoDigitYearToFourDigit(currentYearTwoDigits), + currentYear + ) + }) // Two digit years more than 10 years in the future // are considered in the past. @@ -25,34 +22,22 @@ describe('helpers/mtoFunctions', () => { const futureYear = currentYear + 5 const futureYearTwoDigits = futureYear % 100 - it( - 'should convert ' + - futureYearTwoDigits.toString() + - ' to ' + - futureYear.toString(), - () => { - assert.strictEqual( - mtoFunctions.twoDigitYearToFourDigit(futureYearTwoDigits), - futureYear - ) - } - ) + it(`should convert ${futureYearTwoDigits.toString()} to ${futureYear.toString()}`, () => { + assert.strictEqual( + mtoFunctions.twoDigitYearToFourDigit(futureYearTwoDigits), + futureYear + ) + }) const pastYear = currentYear + 15 - 100 const pastYearTwoDigits = pastYear % 100 - it( - 'should convert ' + - pastYearTwoDigits.toString() + - ' to ' + - pastYear.toString(), - () => { - assert.strictEqual( - mtoFunctions.twoDigitYearToFourDigit(pastYearTwoDigits), - pastYear - ) - } - ) + it(`should convert ${pastYearTwoDigits.toString()} to ${pastYear.toString()}`, () => { + assert.strictEqual( + mtoFunctions.twoDigitYearToFourDigit(pastYearTwoDigits), + pastYear + ) + }) }) describe('#sixDigitDateNumberToEightDigit()', () => { @@ -66,18 +51,12 @@ describe('helpers/mtoFunctions', () => { 10 ) - it( - 'should convert ' + - currentDateSixDigits.toString() + - ' to ' + - currentDateEightDigits.toString(), - () => { - assert.strictEqual( - mtoFunctions.sixDigitDateNumberToEightDigit(currentDateSixDigits), - currentDateEightDigits - ) - } - ) + it(`should convert ${currentDateSixDigits.toString()} to ${currentDateEightDigits.toString()}`, () => { + assert.strictEqual( + mtoFunctions.sixDigitDateNumberToEightDigit(currentDateSixDigits), + currentDateEightDigits + ) + }) }) describe('#parsePKRD()', () => {