Skip to content

Commit c1f577b

Browse files
authored
Add tests for invert function
Add unit tests for the invert function to verify its behavior with various inputs.
1 parent 4c91d5d commit c1f577b

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎Sprint-2/interpret/invert.test.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const invert = require("./invert.js");
2+
3+
test("should swap keys and values in an object", () => {
4+
expect(invert({ a: 1, b: 2 })).toEqual({
5+
1: "a",
6+
2: "b",
7+
});
8+
});
9+
10+
test("should invert an object with a single key-value pair", () => {
11+
expect(invert({ x: 10 })).toEqual({
12+
10: "x",
13+
});
14+
});
15+
16+
test("should return an empty object when passed an empty object", () => {
17+
expect(invert({})).toEqual({});
18+
});

0 commit comments

Comments
 (0)