Matthew Phelan
3 years ago
2 changed files with 18 additions and 4 deletions
@ -1,4 +1,4 @@
|
||||
<div class="govuk-form-group"> |
||||
<label for="numeric_input"><%= label %></label> |
||||
<input id="numeric_input" class="govuk-input govuk-input--width-20" type="number" /> |
||||
<input id="numeric_input" class="govuk-input govuk-input--width-20" type="number" min=<%= minimum %> max=<%= maximum %> /> |
||||
</div> |
@ -1,11 +1,25 @@
|
||||
describe 'questions/_numeric_question.html.erb' do |
||||
context 'when given a label' do |
||||
context 'when given a label and value constraints' do |
||||
let(:label) { "Test Label" } |
||||
let(:min) { "1" } |
||||
let(:max) { "150" } |
||||
let(:locals) { {label: label, minimum: min, maximum: max} } |
||||
|
||||
it 'displays a numeric entry field' do |
||||
render :partial => 'numeric_question', locals: { label: label } |
||||
before(:each) do |
||||
render :partial => 'numeric_question', locals: locals |
||||
end |
||||
|
||||
it 'displays a numeric entry field with a label' do |
||||
expect(rendered).to have_selector('//input[@type="number"]') |
||||
expect(rendered).to have_selector("//label[contains('#{label}')]") |
||||
end |
||||
|
||||
it 'validates for a given minimum input' do |
||||
expect(rendered).to have_selector("//input[@min=#{min}]") |
||||
end |
||||
|
||||
it 'validates for a given maximum input' do |
||||
expect(rendered).to have_selector("//input[@max=#{max}]") |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue