From 1049ad30added79a5db3d6af233744ed90280cde Mon Sep 17 00:00:00 2001 From: Carvallegro Date: Fri, 1 Jun 2018 11:35:03 +1000 Subject: [PATCH] Revert "Group A: FizzBuzz work" This reverts commit e8be5237f653eb8000ae72916381c81a99f43662. --- katas/fizz-buzz/index.js | 22 --- katas/fizz-buzz/package-lock.json | 218 ------------------------------ katas/fizz-buzz/package.json | 17 +-- katas/fizz-buzz/test.js | 49 +------ katas/yatzy/index.js | 43 +----- katas/yatzy/package.json | 7 +- katas/yatzy/test.js | 60 +------- 7 files changed, 17 insertions(+), 399 deletions(-) delete mode 100644 katas/fizz-buzz/index.js delete mode 100644 katas/fizz-buzz/package-lock.json diff --git a/katas/fizz-buzz/index.js b/katas/fizz-buzz/index.js deleted file mode 100644 index 4626d17..0000000 --- a/katas/fizz-buzz/index.js +++ /dev/null @@ -1,22 +0,0 @@ -function fizzbuzz(number){ - if (isNaN(number)) { - return null; - } - if(number % 15 == 0){ - return 'fizzbuzz'; - } else if(number % 5 == 0) { - return 'buzz'; - } else if(number % 3 ==0) { - return 'fizz'; - } else { - return number; - } - } - - function printLines (num) { - return ''; - } - -module.exports= { - fizzbuzz, printLines -} \ No newline at end of file diff --git a/katas/fizz-buzz/package-lock.json b/katas/fizz-buzz/package-lock.json deleted file mode 100644 index 4923e10..0000000 --- a/katas/fizz-buzz/package-lock.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "name": "fizzbuzz", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" - }, - "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", - "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", - "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" - }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "requires": { - "type-detect": "^4.0.0" - } - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "requires": { - "has-flag": "^3.0.0" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - } - } -} diff --git a/katas/fizz-buzz/package.json b/katas/fizz-buzz/package.json index 78cbfd2..f255afc 100644 --- a/katas/fizz-buzz/package.json +++ b/katas/fizz-buzz/package.json @@ -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" + } } diff --git a/katas/fizz-buzz/test.js b/katas/fizz-buzz/test.js index 65ea587..0a67241 100644 --- a/katas/fizz-buzz/test.js +++ b/katas/fizz-buzz/test.js @@ -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); - }) -}) diff --git a/katas/yatzy/index.js b/katas/yatzy/index.js index 44cfa51..8591944 100644 --- a/katas/yatzy/index.js +++ b/katas/yatzy/index.js @@ -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; \ No newline at end of file +module.exports = yatzy; \ No newline at end of file diff --git a/katas/yatzy/package.json b/katas/yatzy/package.json index 611d412..3131086 100644 --- a/katas/yatzy/package.json +++ b/katas/yatzy/package.json @@ -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" } } diff --git a/katas/yatzy/test.js b/katas/yatzy/test.js index 415a15b..7cd3b04 100644 --- a/katas/yatzy/test.js +++ b/katas/yatzy/test.js @@ -1,61 +1,9 @@ -const expect = require('chai').expect +const assert = require('chai').assert const Yatzy = require('./index') describe('Yatzi game', () => { - describe('constructor', () => { - it('Should throw an exception when the parameter is not an array', () => { - expect(() => { new Yatzy(1) }).to.throw('The parameter should be an array of 5 integers between 1 and 6.') - }) - it('Should throw error when the length of the input array is not equal to 5', () => { - expect(() => { new Yatzy([1, 2, 3, 4]) }).to.throw('The parameter should be an array of 5 integers between 1 and 6.') - }) - it('Should throw an error if arrays has not integers', () => { - expect(() => { new Yatzy([1, 2, 3, "4", 5]) }).to.throw('The parameter should be an array of 5 integers between 1 and 6.') - }) - it('Should throw an error if values are not between 1 and 6.', () => { - expect(() => { new Yatzy([1, 2, 3, 20, 5]) }).to.throw('The parameter should be an array of 5 integers between 1 and 6.') - }) - it('Should create an object with the same array values that is provided.', () => { - const acceptableRoll = new Yatzy([1, 2, 3, 4, 5]) - expect(acceptableRoll.diceRolls).to.be.eql([1, 2, 3, 4, 5]) - }) + it('should be fixed', () => { + assert(false).to.be.true }) - describe('Chance', () => { - it('Should return the sum of all values in the array', () => { - const acceptableRoll = new Yatzy([1, 2, 3, 4, 5]) - expect(acceptableRoll.chance()).to.be.equal(15) - }) - }) - describe('Yatzi', () => { - it('Should return 0 if array has different values', () => { - const acceptableRoll = new Yatzy([1, 2, 3, 4, 5]) - expect(acceptableRoll.yatzy()).to.be.equal(0) - }) - it('Should return the sum of all integers of an array if the array has the same values', () => { - const acceptableRoll = new Yatzy([1, 1, 1, 1, 1]) - expect(acceptableRoll.yatzy()).to.be.equal(5) - }) - }) - describe('Number', () => { - it('Should return 0 if the number doesnt exist in the array', () => { - const acceptableRoll = new Yatzy([2, 2, 3, 4, 5]) - expect(acceptableRoll.number(1)).to.be.equal(0) - }) - it('Should return the sum of the numbers in the array matching the value', () => { - const acceptableRoll = new Yatzy([2, 2, 3, 4, 5]) - expect(acceptableRoll.number(2)).to.be.equal(4) - }) - }) - describe('Pair', () => { - it('Should return 0 if there is no pairs in the array', () => { - const acceptableRoll = new Yatzy([1, 2, 3, 4, 5]) - expect(acceptableRoll.pair()).to.be.equal(0) - }) - it('Should return some of the highest pair', () => { - const acceptableRoll = new Yatzy([2, 2, 3, 3, 5]) - expect(acceptableRoll.pair()).to.be.equal(6) - }) - }) -}) - +}) \ No newline at end of file