Skip to content

Commit

Permalink
Merge pull request #157 from shivanshuit914/feature/text-prefix
Browse files Browse the repository at this point in the history
feat: add prefix for the input text
  • Loading branch information
georgeeker authored Feb 19, 2024
2 parents c03a486 + d1e57f4 commit 9afe2c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/hmpo-text/macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
hmpoGetOptions(ctx, params, "label")
),
hint: hmpoGetOptions(ctx, params, "hint", true),
prefix: hmpoGetOptions(ctx, params, "prefix", true),
value: hmpoGetValue(ctx, params),
errorMessage: hmpoGetError(ctx, params),
type: params.type,
Expand Down
10 changes: 10 additions & 0 deletions components/hmpo-text/spec.macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ describe('hmpoText', () => {
expect($hint.length).to.equal(0);
});

it('renders with label and prefix', () => {
const $ = render({ component: 'hmpoText', params: { id: 'my-input' }, ctx: true }, locals);

const $label = $('.govuk-label');
expect($label.text().trim()).to.equal('[fields.my-input.label]');
expect($label.attr('id')).to.equal('my-input-label');
const $prefix = $('.govuk-input__prefix');
expect($prefix.text().trim()).to.equal('[fields.my-input.prefix]');
});

it('renders with value', () => {
const $ = render({ component: 'hmpoText', params: { id: 'my-input' }, ctx: true }, locals);

Expand Down

0 comments on commit 9afe2c7

Please sign in to comment.