Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tests/add.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it, expect } from "vitest";
import { add } from "../src/add";

describe("Test add function", () => {
it("should add two positive numbers", () => {
Expand All @@ -8,9 +9,29 @@ describe("Test add function", () => {
const expected = 3;

// Act
const result = a + b;
const result = add(a, b);

// Assert
expect(result).toBe(expected);
});

it("should add two negative numbers", () => {
const x = -5;
const y = -6;
const expected = -11;

const res = add(x, y);

expect(res).toBe(expected);
});

it("should add a positive and a negative number", () => {
const firstNum = -7;
const secondNum = 10;
const expected = 3;

const res = add(firstNum, secondNum);

expect(res).toBe(expected);
});
});