From 8931b4fe144711b629b2261074e4f71ea54e90e6 Mon Sep 17 00:00:00 2001 From: {Harshit Malpotra} <{malpotra.harshit@gmail.com}> Date: Sat, 14 Oct 2023 20:58:26 +0530 Subject: [PATCH 1/3] test: add tests for Binary Equivalent Algorithm --- Recursive/test/BinaryEquivalent.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Recursive/test/BinaryEquivalent.test.js diff --git a/Recursive/test/BinaryEquivalent.test.js b/Recursive/test/BinaryEquivalent.test.js new file mode 100644 index 0000000000..9bfe565c75 --- /dev/null +++ b/Recursive/test/BinaryEquivalent.test.js @@ -0,0 +1,16 @@ +import { binaryEquivalent } from "../BinaryEquivalent"; + +describe("BinaryEquivalent", () => { + it('The binary equivalent of 2 should be "10"', () => { + expect(binaryEquivalent(2)).toBe("10"); + }) + it('The binary equivalent of 0 should be "0"', () => { + expect(binaryEquivalent(0)).toBe("0"); + }) + it('The binary equivalent of 543 should be "1000011111"', () => { + expect(binaryEquivalent(543)).toBe("1000011111"); + }) + it('The binary equivalent of 4697621023 should be "100011000000000000000001000011111"', () => { + expect(binaryEquivalent(4697621023)).toBe("100011000000000000000001000011111"); + }) +}) \ No newline at end of file From e3e48b412993e3ef62247882f3049b21de53f435 Mon Sep 17 00:00:00 2001 From: {Harshit Malpotra} <{malpotra.harshit@gmail.com}> Date: Sun, 22 Oct 2023 13:01:46 +0530 Subject: [PATCH 2/3] test: Refactored tests using .each() --- Recursive/test/BinaryEquivalent.test.js | 39 ++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Recursive/test/BinaryEquivalent.test.js b/Recursive/test/BinaryEquivalent.test.js index 9bfe565c75..95b977fa67 100644 --- a/Recursive/test/BinaryEquivalent.test.js +++ b/Recursive/test/BinaryEquivalent.test.js @@ -1,16 +1,29 @@ import { binaryEquivalent } from "../BinaryEquivalent"; -describe("BinaryEquivalent", () => { - it('The binary equivalent of 2 should be "10"', () => { - expect(binaryEquivalent(2)).toBe("10"); - }) - it('The binary equivalent of 0 should be "0"', () => { - expect(binaryEquivalent(0)).toBe("0"); - }) - it('The binary equivalent of 543 should be "1000011111"', () => { - expect(binaryEquivalent(543)).toBe("1000011111"); - }) - it('The binary equivalent of 4697621023 should be "100011000000000000000001000011111"', () => { - expect(binaryEquivalent(4697621023)).toBe("100011000000000000000001000011111"); - }) +const tests = [ + { + test: 2, + expectedValue: "10" + }, + { + test: 0, + expectedValue: "0" + }, + { + test: 543, + expectedValue: "1000011111" + }, + { + test: 4697621023, + expectedValue: "100011000000000000000001000011111" + } +] + +describe("Binary Equivalent Tests", () => { + test.each(tests)( + "Binary Equivalent of $test should be $expectedValue", + ({test, expectedValue}) => { + expect(binaryEquivalent(test)).toBe(expectedValue); + } + ) }) \ No newline at end of file From 8f6472b0e544e006e37851f8056f71babb2d0f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:03:32 +0200 Subject: [PATCH 3/3] Update BinaryEquivalent.test.js --- Recursive/test/BinaryEquivalent.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Recursive/test/BinaryEquivalent.test.js b/Recursive/test/BinaryEquivalent.test.js index 95b977fa67..b79a455eed 100644 --- a/Recursive/test/BinaryEquivalent.test.js +++ b/Recursive/test/BinaryEquivalent.test.js @@ -19,11 +19,11 @@ const tests = [ } ] -describe("Binary Equivalent Tests", () => { +describe("Binary Equivalent", () => { test.each(tests)( - "Binary Equivalent of $test should be $expectedValue", + "of $test should be $expectedValue", ({test, expectedValue}) => { expect(binaryEquivalent(test)).toBe(expectedValue); } ) -}) \ No newline at end of file +})
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: