test.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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.getSlideNotes', function() {
  104. Reveal.slide( 0, 0 );
  105. ok( Reveal.getSlideNotes() === 'speaker notes 1', 'works with <aside class="notes">' );
  106. Reveal.slide( 1, 0 );
  107. ok( Reveal.getSlideNotes() === 'speaker notes 2', 'works with <section data-notes="">' );
  108. });
  109. test( 'Reveal.getPreviousSlide/getCurrentSlide', function() {
  110. Reveal.slide( 0, 0 );
  111. Reveal.slide( 1, 0 );
  112. var firstSlide = document.querySelector( '.reveal .slides>section:first-child' );
  113. var secondSlide = document.querySelector( '.reveal .slides>section:nth-child(2)>section' );
  114. equal( Reveal.getPreviousSlide(), firstSlide, 'previous is slide #0' );
  115. equal( Reveal.getCurrentSlide(), secondSlide, 'current is slide #1' );
  116. });
  117. test( 'Reveal.getProgress', function() {
  118. Reveal.slide( 0, 0 );
  119. strictEqual( Reveal.getProgress(), 0, 'progress is 0 on first slide' );
  120. var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
  121. Reveal.slide( lastSlideIndex, 0 );
  122. strictEqual( Reveal.getProgress(), 1, 'progress is 1 on last slide' );
  123. });
  124. test( 'Reveal.getScale', function() {
  125. ok( typeof Reveal.getScale() === 'number', 'has scale' );
  126. });
  127. test( 'Reveal.getConfig', function() {
  128. ok( typeof Reveal.getConfig() === 'object', 'has config' );
  129. });
  130. test( 'Reveal.configure', function() {
  131. strictEqual( Reveal.getConfig().loop, false, '"loop" is false to start with' );
  132. Reveal.configure({ loop: true });
  133. strictEqual( Reveal.getConfig().loop, true, '"loop" has changed to true' );
  134. Reveal.configure({ loop: false, customTestValue: 1 });
  135. strictEqual( Reveal.getConfig().customTestValue, 1, 'supports custom values' );
  136. });
  137. test( 'Reveal.availableRoutes', function() {
  138. Reveal.slide( 0, 0 );
  139. deepEqual( Reveal.availableRoutes(), { left: false, up: false, down: false, right: true }, 'correct for first slide' );
  140. Reveal.slide( 1, 0 );
  141. deepEqual( Reveal.availableRoutes(), { left: true, up: false, down: true, right: true }, 'correct for vertical slide' );
  142. });
  143. test( 'Reveal.next', function() {
  144. Reveal.slide( 0, 0 );
  145. // Step through vertical child slides
  146. Reveal.next();
  147. deepEqual( Reveal.getIndices(), { h: 1, v: 0, f: undefined } );
  148. Reveal.next();
  149. deepEqual( Reveal.getIndices(), { h: 1, v: 1, f: undefined } );
  150. Reveal.next();
  151. deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined } );
  152. // Step through fragments
  153. Reveal.next();
  154. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 } );
  155. Reveal.next();
  156. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 } );
  157. Reveal.next();
  158. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 } );
  159. Reveal.next();
  160. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 } );
  161. });
  162. test( 'Reveal.next at end', function() {
  163. Reveal.slide( 3 );
  164. // We're at the end, this should have no effect
  165. Reveal.next();
  166. deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } );
  167. Reveal.next();
  168. deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } );
  169. });
  170. // ---------------------------------------------------------------
  171. // FRAGMENT TESTS
  172. QUnit.module( 'Fragments' );
  173. test( 'Sliding to fragments', function() {
  174. Reveal.slide( 2, 0, -1 );
  175. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'Reveal.slide( 2, 0, -1 )' );
  176. Reveal.slide( 2, 0, 0 );
  177. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'Reveal.slide( 2, 0, 0 )' );
  178. Reveal.slide( 2, 0, 2 );
  179. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'Reveal.slide( 2, 0, 2 )' );
  180. Reveal.slide( 2, 0, 1 );
  181. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'Reveal.slide( 2, 0, 1 )' );
  182. });
  183. test( 'Hiding all fragments', function() {
  184. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  185. Reveal.slide( 2, 0, 0 );
  186. strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 1, 'one fragment visible when index is 0' );
  187. Reveal.slide( 2, 0, -1 );
  188. strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index is -1' );
  189. });
  190. test( 'Current fragment', function() {
  191. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  192. Reveal.slide( 2, 0 );
  193. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment at index -1' );
  194. Reveal.slide( 2, 0, 0 );
  195. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 1, 'one current fragment at index 0' );
  196. Reveal.slide( 1, 0, 0 );
  197. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to previous slide' );
  198. Reveal.slide( 3, 0, 0 );
  199. strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to next slide' );
  200. });
  201. test( 'Stepping through fragments', function() {
  202. Reveal.slide( 2, 0, -1 );
  203. // forwards:
  204. Reveal.next();
  205. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'next() goes to next fragment' );
  206. Reveal.right();
  207. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'right() goes to next fragment' );
  208. Reveal.down();
  209. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'down() goes to next fragment' );
  210. Reveal.down(); // moves to f #3
  211. // backwards:
  212. Reveal.prev();
  213. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'prev() goes to prev fragment' );
  214. Reveal.left();
  215. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'left() goes to prev fragment' );
  216. Reveal.up();
  217. deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'up() goes to prev fragment' );
  218. });
  219. test( 'Stepping past fragments', function() {
  220. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  221. Reveal.slide( 0, 0, 0 );
  222. equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' );
  223. Reveal.slide( 3, 0, 0 );
  224. equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 3, 'all fragments visible when on future slide' );
  225. });
  226. test( 'Fragment indices', function() {
  227. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(2)' );
  228. Reveal.slide( 3, 0, 0 );
  229. equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 2, 'both fragments of same index are shown' );
  230. // This slide has three fragments, first one is index 0, second and third have index 1
  231. Reveal.slide( 2, 2, 0 );
  232. equal( Reveal.getIndices().f, 0, 'returns correct index for first fragment' );
  233. Reveal.slide( 2, 2, 1 );
  234. equal( Reveal.getIndices().f, 1, 'returns correct index for two fragments with same index' );
  235. });
  236. test( 'Index generation', function() {
  237. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
  238. // These have no indices defined to start with
  239. equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
  240. equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
  241. equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '2' );
  242. });
  243. test( 'Index normalization', function() {
  244. var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(3)' );
  245. // These start out as 1-4-4 and should normalize to 0-1-1
  246. equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
  247. equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
  248. equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '1' );
  249. });
  250. asyncTest( 'fragmentshown event', function() {
  251. expect( 2 );
  252. var _onEvent = function( event ) {
  253. ok( true, 'event fired' );
  254. }
  255. Reveal.addEventListener( 'fragmentshown', _onEvent );
  256. Reveal.slide( 2, 0 );
  257. Reveal.slide( 2, 0 ); // should do nothing
  258. Reveal.slide( 2, 0, 0 ); // should do nothing
  259. Reveal.next();
  260. Reveal.next();
  261. Reveal.prev(); // shouldn't fire fragmentshown
  262. start();
  263. Reveal.removeEventListener( 'fragmentshown', _onEvent );
  264. });
  265. asyncTest( 'fragmenthidden event', function() {
  266. expect( 2 );
  267. var _onEvent = function( event ) {
  268. ok( true, 'event fired' );
  269. }
  270. Reveal.addEventListener( 'fragmenthidden', _onEvent );
  271. Reveal.slide( 2, 0, 2 );
  272. Reveal.slide( 2, 0, 2 ); // should do nothing
  273. Reveal.prev();
  274. Reveal.prev();
  275. Reveal.next(); // shouldn't fire fragmenthidden
  276. start();
  277. Reveal.removeEventListener( 'fragmenthidden', _onEvent );
  278. });
  279. // ---------------------------------------------------------------
  280. // AUTO-SLIDE TESTS
  281. QUnit.module( 'Auto Sliding' );
  282. test( 'Reveal.isAutoSliding', function() {
  283. strictEqual( Reveal.isAutoSliding(), false, 'false by default' );
  284. Reveal.configure({ autoSlide: 10000 });
  285. strictEqual( Reveal.isAutoSliding(), true, 'true after starting' );
  286. Reveal.configure({ autoSlide: 0 });
  287. strictEqual( Reveal.isAutoSliding(), false, 'false after setting to 0' );
  288. });
  289. test( 'Reveal.toggleAutoSlide', function() {
  290. Reveal.configure({ autoSlide: 10000 });
  291. Reveal.toggleAutoSlide();
  292. strictEqual( Reveal.isAutoSliding(), false, 'false after first toggle' );
  293. Reveal.toggleAutoSlide();
  294. strictEqual( Reveal.isAutoSliding(), true, 'true after second toggle' );
  295. Reveal.configure({ autoSlide: 0 });
  296. });
  297. asyncTest( 'autoslidepaused', function() {
  298. expect( 1 );
  299. var _onEvent = function( event ) {
  300. ok( true, 'event fired' );
  301. }
  302. Reveal.addEventListener( 'autoslidepaused', _onEvent );
  303. Reveal.configure({ autoSlide: 10000 });
  304. Reveal.toggleAutoSlide();
  305. start();
  306. // cleanup
  307. Reveal.configure({ autoSlide: 0 });
  308. Reveal.removeEventListener( 'autoslidepaused', _onEvent );
  309. });
  310. asyncTest( 'autoslideresumed', function() {
  311. expect( 1 );
  312. var _onEvent = function( event ) {
  313. ok( true, 'event fired' );
  314. }
  315. Reveal.addEventListener( 'autoslideresumed', _onEvent );
  316. Reveal.configure({ autoSlide: 10000 });
  317. Reveal.toggleAutoSlide();
  318. Reveal.toggleAutoSlide();
  319. start();
  320. // cleanup
  321. Reveal.configure({ autoSlide: 0 });
  322. Reveal.removeEventListener( 'autoslideresumed', _onEvent );
  323. });
  324. // ---------------------------------------------------------------
  325. // CONFIGURATION VALUES
  326. QUnit.module( 'Configuration' );
  327. test( 'Controls', function() {
  328. var controlsElement = document.querySelector( '.reveal>.controls' );
  329. Reveal.configure({ controls: false });
  330. equal( controlsElement.style.display, 'none', 'controls are hidden' );
  331. Reveal.configure({ controls: true });
  332. equal( controlsElement.style.display, 'block', 'controls are visible' );
  333. });
  334. test( 'Progress', function() {
  335. var progressElement = document.querySelector( '.reveal>.progress' );
  336. Reveal.configure({ progress: false });
  337. equal( progressElement.style.display, 'none', 'progress are hidden' );
  338. Reveal.configure({ progress: true });
  339. equal( progressElement.style.display, 'block', 'progress are visible' );
  340. });
  341. test( 'Loop', function() {
  342. Reveal.configure({ loop: true });
  343. Reveal.slide( 0, 0 );
  344. Reveal.left();
  345. notEqual( Reveal.getIndices().h, 0, 'looped from start to end' );
  346. Reveal.right();
  347. equal( Reveal.getIndices().h, 0, 'looped from end to start' );
  348. Reveal.configure({ loop: false });
  349. });
  350. // ---------------------------------------------------------------
  351. // LAZY-LOADING TESTS
  352. QUnit.module( 'Lazy-Loading' );
  353. test( 'img with data-src', function() {
  354. strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' );
  355. });
  356. test( 'video with data-src', function() {
  357. strictEqual( document.querySelectorAll( '.reveal section video[src]' ).length, 1, 'Video source has been set' );
  358. });
  359. test( 'audio with data-src', function() {
  360. strictEqual( document.querySelectorAll( '.reveal section audio[src]' ).length, 1, 'Audio source has been set' );
  361. });
  362. test( 'iframe with data-src', function() {
  363. Reveal.slide( 0, 0 );
  364. strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );
  365. Reveal.slide( 2, 1 );
  366. strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 1, 'Iframe source is set' );
  367. Reveal.slide( 2, 2 );
  368. strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );
  369. });
  370. test( 'background images', function() {
  371. var imageSource1 = Reveal.getSlide( 0 ).getAttribute( 'data-background-image' );
  372. var imageSource2 = Reveal.getSlide( 1, 0 ).getAttribute( 'data-background' );
  373. // check that the images are applied to the background elements
  374. ok( Reveal.getSlideBackground( 0 ).style.backgroundImage.indexOf( imageSource1 ) !== -1, 'data-background-image worked' );
  375. ok( Reveal.getSlideBackground( 1, 0 ).style.backgroundImage.indexOf( imageSource2 ) !== -1, 'data-background worked' );
  376. });
  377. // ---------------------------------------------------------------
  378. // EVENT TESTS
  379. QUnit.module( 'Events' );
  380. asyncTest( 'slidechanged', function() {
  381. expect( 3 );
  382. var _onEvent = function( event ) {
  383. ok( true, 'event fired' );
  384. }
  385. Reveal.addEventListener( 'slidechanged', _onEvent );
  386. Reveal.slide( 1, 0 ); // should trigger
  387. Reveal.slide( 1, 0 ); // should do nothing
  388. Reveal.next(); // should trigger
  389. Reveal.slide( 3, 0 ); // should trigger
  390. Reveal.next(); // should do nothing
  391. start();
  392. Reveal.removeEventListener( 'slidechanged', _onEvent );
  393. });
  394. asyncTest( 'paused', function() {
  395. expect( 1 );
  396. var _onEvent = function( event ) {
  397. ok( true, 'event fired' );
  398. }
  399. Reveal.addEventListener( 'paused', _onEvent );
  400. Reveal.togglePause();
  401. Reveal.togglePause();
  402. start();
  403. Reveal.removeEventListener( 'paused', _onEvent );
  404. });
  405. asyncTest( 'resumed', function() {
  406. expect( 1 );
  407. var _onEvent = function( event ) {
  408. ok( true, 'event fired' );
  409. }
  410. Reveal.addEventListener( 'resumed', _onEvent );
  411. Reveal.togglePause();
  412. Reveal.togglePause();
  413. start();
  414. Reveal.removeEventListener( 'resumed', _onEvent );
  415. });
  416. } );
  417. Reveal.initialize();