Skip to content

Commit

Permalink
fix(app): amend back link
Browse files Browse the repository at this point in the history
  • Loading branch information
Demwunz committed Feb 15, 2024
1 parent 1316424 commit c4f44e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/validators/return-requirements/setup.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const VALID_VALUES = [
function go (data) {
const errorMessage = 'Select how you want to set up the return requirement'
const schema = Joi.object({
reason: Joi.string()
setup: Joi.string()
.required()
.valid(...VALID_VALUES)
.messages({
Expand Down
4 changes: 2 additions & 2 deletions app/views/return-requirements/setup.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{
govukBackLink({
text: 'Back',
href: '/system/return-requirements/' + id + '/reason'
href: rootLink + '/reason'
})
}}
{% endblock %}
Expand All @@ -32,7 +32,7 @@
<div class="govuk-body">
<form method="post">
{{ govukRadios({
name: "reason",
name: "setup",
errorMessage: error,
fieldset: {
legend: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Submit Setup service', () => {
describe('with a valid payload', () => {
beforeEach(() => {
payload = {
reason: 'use_abstraction_data'
setup: 'use_abstraction_data'
}
})

Expand Down
12 changes: 6 additions & 6 deletions test/validators/no-returns-required/setup.validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ const { expect } = Code
// Thing under test
const SetupValidator = require('../../../app/validators/return-requirements/setup.validator.js')

describe('Reason validator', () => {
describe.only('Setup validator', () => {
describe('when valid data is provided', () => {
it('confirms the data is valid', () => {
const result = SetupValidator.go({ reason: 'use_abstraction_data' })
const result = SetupValidator.go({ setup: 'use_abstraction_data' })

expect(result.value).to.exist()
expect(result.error).not.to.exist()
})
})

describe('when valid data is provided', () => {
describe("because no 'reason' is given", () => {
describe("because no 'setup' is given", () => {
it('fails validation', () => {
const result = SetupValidator.go({ reason: '' })
const result = SetupValidator.go({ setup: '' })

expect(result.value).to.exist()
expect(result.error).to.exist()
expect(result.error.details[0].message).to.equal('Select how you want to set up the return requirement')
})
})

describe("because an unknown 'reason' is given", () => {
describe("because an unknown 'setup' is given", () => {
it('fails validation', () => {
const result = SetupValidator.go({ reason: 'just-because' })
const result = SetupValidator.go({ setup: 'just-because' })

expect(result.value).to.exist()
expect(result.error).to.exist()
Expand Down

0 comments on commit c4f44e6

Please sign in to comment.