UNPKG

jquery-touch-fix

Version:

Ensure event.touches are monitored by jQuery touch listeners.

71 lines (66 loc) 1.97 kB
<!doctype html> <html> <head> <title>jquery-touch-fix - Unit tests</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css"> <style> #mocha .test code, #mocha .test pre { white-space:pre-line; } </style> <script type="text/javascript" src="../node_modules/requirejs/require.js"></script> <script type="text/javascript" src="../node_modules/mocha/mocha.js"></script> <script type="text/javascript" src="../node_modules/jquery/dist/jquery.js"></script> </head> <body> <div id="mocha"></div> <script type="text/javascript"> mocha.setup({ ui : 'bdd', reporter : ['html'], globals : ['results'] }); mocha.checkLeaks(); require.config({ baseUrl : '../node_modules/' }); require([ 'chai/chai', '../jquery-touch-fix' ],function( chai, jqueryTouchFix ){ var expect=chai.expect; describe("jquery-touch-fix",function(){ it("add hooks to jQuery.event",function(){ if(jQuery.event && jQuery.event.mouseHooks) { expect(jQuery.event.fixHooks).to.contain.keys( 'touchstart', 'touchend', 'touchmove', 'touchcancel' ); } else { expect(true).to.be.ok; } }); it("should return an instance of jQuery",function(){ expect(jqueryTouchFix).to.equal(jQuery); }); if('ontouchstart' in window){ it("touch events should surface a touches property on the event",function(done){ var evt=document.createEvent('TouchEvent'); evt.initEvent('touchstart'); jQuery(window).on('touchstart',function(e){ expect(e.touches).to.not.equal(undefined); done(); }); window.dispatchEvent(evt); }); } }); mocha.run(); }); </script> </body> </html>