Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #422

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Tests #422

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/getCoinCombination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,51 @@ describe('getCoinCombination', () => {
expect(getCoinCombination)
.toBeInstanceOf(Function);
});

it(`should return an array with 4 int`, () => {
const result = getCoinCombination(25);

expect(Array.isArray(result)).toBe(true);

for (const change of result) {
expect(Number.isInteger(change)).toBe(true);
}
});

it(`returns 0 with 0 cents`, () => {
expect(getCoinCombination(0)).toEqual([0, 0, 0, 0]);
});

it(`returns 1 penny with 1 cent`, () => {
expect(getCoinCombination(1)).toEqual([1, 0, 0, 0]);
});

it(`returns 1 nickel with 5 cents`, () => {
expect(getCoinCombination(5)).toEqual([0, 1, 0, 0]);
});

it(`returns 1 dime with 10 cents`, () => {
expect(getCoinCombination(10)).toEqual([0, 0, 1, 0]);
});

it(`returns 1 quarter with 25 cents`, () => {
expect(getCoinCombination(25)).toEqual([0, 0, 0, 1]);
});

it(`quarter, dime and penny with 36 cents`, () => {
expect(getCoinCombination(36)).toEqual([1, 0, 1, 1]);
});

it(`2 quarters, dime and a nickel with 65 cents`, () => {
expect(getCoinCombination(65)
Bulavskyi marked this conversation as resolved.
Show resolved Hide resolved

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing closing parenthesis in the expect function call. Please add the closing parenthesis to ensure the test runs correctly.

).toEqual([0, 1, 1, 2]);
Comment on lines +45 to +47

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected result for 65 cents seems to be incorrect. It should be [0, 1, 1, 2] for 2 quarters, 1 dime, and 1 nickel. Please verify and correct the expected output.

});

// TEST FOR NaN
/*
it(`cents === NaN`, () => {
expect(getCoinCombination(NaN)
).toEqual([0,0,0,0]);
});
*/
});