Skip to content

Commit c3114b2

Browse files
authored
Add tests for invert function in test.js
Added unit tests for the invert function to verify its behavior with various inputs.
1 parent 34394f6 commit c3114b2

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎Sprint-2/interpret/test.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const invert = require("./invert");
2+
3+
describe("invert", () => {
4+
test("inverts an empty object", () => {
5+
expect(invert({})).toEqual({});
6+
});
7+
8+
test("inverts a single property", () => {
9+
expect(invert({ a: 1 })).toEqual({ 1: "a" });
10+
});
11+
12+
test("inverts multiple properties", () => {
13+
expect(invert({ a: 1, b: 2 })).toEqual({
14+
1: "a",
15+
2: "b",
16+
});
17+
});
18+
19+
test("works with other values", () => {
20+
expect(invert({ x: 10, y: 20 })).toEqual({
21+
10: "x",
22+
20: "y",
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)