Clock.tests.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * @author simonThiele / https://github.com/simonThiele
  3. * @author TristanVALCKE / https://github.com/Itee
  4. */
  5. /* global QUnit */
  6. import { Clock } from '../../../../src/core/Clock';
  7. export default QUnit.module( 'Core', () => {
  8. QUnit.module.todo( 'Clock', () => {
  9. function mockPerformance() {
  10. self.performance = {
  11. deltaTime: 0,
  12. next: function ( delta ) {
  13. this.deltaTime += delta;
  14. },
  15. now: function () {
  16. return this.deltaTime;
  17. }
  18. };
  19. }
  20. // INSTANCING
  21. QUnit.test( "Instancing", ( assert ) => {
  22. assert.ok( false, "everything's gonna be alright" );
  23. } );
  24. // PUBLIC STUFF
  25. QUnit.test( "start", ( assert ) => {
  26. assert.ok( false, "everything's gonna be alright" );
  27. } );
  28. QUnit.test( "stop", ( assert ) => {
  29. assert.ok( false, "everything's gonna be alright" );
  30. } );
  31. QUnit.test( "getElapsedTime", ( assert ) => {
  32. assert.ok( false, "everything's gonna be alright" );
  33. } );
  34. QUnit.test( "getDelta", ( assert ) => {
  35. assert.ok( false, "everything's gonna be alright" );
  36. } );
  37. // OTHERS
  38. QUnit.test( "clock with performance", ( assert ) => {
  39. mockPerformance();
  40. var clock = new Clock( false );
  41. clock.start();
  42. self.performance.next( 123 );
  43. assert.numEqual( clock.getElapsedTime(), 0.123, "okay" );
  44. self.performance.next( 100 );
  45. assert.numEqual( clock.getElapsedTime(), 0.223, "okay" );
  46. clock.stop();
  47. self.performance.next( 1000 );
  48. assert.numEqual( clock.getElapsedTime(), 0.223, "don't update time if the clock was stopped" );
  49. } );
  50. } );
  51. } );