Sha256: 6dc74a9fdc65166a01bc41196d5027fe5e6c5e973d02de5863437749d4fb21d6
Contents?: true
Size: 1.06 KB
Versions: 6
Compression:
Stored size: 1.06 KB
Contents
describe("shim-links-with-button-role", function () { var $body; var $buttonLink; var keyupEvent; beforeEach(function () { $buttonLink = $('<a role="button">Button</a>'); $buttonLink.on('click',function(){ $buttonLink.addClass('clicked'); }); $(document.body).append($buttonLink); keyupEvent = $.Event('keyup'); keyupEvent.target = $buttonLink.get(0); GOVUK.shimLinksWithButtonRole.init(); }); afterEach(function () { $buttonLink.remove(); $(document).off('keyup'); }); it('should trigger event on space', function(){ // Ideally we’d test the page loading functionality but that seems hard to // do within a Jasmine context. Settle for checking a bound event trigger. keyupEvent.which = 32; // Space character $(document).trigger(keyupEvent); expect($buttonLink.hasClass('clicked')).toBe(true); }); it('should not trigger event on tab', function(){ keyupEvent.which = 9; // Tab character $(document).trigger(keyupEvent); expect($buttonLink.hasClass('clicked')).toBe(false); }); });
Version data entries
6 entries across 6 versions & 1 rubygems