This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it("should work with async/await", async () => { | |
| let completed = false; | |
| completed = await utils.simulateAsyncOp(); | |
| expect(completed).toEqual(true); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```js | |
| function simulateAsyncOp2() { | |
| return new Promise(resolve => { | |
| setTimeout(() => { | |
| resolve(true); | |
| }, 1000); | |
| }); | |
| } | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```js | |
| function simulateAsyncOp2() { | |
| return new Promise(resolve => { | |
| setTimeout(() => { | |
| resolve(true); | |
| }, 1000); | |
| }); | |
| } | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("/Async Op", function () { | |
| var asyncOpCompleted = false; | |
| beforeEach(function (done) { | |
| utils.simulateAsyncOp(function(){ | |
| asyncOpCompleted = true; | |
| done(); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("/Async Op", function () { | |
| var asyncOpCompleted = false; | |
| beforeEach(function (done) { | |
| utils.simulateAsyncOp(function(){ | |
| asyncOpCompleted = true; | |
| done(); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function simulateAsyncOp(callback){ | |
| setTimeout(function () { | |
| callback(); | |
| }, 2000); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it("should be able to upper case a string", function () { | |
| var spytoUpperCase = spyOn(String.prototype, 'toUpperCase').and.callThrough(); | |
| expect(utils.toUpperCase).toBeDefined(); | |
| expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD"); | |
| expect(String.prototype.toUpperCase).toHaveBeenCalled(); | |
| expect(spytoUpperCase.calls.count()).toEqual(1); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it("should be able to upper case a string", function () { | |
| var spytoUpperCase = spyOn(String.prototype, 'toUpperCase').and.callThrough(); | |
| expect(utils.toUpperCase).toBeDefined(); | |
| expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD"); | |
| expect(String.prototype.toUpperCase).toHaveBeenCalled(); | |
| expect(spytoUpperCase.calls.count()).toEqual(1); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it("should be able to upper case a string", function () { | |
| var spytoUpperCase = spyOn(String.prototype, 'toUpperCase').and.callThrough(); | |
| expect(utils.toUpperCase).toBeDefined(); | |
| expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD"); | |
| expect(String.prototype.toUpperCase).toHaveBeenCalled(); | |
| expect(spytoUpperCase.calls.count()).toEqual(1); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("/Basic Math Utils", function () { | |
| beforeEach(function () { | |
| jasmine.addMatchers({ | |
| hasEvenMethod: function (util, customEqualityTesters) { | |
| return { | |
| compare: function (actual, expected) { | |
| var result = { pass: utils.isEven !== undefined }; | |
| if (result.pass) { | |
| result.message = "Expected isEven() to be not defined." | |
| } |