|
| 1 | +import { |
| 2 | + add3, |
| 3 | + fahrenheitToCelius, |
| 4 | + shout, |
| 5 | + isQuestion, |
| 6 | + convertYesNo, |
| 7 | +} from "./functions"; |
| 8 | + |
| 9 | +describe("Testing the basic functions", () => { |
| 10 | + test("(3 pts) Testing the fahrenheitToCelius function", () => { |
| 11 | + expect(fahrenheitToCelius(32)).toBe(0); |
| 12 | + expect(fahrenheitToCelius(-40)).toBe(-40); |
| 13 | + expect(fahrenheitToCelius(-22)).toBe(-30); |
| 14 | + expect(fahrenheitToCelius(14)).toBe(-10); |
| 15 | + expect(fahrenheitToCelius(68)).toBe(20); |
| 16 | + expect(fahrenheitToCelius(86)).toBe(30); |
| 17 | + expect(fahrenheitToCelius(212)).toBe(100); |
| 18 | + }); |
| 19 | + |
| 20 | + test("(3 pts) Testing the add3 function", () => { |
| 21 | + expect(add3(1, 2, 3)).toBe(6); |
| 22 | + expect(add3(9, 7, 4)).toBe(20); |
| 23 | + expect(add3(6, -3, 9)).toBe(15); |
| 24 | + expect(add3(10, 1, -9)).toBe(11); |
| 25 | + expect(add3(-9, -100, -4)).toBe(0); |
| 26 | + expect(add3(-1, -1, 1)).toBe(1); |
| 27 | + }); |
| 28 | + |
| 29 | + test("(3 pts) Testing the shout function", () => { |
| 30 | + expect(shout("Hello")).toBe("HELLO!"); |
| 31 | + expect(shout("What?")).toBe("WHAT?!"); |
| 32 | + expect(shout("oHo")).toBe("OHO!"); |
| 33 | + expect(shout("AHHHH!!!")).toBe("AHHHH!!!!"); |
| 34 | + expect(shout("")).toBe("!"); |
| 35 | + expect(shout("Please go outside")).toBe("PLEASE GO OUTSIDE!"); |
| 36 | + }); |
| 37 | + |
| 38 | + test("(3 pts) Testing the isQuestion function", () => { |
| 39 | + expect(isQuestion("Is this a question?")).toBe(true); |
| 40 | + expect(isQuestion("Who are you?")).toBe(true); |
| 41 | + expect(isQuestion("WHAT ARE YOU !?")).toBe(true); |
| 42 | + expect(isQuestion("WHAT IS THIS?!")).toBe(false); |
| 43 | + expect(isQuestion("OH GOD!")).toBe(false); |
| 44 | + expect(isQuestion("Oh nevermind, it's fine.")).toBe(false); |
| 45 | + expect(isQuestion("")).toBe(false); |
| 46 | + }); |
| 47 | + |
| 48 | + test("(3 pts) Testing the convertYesNo function", () => { |
| 49 | + expect(convertYesNo("yes")).toBe(true); |
| 50 | + expect(convertYesNo("YES")).toBe(true); |
| 51 | + expect(convertYesNo("NO")).toBe(false); |
| 52 | + expect(convertYesNo("no")).toBe(false); |
| 53 | + expect(convertYesNo("Apple")).toBe(null); |
| 54 | + expect(convertYesNo("Bananas")).toBe(null); |
| 55 | + expect(convertYesNo("Nope")).toBe(null); |
| 56 | + expect(convertYesNo("Yesterday")).toBe(null); |
| 57 | + expect(convertYesNo("Maybe")).toBe(null); |
| 58 | + }); |
| 59 | +}); |
0 commit comments