diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/fizzBuzz/fizzBuzz.js b/fizzBuzz/fizzBuzz.js new file mode 100644 index 0000000..599c64f --- /dev/null +++ b/fizzBuzz/fizzBuzz.js @@ -0,0 +1,16 @@ +module.exports = { + convert : function test(i) { + var f = i % 3 == 0, b = i % 5 == 0; + return f ? (b ? "FizzBuzz" : "Fizz" ): (b ? "Buzz" : '') ; + } +} +// function coba(i){ +// if(i%3 === 0) { +// if(i%5 ===0) return "fizzbuzz" +// return "fizz" +// } else if(i%5===0){ +// return "buzz" +// } +// return i +// } +// console.log(coba(15)) diff --git a/package.json b/package.json new file mode 100644 index 0000000..8007048 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "fizzbuzz-tdd", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Wahyuhidayatt/fizzbuzz-tdd.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/Wahyuhidayatt/fizzbuzz-tdd/issues" + }, + "homepage": "https://github.com/Wahyuhidayatt/fizzbuzz-tdd#readme", + "dependencies": { + "chai": "^3.5.0", + "express": "^4.15.2" + } +} diff --git a/test/fizzBuzzTest.js b/test/fizzBuzzTest.js new file mode 100644 index 0000000..2c1d975 --- /dev/null +++ b/test/fizzBuzzTest.js @@ -0,0 +1,21 @@ +const chai = require('chai'); +const should = chai.should(); + +const fizzBuzz = require('../fizzBuzz/fizzBuzz') + + + +describe('Pengetesan fungsi fizzbuzz', function () { + it('Kata yang keluar harus FizzBuzz', function() { + fizzBuzz.convert(15).should.equal('FizzBuzz') + }) + it('Kata yang keluar harus fizz', function() { + fizzBuzz.convert(3).should.equal('Fizz') + }) + it('Kata yang keluar harus Buzz', function() { + fizzBuzz.convert(5).should.equal('Buzz') + }) + it('Keluarkan inputan ', function() { + fizzBuzz.convert(2).should.equal('') + }) +})