Skip to content

Commit

Permalink
Remove retrieveQuestionResponseFromApplication
Browse files Browse the repository at this point in the history
As this is no longer being referenced, it's safe to delete.
  • Loading branch information
libuk committed Oct 9, 2023
1 parent b065e2a commit 8d3ba0e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
37 changes: 0 additions & 37 deletions server/utils/applicationUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
getResponses,
getSectionAndTask,
getStatus,
retrieveQuestionResponseFromApplication,
taskResponsesToSummaryListRowItems,
} from './applicationUtils'
import getSections from './assessments/getSections'
Expand Down Expand Up @@ -376,42 +375,6 @@ describe('applicationUtils', () => {
})
})

describe('retrieveQuestionResponseFromApplication', () => {
it("throws a SessionDataError if the property doesn't exist", () => {
const application = applicationFactory.build()
expect(() => retrieveQuestionResponseFromApplication(application, 'basic-information', '')).toThrow(
SessionDataError,
)
})

it('returns the property if it does exist and a question is not provided', () => {
const application = applicationFactory.build({
data: {
'basic-information': { 'my-page': { myPage: 'no' } },
},
})

const questionResponse = retrieveQuestionResponseFromApplication(application, 'basic-information', 'myPage')
expect(questionResponse).toBe('no')
})

it('returns the property if it does exist and a question is provided', () => {
const application = applicationFactory.build({
data: {
'basic-information': { 'my-page': { questionResponse: 'no' } },
},
})

const questionResponse = retrieveQuestionResponseFromApplication(
application,
'basic-information',
'myPage',
'questionResponse',
)
expect(questionResponse).toBe('no')
})
})

describe('taskResponsesToSummaryListRowItems', () => {
it('returns an array of summary list row items', () => {
const taskResponses = [
Expand Down
23 changes: 0 additions & 23 deletions server/utils/applicationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import isAssessment from './assessments/isAssessment'
import { DateFormats } from './dateUtils'
import { SessionDataError, UnknownPageError, UnknownTaskError } from './errors'
import { personName } from './personUtils'
import { kebabCase } from './utils'
import { formatLines } from './viewUtils'
import { embeddedSummaryListItem } from './checkYourAnswersUtils/embeddedSummaryListItem'

Expand Down Expand Up @@ -163,27 +162,6 @@ const firstPageOfApplicationJourney = (application: Application) => {
return paths.applications.show({ id: application.id })
}

/**
* Retrieves response for a given question from the application object.
* @param application the application to fetch the response from.
* @param task the task to retrieve the response for.
* @param page the page that we need the response for in camelCase.
* @param {string} question [question=page] the page that we need the response for. Defaults to the value of `page`.
* @returns the response for the given task/page/question.
*/
const retrieveQuestionResponseFromApplication = <T>(
application: Application,
task: string,
page: string,
question?: string,
) => {
try {
return application.data[task][kebabCase(page)][question || page] as T
} catch (e) {
throw new SessionDataError(`Question ${question} was not found in the session`)
}
}

const taskResponsesToSummaryListRowItems = (
taskResponses: TaskResponse['content'],
): Array<{ key: string; value: HtmlItem }> => {
Expand Down Expand Up @@ -215,6 +193,5 @@ export {
getResponses,
getSectionAndTask,
getStatus,
retrieveQuestionResponseFromApplication,
taskResponsesToSummaryListRowItems,
}

0 comments on commit 8d3ba0e

Please sign in to comment.