File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 11import { describe , it , expect } from "vitest" ;
2+ import { add } from "../src/add" ;
23
34describe ( "Test add function" , ( ) => {
45 it ( "should add two positive numbers" , ( ) => {
@@ -8,9 +9,29 @@ describe("Test add function", () => {
89 const expected = 3 ;
910
1011 // Act
11- const result = a + b ;
12+ const result = add ( a , b ) ;
1213
1314 // Assert
1415 expect ( result ) . toBe ( expected ) ;
1516 } ) ;
17+
18+ it ( "should add two negative numbers" , ( ) => {
19+ const x = - 5 ;
20+ const y = - 6 ;
21+ const expected = - 11 ;
22+
23+ const res = add ( x , y ) ;
24+
25+ expect ( res ) . toBe ( expected ) ;
26+ } ) ;
27+
28+ it ( "should add a positive and a negative number" , ( ) => {
29+ const firstNum = - 7 ;
30+ const secondNum = 10 ;
31+ const expected = 3 ;
32+
33+ const res = add ( firstNum , secondNum ) ;
34+
35+ expect ( res ) . toBe ( expected ) ;
36+ } ) ;
1637} ) ;
You can’t perform that action at this time.
0 commit comments