Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions __tests__/kata1.fizzBuzz.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ const { fizzBuzz } = require('../src');

describe('fizzBuzz', () => {
it('returns Fizz when passed a multiple of 3', () => {

expect(fizzBuzz(3)).toBe('Fizz')
});

it('returns Buzz when passed a multiple of 5', () => {

expect(fizzBuzz(5)).toBe('Buzz')
});

it('returns FizzBuzz when passed a multiple 3 and 5', () => {

expect(fizzBuzz(15)).toBe('FizzBuzz')
expect(fizzBuzz(30)).toBe('FizzBuzz')
expect(fizzBuzz(90)).toBe('FizzBuzz')
});

it('returns the number when it isn\'t a multiple of 3 or 5', () => {

expect(fizzBuzz(4)).toBe(4)
expect(fizzBuzz(11)).toBe(11)
});
});
10 changes: 8 additions & 2 deletions __tests__/kata2.booleanToWord.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const { booleanToWord } = require('../src');

describe('booleanToWord', () => {
// how do we create specs again???
});
it('returns Yes when passed true', () => {
expect(booleanToWord(true)).toBe('Yes')
});

it('returns No when passed false', () => {
expect(booleanToWord(false)).toBe('No')
});
});
2 changes: 1 addition & 1 deletion __tests__/kata3.numberToReversedDigits.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const { numberToReversedDigits } = require('../src');

describe('numberToReversedDigits', () => {
it('returns a reversed array of the number\'s digits', () => {

expect(numberToReversedDigits(12345)).toEqual([5, 4, 3, 2, 1])
});
});
10 changes: 9 additions & 1 deletion __tests__/kata4.humanCatDogYears.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
const { humanCatDogYears } = require('../src');

// Look Ma, no handlebars!!!
describe('humanCatDogYears', () => {
it('returns array of cat, human and dog ages', () => {
expect(humanCatDogYears(10)).toEqual([10, 56, 64])
});

it('returns array of cat, human and dog ages even if less than 3', () => {
expect(humanCatDogYears(2)).toEqual([2, 24, 24])
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These tests are fine and work accordingly but should the user enter a 0, negative number, a 3 or upwards, the code that passes these tests will fail. Ensure your tests have more robust coverage.

2 changes: 1 addition & 1 deletion __tests__/kata5.reachDestination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const { reachDestination } = require('../src');

describe('reachDestination', () => {
it('returns string with estimated time of arrival', () => {

expect(reachDestination(44, 10)).toEqual('I should be there in 4.5 hours')
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

More robust testing needed for edge cases.

19 changes: 18 additions & 1 deletion __tests__/kata6.joinNames.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
const { joinNames } = require('../src');

describe('joinNames', () => {

const objectsArray = [{
name: 'Bart'
}, {
name: 'Lisa'
}, {
name: 'Maggie'
}]

const objectsArray2 = [{
name: 'Jack'
}]

it('returns string of names, seperated by commas and an ampersand', () => {

expect(joinNames(objectsArray)).toBe('Bart, Lisa & Maggie');
});

it('will return single name and no ampersand if objects array has only 1 object', () => {
expect(joinNames(objectsArray2)).toBe('Jack');
});
});
16 changes: 14 additions & 2 deletions __tests__/kata7.getEmployerRole.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
const { getEmployerRole } = require('../src');

describe('getEmployerRole', () => {
it('returns the employee\'s role in the company', () => {


const employees = [{
name: 'Satti',
role: 'Developer'
}, {
name: 'Jenny',
role: 'Sales Associate'
}, {
name: 'Javid',
role: 'Human Recommended Reading Assistant'
}]

it('returns the employee\'s role in the company', () => {
expect(getEmployerRole('Jenny', employees)).toBe('Sales Associate');
});
});
Loading