test.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. Reveal.addEventListener( 'ready', function() {
  2. QUnit.module( 'API' );
  3. test( 'Reveal.isReady', function() {
  4. ok( Reveal.isReady() === true, 'returns true' );
  5. });
  6. test( 'Reveal.isOverview', function() {
  7. ok( Reveal.isOverview() === false, 'returns false' );
  8. Reveal.toggleOverview();
  9. ok( Reveal.isOverview() === true, 'returns true after toggling on' );
  10. Reveal.toggleOverview();
  11. ok( Reveal.isOverview() === false, 'returns false after toggling off' );
  12. });
  13. test( 'Reveal.isPaused', function() {
  14. ok( Reveal.isPaused() === false, 'returns false' );
  15. Reveal.togglePause();
  16. ok( Reveal.isPaused() === true, 'returns true after pausing' );
  17. Reveal.togglePause();
  18. ok( Reveal.isPaused() === false, 'returns false after resuming' );
  19. });
  20. test( 'Reveal.isFirstSlide', function() {
  21. Reveal.slide( 0 );
  22. ok( Reveal.isFirstSlide() === true, 'returns true' );
  23. Reveal.slide( 1 );
  24. ok( Reveal.isFirstSlide() === false, 'returns false after navigation' );
  25. Reveal.slide( 0 );
  26. ok( Reveal.isFirstSlide() === true, 'returns true after navigation' );
  27. });
  28. test( 'Reveal.isLastSlide', function() {
  29. Reveal.slide( 0 );
  30. ok( Reveal.isLastSlide() === false, 'returns false' );
  31. Reveal.slide( document.querySelectorAll( '.reveal .slides>section' ).length - 1 );
  32. ok( Reveal.isLastSlide() === true, 'returns true after navigation' );
  33. Reveal.slide( 0 );
  34. ok( Reveal.isLastSlide() === false, 'returns false after navigation' );
  35. });
  36. test( 'Reveal.getIndices', function() {
  37. var indices = Reveal.getIndices();
  38. ok( typeof indices.hasOwnProperty( 'h' ), 'h exists' );
  39. ok( typeof indices.hasOwnProperty( 'v' ), 'v exists' );
  40. ok( typeof indices.hasOwnProperty( 'f' ), 'f exists' );
  41. Reveal.slide( 1 );
  42. ok( Reveal.getIndices().h === 1 && Reveal.getIndices().v === 0, 'h 1, v 0' );
  43. Reveal.slide( 1, 2 );
  44. ok( Reveal.getIndices().h === 1 && Reveal.getIndices().v === 2, 'h 1, v 2' );
  45. Reveal.slide( 0 );
  46. });
  47. test( 'Reveal.getScale', function() {
  48. ok( typeof Reveal.getScale() === 'number', 'has scale' );
  49. });
  50. test( 'Reveal.getConfig', function() {
  51. ok( typeof Reveal.getConfig() === 'object', 'has config' );
  52. });
  53. QUnit.module( 'Events' );
  54. asyncTest( 'slidechanged', function() {
  55. expect( 1 );
  56. var _onSlideChanged = function( event ) {
  57. ok( true, 'event fired' );
  58. start();
  59. }
  60. Reveal.addEventListener( 'slidechanged', _onSlideChanged );
  61. // Should trigger the event
  62. Reveal.slide( 1 );
  63. // Should not trigger an event since it's the same #
  64. Reveal.slide( 1 );
  65. Reveal.removeEventListener( 'slidechanged', _onSlideChanged );
  66. });
  67. } );
  68. Reveal.initialize();