test.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. // These tests expect the DOM to contain a presentation
  2. // with the following slide structure:
  3. //
  4. // 1
  5. // 2 - Three sub-slides
  6. // 3 - Three fragment elements
  7. // 3 - Two fragments with same data-fragment-index
  8. // 4
  9. Reveal.addEventListener( 'ready', function() {
  10. // ---------------------------------------------------------------
  11. // DOM TESTS
  12. QUnit.module( 'DOM' );
  13. test( 'Initial slides classes', function() {
  14. var horizontalSlides = document.querySelectorAll( '.reveal .slides>section' )
  15. strictEqual( document.querySelectorAll( '.reveal .slides section.past' ).length, 0, 'no .past slides' );
  16. strictEqual( document.querySelectorAll( '.reveal .slides section.present' ).length, 1, 'one .present slide' );
  17. strictEqual( document.querySelectorAll( '.reveal .slides>section.future' ).length, horizontalSlides.length - 1, 'remaining horizontal slides are .future' );
  18. strictEqual( document.querySelectorAll( '.reveal .slides section.stack' ).length, 2, 'two .stacks' );
  19. ok( document.querySelectorAll( '.reveal .slides section.stack' )[0].querySelectorAll( '.future' ).length > 0, 'vertical slides are given .future' );
  20. });
  21. // ---------------------------------------------------------------
  22. // API TESTS
  23. QUnit.module( 'API' );
  24. test( 'Reveal.isReady', function() {
  25. strictEqual( Reveal.isReady(), true, 'returns true' );
  26. });
  27. test( 'Reveal.isOverview', function() {
  28. strictEqual( Reveal.isOverview(), false, 'false by default' );
  29. Reveal.toggleOverview();
  30. strictEqual( Reveal.isOverview(), true, 'true after toggling on' );
  31. Reveal.toggleOverview();
  32. strictEqual( Reveal.isOverview(), false, 'false after toggling off' );
  33. });
  34. test( 'Reveal.isPaused', function() {
  35. strictEqual( Reveal.isPaused(), false, 'false by default' );
  36. Reveal.togglePause();
  37. strictEqual( Reveal.isPaused(), true, 'true after pausing' );
  38. Reveal.togglePause();
  39. strictEqual( Reveal.isPaused(), false, 'false after resuming' );
  40. });
  41. test( 'Reveal.isFirstSlide', function() {
  42. Reveal.slide( 0, 0 );
  43. strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' );
  44. Reveal.slide( 1, 0 );
  45. strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1, 0 )' );
  46. Reveal.slide( 0, 0 );
  47. strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' );
  48. });
  49. test( 'Reveal.isFirstSlide after vertical slide', function() {
  50. Reveal.slide( 1, 1 );
  51. Reveal.slide( 0, 0 );
  52. strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( 0, 0 )' );
  53. });
  54. test( 'Reveal.isLastSlide', function() {
  55. Reveal.slide( 0, 0 );
  56. strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
  57. var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
  58. Reveal.slide( lastSlideIndex, 0 );
  59. strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( '+ lastSlideIndex +', 0 )' );
  60. Reveal.slide( 0, 0 );
  61. strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
  62. });
  63. test( 'Reveal.isLastSlide after vertical slide', function() {
  64. var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
  65. Reveal.slide( 1, 1 );
  66. Reveal.slide( lastSlideIndex );
  67. strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( '+ lastSlideIndex +', 0 )' );
  68. });
  69. test( 'Reveal.getTotalSlides', function() {
  70. strictEqual( Reveal.getTotalSlides(), 8, 'eight slides in total' );
  71. });
  72. test( 'Reveal.getIndices', function() {
  73. var indices = Reveal.getIndices();
  74. ok( indices.hasOwnProperty( 'h' ), 'h exists' );
  75. ok( indices.hasOwnProperty( 'v' ), 'v exists' );
  76. ok( indices.hasOwnProperty( 'f' ), 'f exists' );
  77. Reveal.slide( 1, 0 );
  78. strictEqual( Reveal.getIndices().h, 1, 'h 1' );
  79. strictEqual( Reveal.getIndices().v, 0, 'v 0' );
  80. Reveal.slide( 1, 2 );
  81. strictEqual( Reveal.getIndices().h, 1, 'h 1' );
  82. strictEqual( Reveal.getIndices().v, 2, 'v 2' );
  83. Reveal.slide( 0, 0 );
  84. strictEqual( Reveal.getIndices().h, 0, 'h 0' );
  85. strictEqual( Reveal.getIndices().v, 0, 'v 0' );
  86. });
  87. test( 'Reveal.getSlide', function() {
  88. equal( Reveal.getSlide( 0 ), document.querySelector( '.reveal .slides>section:first-child' ), 'gets correct first slide' );
  89. equal( Reveal.getSlide( 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)' ), 'no v index returns stack' );
  90. equal( Reveal.getSlide( 1, 0 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(1)' ), 'v index 0 returns first vertical child' );
  91. equal( Reveal.getSlide( 1, 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(2)' ), 'v index 1 returns second vertical child' );
  92. strictEqual( Reveal.getSlide( 100 ), undefined, 'undefined when out of horizontal bounds' );
  93. strictEqual( Reveal.getSlide( 1, 100 ), undefined, 'undefined when out of vertical bounds' );
  94. });
  95. test( 'Reveal.getSlideBackground', function() {
  96. equal( Reveal.getSlideBackground( 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ), 'gets correct first background' );
  97. equal( Reveal.getSlideBackground( 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2)' ), 'no v index returns stack' );
  98. equal( Reveal.getSlideBackground( 1, 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(1)' ), 'v index 0 returns first vertical child' );
  99. equal( Reveal.getSlideBackground( 1, 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(2)' ), 'v index 1 returns second vertical child' );
  100. strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'undefined when out of horizontal bounds' );
  101. strictEqual( Reveal.getSlideBackground( 1, 100 ), undefined, 'undefined when out of vertical bounds' );
  102. });
  103. test( 'Reveal.getPreviousSlide/getCurrentSlide', function() {
  104. Reveal.slide( 0, 0 );
  105. Reveal.slide( 1, 0 );
  106. var firstSlide = document.querySelector( '.reveal .slides>section:first-child' );
  107. var secondSlide = document.querySelector( '.reveal .slides>section:nth-child(2)>section' );
  108. equal( Reveal.getPreviousSlide(), firstSlide, 'previous is slide #0' );
  109. equal( Reveal.getCurrentSlide(), secondSlide, 'current is slide #1' );
  110. });
  111. test( 'Reveal.getProgress', function() {
  112. Reveal.slide( 0, 0 );
  113. strictEqual( Reveal.getProgress(), 0, 'progress is 0 on first slide' );
  114. var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
  115. Reveal.slide( lastSlideIndex, 0 );
  116. strictEqual( Reveal.getProgress(), 1, 'progress is 1 on last slide' );
  117. });
  118. test( 'Reveal.getScale', function() {
  119. ok( typeof Reveal.getScale() === 'number', 'has scale' );
  120. });
  121. test( 'Reveal.getConfig', function() {
  122. ok( typeof Reveal.getConfig() === 'object', 'has config' );
  123. });
  124. test( 'Reveal.configure', function() {
  125. strictEqual( Reveal.getConfig().loop, false, '"loop" is false to start with' );
  126. Reveal.configure({ loop: true });
  127. strictEqual( Reveal.getConfig().loop, true, '"loop" has changed to true' );
  128. Reveal.configure({ loop: false, customTestValue: 1 });
  129. strictEqual( Reveal.getConfig().customTestValue, 1, 'supports custom values' );
  130. });
  131. test( 'Reveal.availableRoutes', function() {
  132. Reveal.slide( 0, 0 );
  133. deepEqual( Reveal.availableRoutes(), { left: false, up: false, down: false, right: true }, 'correct for first slide' );
  134. Reveal.slide( 1, 0 );
  135. deepEqual( Reveal.availableRoutes(), { left: true, up: false, down: true, right: true }, 'correct for vertical slide' );
  136. });
  137. test( 'Reveal.next', function() {
  138. Reveal.slide( 0, 0 );
  139. // Step through vertical child slides
  140. Reveal.next();
  141. deepEqual( Reveal.getIndices(), { h: 1, v: 0, f: undefined } );
  142. Reveal.next();
  143. deepEqual( Reveal.getIndices(), { h: 1, v: 1, f: undefined } );
  144. Reveal.next();
  145. deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined } );
  146. // Step through fragments
  147. Reveal.next();
  148. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 } );
  149. Reveal.next();
  150. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 } );
  151. Reveal.next();
  152. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 } );
  153. Reveal.next();
  154. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 } );
  155. });
  156. test( 'Reveal.next at end', function() {
  157. Reveal.slide( 3 );
  158. // We're at the end, this should have no effect
  159. Reveal.next();
  160. deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } );
  161. Reveal.next();
  162. deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } );
  163. });
  164. // ---------------------------------------------------------------
  165. // FRAGMENT TESTS
  166. QUnit.module( 'Fragments' );
  167. test( 'Sliding to fragments', function() {
  168. Reveal.slide( 2, 0, -1 );
  169. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'Reveal.slide( 2, 0, -1 )' );
  170. Reveal.slide( 2, 0, 0 );
  171. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'Reveal.slide( 2, 0, 0 )' );
  172. Reveal.slide( 2, 0, 2 );
  173. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'Reveal.slide( 2, 0, 2 )' );
  174. Reveal.slide( 2, 0, 1 );
  175. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'Reveal.slide( 2, 0, 1 )' );
  176. });
  177. test( 'Hiding all fragments', function() {
  178. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  179. Reveal.slide( 2, 0, 0 );
  180. strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 1, 'one fragment visible when index is 0' );
  181. Reveal.slide( 2, 0, -1 );
  182. strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index is -1' );
  183. });
  184. test( 'Current fragment', function() {
  185. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  186. Reveal.slide( 2, 0 );
  187. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment at index -1' );
  188. Reveal.slide( 2, 0, 0 );
  189. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 1, 'one current fragment at index 0' );
  190. Reveal.slide( 1, 0, 0 );
  191. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to previous slide' );
  192. Reveal.slide( 3, 0, 0 );
  193. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to next slide' );
  194. });
  195. test( 'Stepping through fragments', function() {
  196. Reveal.slide( 2, 0, -1 );
  197. // forwards:
  198. Reveal.next();
  199. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'next() goes to next fragment' );
  200. Reveal.right();
  201. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'right() goes to next fragment' );
  202. Reveal.down();
  203. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'down() goes to next fragment' );
  204. Reveal.down(); // moves to f #3
  205. // backwards:
  206. Reveal.prev();
  207. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'prev() goes to prev fragment' );
  208. Reveal.left();
  209. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'left() goes to prev fragment' );
  210. Reveal.up();
  211. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'up() goes to prev fragment' );
  212. });
  213. test( 'Stepping past fragments', function() {
  214. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  215. Reveal.slide( 0, 0, 0 );
  216. equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' );
  217. Reveal.slide( 3, 0, 0 );
  218. equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 3, 'all fragments visible when on future slide' );
  219. });
  220. test( 'Fragment indices', function() {
  221. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(2)' );
  222. Reveal.slide( 3, 0, 0 );
  223. equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 2, 'both fragments of same index are shown' );
  224. // This slide has three fragments, first one is index 0, second and third have index 1
  225. Reveal.slide( 2, 2, 0 );
  226. equal( Reveal.getIndices().f, 0, 'returns correct index for first fragment' );
  227. Reveal.slide( 2, 2, 1 );
  228. equal( Reveal.getIndices().f, 1, 'returns correct index for two fragments with same index' );
  229. });
  230. test( 'Index generation', function() {
  231. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  232. // These have no indices defined to start with
  233. equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
  234. equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
  235. equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '2' );
  236. });
  237. test( 'Index normalization', function() {
  238. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(3)' );
  239. // These start out as 1-4-4 and should normalize to 0-1-1
  240. equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
  241. equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
  242. equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '1' );
  243. });
  244. asyncTest( 'fragmentshown event', function() {
  245. expect( 2 );
  246. var _onEvent = function( event ) {
  247. ok( true, 'event fired' );
  248. }
  249. Reveal.addEventListener( 'fragmentshown', _onEvent );
  250. Reveal.slide( 2, 0 );
  251. Reveal.slide( 2, 0 ); // should do nothing
  252. Reveal.slide( 2, 0, 0 ); // should do nothing
  253. Reveal.next();
  254. Reveal.next();
  255. Reveal.prev(); // shouldn't fire fragmentshown
  256. start();
  257. Reveal.removeEventListener( 'fragmentshown', _onEvent );
  258. });
  259. asyncTest( 'fragmenthidden event', function() {
  260. expect( 2 );
  261. var _onEvent = function( event ) {
  262. ok( true, 'event fired' );
  263. }
  264. Reveal.addEventListener( 'fragmenthidden', _onEvent );
  265. Reveal.slide( 2, 0, 2 );
  266. Reveal.slide( 2, 0, 2 ); // should do nothing
  267. Reveal.prev();
  268. Reveal.prev();
  269. Reveal.next(); // shouldn't fire fragmenthidden
  270. start();
  271. Reveal.removeEventListener( 'fragmenthidden', _onEvent );
  272. });
  273. // ---------------------------------------------------------------
  274. // AUTO-SLIDE TESTS
  275. QUnit.module( 'Auto Sliding' );
  276. test( 'Reveal.isAutoSliding', function() {
  277. strictEqual( Reveal.isAutoSliding(), false, 'false by default' );
  278. Reveal.configure({ autoSlide: 10000 });
  279. strictEqual( Reveal.isAutoSliding(), true, 'true after starting' );
  280. Reveal.configure({ autoSlide: 0 });
  281. strictEqual( Reveal.isAutoSliding(), false, 'false after setting to 0' );
  282. });
  283. test( 'Reveal.toggleAutoSlide', function() {
  284. Reveal.configure({ autoSlide: 10000 });
  285. Reveal.toggleAutoSlide();
  286. strictEqual( Reveal.isAutoSliding(), false, 'false after first toggle' );
  287. Reveal.toggleAutoSlide();
  288. strictEqual( Reveal.isAutoSliding(), true, 'true after second toggle' );
  289. Reveal.configure({ autoSlide: 0 });
  290. });
  291. asyncTest( 'autoslidepaused', function() {
  292. expect( 1 );
  293. var _onEvent = function( event ) {
  294. ok( true, 'event fired' );
  295. }
  296. Reveal.addEventListener( 'autoslidepaused', _onEvent );
  297. Reveal.configure({ autoSlide: 10000 });
  298. Reveal.toggleAutoSlide();
  299. start();
  300. // cleanup
  301. Reveal.configure({ autoSlide: 0 });
  302. Reveal.removeEventListener( 'autoslidepaused', _onEvent );
  303. });
  304. asyncTest( 'autoslideresumed', function() {
  305. expect( 1 );
  306. var _onEvent = function( event ) {
  307. ok( true, 'event fired' );
  308. }
  309. Reveal.addEventListener( 'autoslideresumed', _onEvent );
  310. Reveal.configure({ autoSlide: 10000 });
  311. Reveal.toggleAutoSlide();
  312. Reveal.toggleAutoSlide();
  313. start();
  314. // cleanup
  315. Reveal.configure({ autoSlide: 0 });
  316. Reveal.removeEventListener( 'autoslideresumed', _onEvent );
  317. });
  318. // ---------------------------------------------------------------
  319. // CONFIGURATION VALUES
  320. QUnit.module( 'Configuration' );
  321. test( 'Controls', function() {
  322. var controlsElement = document.querySelector( '.reveal>.controls' );
  323. Reveal.configure({ controls: false });
  324. equal( controlsElement.style.display, 'none', 'controls are hidden' );
  325. Reveal.configure({ controls: true });
  326. equal( controlsElement.style.display, 'block', 'controls are visible' );
  327. });
  328. test( 'Progress', function() {
  329. var progressElement = document.querySelector( '.reveal>.progress' );
  330. Reveal.configure({ progress: false });
  331. equal( progressElement.style.display, 'none', 'progress are hidden' );
  332. Reveal.configure({ progress: true });
  333. equal( progressElement.style.display, 'block', 'progress are visible' );
  334. });
  335. test( 'Loop', function() {
  336. Reveal.configure({ loop: true });
  337. Reveal.slide( 0, 0 );
  338. Reveal.left();
  339. notEqual( Reveal.getIndices().h, 0, 'looped from start to end' );
  340. Reveal.right();
  341. equal( Reveal.getIndices().h, 0, 'looped from end to start' );
  342. Reveal.configure({ loop: false });
  343. });
  344. // ---------------------------------------------------------------
  345. // LAZY-LOADING TESTS
  346. QUnit.module( 'Lazy-Loading' );
  347. test( 'img with data-src', function() {
  348. strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' );
  349. });
  350. test( 'video with data-src', function() {
  351. strictEqual( document.querySelectorAll( '.reveal section video[src]' ).length, 1, 'Video source has been set' );
  352. });
  353. test( 'audio with data-src', function() {
  354. strictEqual( document.querySelectorAll( '.reveal section audio[src]' ).length, 1, 'Audio source has been set' );
  355. });
  356. test( 'iframe with data-src', function() {
  357. Reveal.slide( 0, 0 );
  358. strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );
  359. Reveal.slide( 2, 1 );
  360. strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 1, 'Iframe source is set' );
  361. Reveal.slide( 2, 2 );
  362. strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );
  363. });
  364. test( 'background images', function() {
  365. var imageSource1 = Reveal.getSlide( 0 ).getAttribute( 'data-background-image' );
  366. var imageSource2 = Reveal.getSlide( 1, 0 ).getAttribute( 'data-background' );
  367. // check that the images are applied to the background elements
  368. ok( Reveal.getSlideBackground( 0 ).style.backgroundImage.indexOf( imageSource1 ) !== -1, 'data-background-image worked' );
  369. ok( Reveal.getSlideBackground( 1, 0 ).style.backgroundImage.indexOf( imageSource2 ) !== -1, 'data-background worked' );
  370. });
  371. // ---------------------------------------------------------------
  372. // EVENT TESTS
  373. QUnit.module( 'Events' );
  374. asyncTest( 'slidechanged', function() {
  375. expect( 3 );
  376. var _onEvent = function( event ) {
  377. ok( true, 'event fired' );
  378. }
  379. Reveal.addEventListener( 'slidechanged', _onEvent );
  380. Reveal.slide( 1, 0 ); // should trigger
  381. Reveal.slide( 1, 0 ); // should do nothing
  382. Reveal.next(); // should trigger
  383. Reveal.slide( 3, 0 ); // should trigger
  384. Reveal.next(); // should do nothing
  385. start();
  386. Reveal.removeEventListener( 'slidechanged', _onEvent );
  387. });
  388. asyncTest( 'paused', function() {
  389. expect( 1 );
  390. var _onEvent = function( event ) {
  391. ok( true, 'event fired' );
  392. }
  393. Reveal.addEventListener( 'paused', _onEvent );
  394. Reveal.togglePause();
  395. Reveal.togglePause();
  396. start();
  397. Reveal.removeEventListener( 'paused', _onEvent );
  398. });
  399. asyncTest( 'resumed', function() {
  400. expect( 1 );
  401. var _onEvent = function( event ) {
  402. ok( true, 'event fired' );
  403. }
  404. Reveal.addEventListener( 'resumed', _onEvent );
  405. Reveal.togglePause();
  406. Reveal.togglePause();
  407. start();
  408. Reveal.removeEventListener( 'resumed', _onEvent );
  409. });
  410. } );
  411. Reveal.initialize();