babylon.example.tests.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. .load(function () {
  19. // Force apply promise polyfill for consistent behavior between PhantomJS, IE11, and other browsers.
  20. BABYLON.PromisePolyfill.Apply(true);
  21. done();
  22. });
  23. });
  24. /**
  25. * This test highlights different ways of using asserts from chai so that you can chose the syntax
  26. * you prefer between should, expect, and assert.
  27. */
  28. describe('#ExponentOfTwo', () => {
  29. it('should be expoent of two', () => {
  30. var result : boolean = BABYLON.Tools.IsExponentOfTwo(2);
  31. expect(result).to.be.true;
  32. result = BABYLON.Tools.IsExponentOfTwo(4);
  33. result.should.be.true;
  34. result = BABYLON.Tools.IsExponentOfTwo(8);
  35. assert.isTrue(result);
  36. });
  37. it('should not be exponent of two', () => {
  38. var result : boolean = BABYLON.Tools.IsExponentOfTwo(3);
  39. expect(result).to.be.false;
  40. result = BABYLON.Tools.IsExponentOfTwo(6);
  41. result.should.be.false;
  42. result = BABYLON.Tools.IsExponentOfTwo(12);
  43. assert.isFalse(result);
  44. });
  45. });
  46. /**
  47. * This test shows how to return an asynchronous operation with promises.
  48. */
  49. describe('#Promise', () => {
  50. it('delay', () => {
  51. return BABYLON.Tools.DelayAsync(100);
  52. });
  53. });
  54. });