Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 99ac7c5

Browse files
committed
--update : add product-of-element.test.js
1 parent 61dcf64 commit 99ac7c5

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const { findProduct, findProduct2 } = require('.');
2+
3+
describe('Productof elements', () => {
4+
let array = [];
5+
6+
describe('When count of zero is 0', () => {
7+
beforeEach(() => {
8+
array = [1, 2, 3, 4];
9+
});
10+
it('With 1st Approach', () => {
11+
expect(findProduct(array)).toEqual([24, 12, 8, 6]);
12+
});
13+
it('With 2st Approach', () => {
14+
expect(findProduct2(array)).toEqual([24, 12, 8, 6]);
15+
});
16+
});
17+
18+
describe('When count of zero is 1', () => {
19+
beforeEach(() => {
20+
array = [2, 3, 0, 4];
21+
});
22+
it('With 1st Approach', () => {
23+
expect(findProduct(array)).toEqual([0, 0, 24, 0]);
24+
});
25+
it('With 2st Approach', () => {
26+
expect(findProduct2(array)).toEqual([0, 0, 24, 0]);
27+
});
28+
});
29+
30+
describe('When count of zero is 2', () => {
31+
beforeEach(() => {
32+
array = [0, 3, 0, 4];
33+
});
34+
it('With 1st Approach', () => {
35+
expect(findProduct(array)).toEqual([0, 0, 0, 0]);
36+
});
37+
it('With 2st Approach', () => {
38+
expect(findProduct2(array)).toEqual([0, 0, 0, 0]);
39+
});
40+
});
41+
42+
describe('When count of zero is greater than 2', () => {
43+
beforeEach(() => {
44+
array = [0, 3, 0, 4, 8, 0];
45+
});
46+
it('With 1st Approach', () => {
47+
expect(findProduct(array)).toEqual([0, 0, 0, 0, 0, 0]);
48+
});
49+
it('With 2st Approach', () => {
50+
expect(findProduct2(array)).toEqual([0, 0, 0, 0, 0, 0]);
51+
});
52+
});
53+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /