|
| 1 | +const getMid = require("../project/js/functionality/getMid"); |
| 2 | + |
| 3 | +it("always returns a number", function () { |
| 4 | + expect(typeof getMid(1, 2)).toBe("number"); |
| 5 | +}); |
| 6 | + |
| 7 | +it("always returns a number also if the parameters are string", function () { |
| 8 | + expect(typeof getMid("ali", "ahmed")).toBe("number"); |
| 9 | +}); |
| 10 | + |
| 11 | +it("always returns a zero if the first parameter is not a number", function () { |
| 12 | + expect(getMid("ali", 5)).toBe(0); |
| 13 | +}); |
| 14 | + |
| 15 | +it("always returns a zero if the second parameter is not a number", function () { |
| 16 | + expect(getMid(5, "ali")).toBe(0); |
| 17 | +}); |
| 18 | + |
| 19 | +it("returns the two parameters value if they are the same also if they are a string type", function () { |
| 20 | + expect(getMid("5", "5")).toBe(5); |
| 21 | +}); |
| 22 | + |
| 23 | +it("returns the middle of two parameters", function () { |
| 24 | + expect(getMid(10, 20)).toBe(15); |
| 25 | +}); |
| 26 | + |
| 27 | +it("returns the two parameters value if they are the same", function () { |
| 28 | + expect(getMid(5, 5)).toBe(5); |
| 29 | +}); |
| 30 | + |
| 31 | +it("returns the first number if not Entering The Second Number", function () { |
| 32 | + expect(getMid(5)).toBe(5); |
| 33 | +}); |
| 34 | + |
| 35 | +it("returns zero if the first parameter is not a number and the second parameter is not passing", function () { |
| 36 | + expect(getMid([1, 2, 3, 4])).toBe(0); |
| 37 | +}); |
| 38 | + |
| 39 | +it("returns zero if there is no parameters", function () { |
| 40 | + expect(getMid()).toBe(0); |
| 41 | +}); |
0 commit comments