From 99ac7c57e59e2d9abd794faca16e9a40af1ac286 Mon Sep 17 00:00:00 2001 From: ashudeshwal999 Date: Sun, 8 Sep 2019 02:32:13 +0530 Subject: [PATCH] --update : add product-of-element.test.js --- .../product-of-elements.test.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/_Problems_/product-of-elements/product-of-elements.test.js diff --git a/src/_Problems_/product-of-elements/product-of-elements.test.js b/src/_Problems_/product-of-elements/product-of-elements.test.js new file mode 100644 index 00000000..ad7a6cad --- /dev/null +++ b/src/_Problems_/product-of-elements/product-of-elements.test.js @@ -0,0 +1,53 @@ +const { findProduct, findProduct2 } = require('.'); + +describe('Productof elements', () => { + let array = []; + + describe('When count of zero is 0', () => { + beforeEach(() => { + array = [1, 2, 3, 4]; + }); + it('With 1st Approach', () => { + expect(findProduct(array)).toEqual([24, 12, 8, 6]); + }); + it('With 2st Approach', () => { + expect(findProduct2(array)).toEqual([24, 12, 8, 6]); + }); + }); + + describe('When count of zero is 1', () => { + beforeEach(() => { + array = [2, 3, 0, 4]; + }); + it('With 1st Approach', () => { + expect(findProduct(array)).toEqual([0, 0, 24, 0]); + }); + it('With 2st Approach', () => { + expect(findProduct2(array)).toEqual([0, 0, 24, 0]); + }); + }); + + describe('When count of zero is 2', () => { + beforeEach(() => { + array = [0, 3, 0, 4]; + }); + it('With 1st Approach', () => { + expect(findProduct(array)).toEqual([0, 0, 0, 0]); + }); + it('With 2st Approach', () => { + expect(findProduct2(array)).toEqual([0, 0, 0, 0]); + }); + }); + + describe('When count of zero is greater than 2', () => { + beforeEach(() => { + array = [0, 3, 0, 4, 8, 0]; + }); + it('With 1st Approach', () => { + expect(findProduct(array)).toEqual([0, 0, 0, 0, 0, 0]); + }); + it('With 2st Approach', () => { + expect(findProduct2(array)).toEqual([0, 0, 0, 0, 0, 0]); + }); + }); +});