diff --git a/src/04-generics-advanced/17-you-say-goodbye-i-say-hello.solution.3.ts b/src/04-generics-advanced/17-you-say-goodbye-i-say-hello.solution.3.ts new file mode 100644 index 0000000..8a4f181 --- /dev/null +++ b/src/04-generics-advanced/17-you-say-goodbye-i-say-hello.solution.3.ts @@ -0,0 +1,26 @@ +import { expect, it } from "vitest"; +import { Equal, Expect } from "../helpers/type-utils"; + +function youSayGoodbyeISayHello(greeting: 'hello'): 'goodbye' +function youSayGoodbyeISayHello(greeting: 'goodbye'): 'hello' +function youSayGoodbyeISayHello( + greeting: TGreeting +){ + return greeting === "goodbye" ? "hello" : "goodbye"; +} + +it("Should return goodbye when hello is passed in", () => { + const result = youSayGoodbyeISayHello("hello"); + + type test = [Expect>]; + + expect(result).toEqual("goodbye"); +}); + +it("Should return hello when goodbye is passed in", () => { + const result = youSayGoodbyeISayHello("goodbye"); + + type test = [Expect>]; + + expect(result).toEqual("hello"); +});