Skip to content
Merged
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
22 changes: 0 additions & 22 deletions katas/fizz-buzz/index.js

This file was deleted.

218 changes: 0 additions & 218 deletions katas/fizz-buzz/package-lock.json

This file was deleted.

17 changes: 5 additions & 12 deletions katas/fizz-buzz/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{
"name": "fizzbuzz",
"version": "1.0.0",
"description": "FizzBuzz kata",
"main": "index.js",
"name": "fizz-buzz",
"scripts": {
"test": "mocha -w --reporter spec"
"test": "mocha -w"
},
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.1.2",
"mocha": "^5.2.0"
},
"devDependencies": {}
"devDependencies": {
"mocha": "3.2.0"
}
}
49 changes: 4 additions & 45 deletions katas/fizz-buzz/test.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,12 @@
var fizzbuzz = require('./index').fizzbuzz;
var printLines = require('./index').printLines;
const assert = require('assert');

var assert = require('chai').assert;

describe('Example test', function() {
describe('Fizz Buzz Game', function() {

it('does works', () => {
it('works', () => {
const expected = true;
const actual = true;
const actual = false;

assert.equal(actual, expected);
});
});

describe('Fizz Buzz Game', function() {

// Put tests here
it('1 should return 1', () => {
assert.equal(fizzbuzz(1), 1);
})

it('should return fizz divisible by 3', () => {
assert.equal(fizzbuzz(3), 'fizz');
assert.equal(fizzbuzz(6), 'fizz');

})

it('should return buzz divisible by 5', () => {
assert.equal(fizzbuzz(5), 'buzz');
assert.equal(fizzbuzz(20), 'buzz');

})

it('should return fizzbuzz if divisible by 15', () => {
assert.equal(fizzbuzz(15), 'fizzbuzz');
assert.equal(fizzbuzz(45), 'fizzbuzz');
})

it('should return null if input not a number', () => {
assert.equal(fizzbuzz('yes'), null);
})

});

describe('Line Printer', function() {

it('Returns an array', () => {
const actual = printLines(0);
const expected = '';
assert.strictEqual(actual, expected);
})
})
43 changes: 2 additions & 41 deletions katas/yatzy/index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
const _ = require('lodash')
const CONSTRUCTOR_ERROR = new Error("The parameter should be an array of 5 integers between 1 and 6.");
const NUMBER_OF_DICE = 5;
const MAX_VALUE = 6;
const MIN_VALUE = 1;
function Yatzy(){}

class Yatzy {
constructor(diceRolls) {
if (!_.isArray(diceRolls) || _.size(diceRolls) !== NUMBER_OF_DICE) {
throw CONSTRUCTOR_ERROR
}
_.forEach(diceRolls, (diceRoll) => {
if (!_.isInteger(diceRoll) || !_.inRange(diceRoll, MIN_VALUE, MAX_VALUE)) {
throw CONSTRUCTOR_ERROR
}
})
this.diceRolls = diceRolls
}
chance() {
return _.sum(this.diceRolls)
}
yatzy() {
if (_(this.diceRolls).uniq().size() === 1) {
return _.sum(this.diceRolls)
}
return 0
}
number(value) {
return _(this.diceRolls).filter(roll => roll === value).sum()
}
pair() {
if (_(this.diceRolls).uniq().size() === 5) {
return 0
}
return _(this.diceRolls).countBy().filter((val, key) => key > 1)
.map((value, key) => value * 2).max()
// TODO: FIXME
// TODO: find ressource to explain async and functions as arguments
// TODO: find resources to explain how to setup
}
}
module.exports = Yatzy;
module.exports = yatzy;
7 changes: 2 additions & 5 deletions katas/yatzy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
"description": "This Refactoring Kata was designed by Jon Jagger and is available in his Cyber-Dojo. See [his blog post](http://jonjagger.blogspot.co.uk/2012/05/yahtzee-cyber-dojo-refactoring-in-java.html)",
"main": "index.js",
"scripts": {
"test": "mocha -w",
"test:coverage": "nyc mocha"
"test": "mocha -w"
},
"devDependencies": {
"mocha": "3.2.0"
},
"dependencies": {
"chai": "^4.1.2",
"lodash": "^4.17.10",
"nyc": "^11.8.0"
"chai": "^4.1.2"
}
}
Loading