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

Solution #455

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
33 changes: 31 additions & 2 deletions src/getCoinCombination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,36 @@ describe('getCoinCombination', () => {
const { getCoinCombination } = require('./getCoinCombination');

it(`should be declared`, () => {
expect(getCoinCombination)
.toBeInstanceOf(Function);
expect(getCoinCombination).toBeDefined();
});

it(`returns an array`, () => {
expect(getCoinCombination(100)).toBeInstanceOf(Array);
});

it(`returns array of length = 4`, () => {
expect(getCoinCombination(100)).toHaveLength(4);
});

it(`returns array with numbers`, () => {
const result = getCoinCombination(100);

result.forEach((value) => expect(typeof value).toBe('number'));
});

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

it(`returns array with pennies and nickels if 5 < cents < 10`, () => {
expect(getCoinCombination(6)).toEqual([1, 1, 0, 0]);
});

it(`returns array with pennies, nickels and dimes if 10 < cents < 25`, () => {
expect(getCoinCombination(17)).toEqual([2, 1, 1, 0]);
});

it(`returns array with quarters if cents are divisible by 25`, () => {
expect(getCoinCombination(50)).toEqual([0, 0, 0, 2]);
});
});