Skip to content

Commit

Permalink
filled in showUserWarning tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Nov 15, 2023
1 parent 40c2b01 commit e3652b6
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion app/javascript/__tests__/validated_form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,26 @@ describe('NonDrivingContactMediumWarning', () => {
})

describe('showUserWarning', () => {
test('', (done) => {
let component
let notifierElement

beforeEach(() => {
$(() => {
component = new NonDrivingContactMediumWarning($('.contact-medium.form-group input:not([type=hidden]), #case_contact_miles_driven'), notifier)
notifierElement = $('#notifications')
})
})

test('it shows the user a warning through the notifier', (done) => {
$(() => {
try {
const warningText = 'Q~Au\\`FMET"["8.JKB_M'

component.showUserWarning(warningText)

const notifications = notifierElement.find('.warning-notification')
expect(notifications[0].innerHTML).toContain(warningText)

done()
} catch (error) {
done(error)
Expand All @@ -488,6 +505,14 @@ describe('NonDrivingContactMediumWarning', () => {
test('idempotence test', (done) => {
$(() => {
try {
const warningText = 'Q~Au\\`FMET"["8.JKB_M'

component.showUserWarning(warningText)
component.showUserWarning(warningText)

const notifications = notifierElement.find('.warning-notification')
expect(notifications.length).toBe(1)

done()
} catch (error) {
done(error)
Expand Down

0 comments on commit e3652b6

Please sign in to comment.