Last active
August 2, 2023 19:34
-
-
Save willie-hung/ce2914b9ea2c4fd6cce4f2c2f3073fef to your computer and use it in GitHub Desktop.
post_32
This file contains 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
export function add(...args: number[]): number { | |
return args.reduce((a, b) => a + b, 0); | |
} | |
// in-source test suites | |
if (import.meta.vitest) { | |
const { it, expect } = import.meta.vitest; | |
it("add", () => { | |
expect(add()).toBe(0); | |
expect(add(1)).toBe(1); | |
expect(add(1, 2, 3, 4, 5)).toBe(15); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment