From 3e512b9a5172525bf066cc5a8a693855fc76b72a Mon Sep 17 00:00:00 2001 From: Marius Olbertz Date: Thu, 5 Oct 2017 21:30:56 +0200 Subject: [PATCH] Added unittests for aria-invalid in Abide. --- test/javascript/components/abide.js | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/javascript/components/abide.js b/test/javascript/components/abide.js index 37f5c144a..a429bc041 100644 --- a/test/javascript/components/abide.js +++ b/test/javascript/components/abide.js @@ -80,4 +80,54 @@ describe('Abide', function() { plugin.validateInput($html.find("select")).should.equal(false); }); }); + + describe('addErrorClasses()', function() { + it('adds aria-invalid attribute to element', function() { + $html = $('
').appendTo('body'); + plugin = new Foundation.Abide($html, {}); + + plugin.addErrorClasses($html.find('input')); + + $html.find('input').should.have.attr('aria-invalid', 'true') + }); + }); + + describe('removeErrorClasses()', function() { + it('removes aria-invalid attribute from element', function() { + $html = $('
').appendTo('body'); + plugin = new Foundation.Abide($html, {}); + // Add error classes first + plugin.addErrorClasses($html.find('input')); + + plugin.removeErrorClasses($html.find('input')); + + $html.find('input').should.not.have.attr('aria-invalid') + }); + }); + + describe('removeRadioErrorClasses()', function() { + it('removes aria-invalid attribute from radio group', function() { + $html = $('
').appendTo('body'); + plugin = new Foundation.Abide($html, {}); + // Add error classes first + plugin.addErrorClasses($html.find('input')); + + plugin.removeRadioErrorClasses('groupName'); + + $html.find('input').should.not.have.attr('aria-invalid') + }); + }); + + describe('resetForm()', function() { + it('removes aria-invalid attribute from elements', function() { + $html = $('
').appendTo('body'); + plugin = new Foundation.Abide($html, {}); + // Add error classes first + plugin.addErrorClasses($html.find('input')); + + plugin.resetForm(); + + $html.find('input').should.not.have.attr('aria-invalid') + }); + }); }); -- 2.47.2