diff --git a/app/javascript/__tests__/validated_form.test.js b/app/javascript/__tests__/validated_form.test.js index a8b9f68ab1..15d5ddc359 100644 --- a/app/javascript/__tests__/validated_form.test.js +++ b/app/javascript/__tests__/validated_form.test.js @@ -369,12 +369,24 @@ describe('NonDrivingContactMediumWarning', () => { let component beforeEach(() => { - component = new NonDrivingContactMediumWarning(validatedFormCollection.find('.contact-medium.form-group input:not([type=hidden]), #case_contact_miles_driven'), notifier) + component = new NonDrivingContactMediumWarning($('.contact-medium.form-group input:not([type=hidden]), #case_contact_miles_driven'), notifier) }) test('returns the warning message if a non driving contact medium is selected and the miles driven count is > 0', (done) => { $(() => { try { + expect(nonDrivingOptions.length).toBeGreaterThan(0) + + milesDrivenInput.val(1) + + nonDrivingOptions.each(function () { + const option = $(this) + + option.trigger('click') + + expect(component.getWarningState()).toBe('You requested driving reimbursement for a contact medium that typically does not involve driving. Are you sure that\'s right?') + }) + done() } catch (error) { done(error)