babylon.example.tests.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Describes the test suite.
  3. */
  4. describe('Example', function() {
  5. /**
  6. * Sets the timeout of all the tests to 10 seconds.
  7. * Note the JavaScript function syntax in the describe callback.
  8. * See https://mochajs.org/#arrow-functions
  9. */
  10. this.timeout(10000);
  11. /**
  12. * Loads the dependencies.
  13. */
  14. before(function(done) {
  15. this.timeout(180000);
  16. (BABYLONDEVTOOLS).Loader
  17. .useDist()
  18. .testMode()
  19. .load(function() {
  20. // Force apply promise polyfill for consistent behavior between chrome headless, IE11, and other browsers.
  21. BABYLON.PromisePolyfill.Apply(true);
  22. done();
  23. });
  24. });
  25. /**
  26. * This test highlights different ways of using asserts from chai so that you can chose the syntax
  27. * you prefer between should, expect, and assert.
  28. */
  29. describe('#ExponentOfTwo', () => {
  30. it('should be expoent of two', () => {
  31. var result: boolean = BABYLON.Tools.IsExponentOfTwo(2);
  32. expect(result).to.be.true;
  33. result = BABYLON.Tools.IsExponentOfTwo(4);
  34. result.should.be.true;
  35. result = BABYLON.Tools.IsExponentOfTwo(8);
  36. assert.isTrue(result);
  37. });
  38. it('should not be exponent of two', () => {
  39. var result: boolean = BABYLON.Tools.IsExponentOfTwo(3);
  40. expect(result).to.be.false;
  41. result = BABYLON.Tools.IsExponentOfTwo(6);
  42. result.should.be.false;
  43. result = BABYLON.Tools.IsExponentOfTwo(12);
  44. assert.isFalse(result);
  45. });
  46. });
  47. /**
  48. * This test shows how to return an asynchronous operation with promises.
  49. */
  50. describe('#Promise', () => {
  51. it('delay', () => {
  52. return BABYLON.Tools.DelayAsync(100);
  53. });
  54. });
  55. });