Skip to content

Instantly share code, notes, and snippets.

@invasionofsmallcubes
Created May 2, 2022 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invasionofsmallcubes/5ea699dbd8e4ebf071029fdeb89f5938 to your computer and use it in GitHub Desktop.
Save invasionofsmallcubes/5ea699dbd8e4ebf071029fdeb89f5938 to your computer and use it in GitHub Desktop.
A FizzBuzz TDD Kata done using only Github Copilot
// create a function called onumitama that accepts a number and returns 'LaL'
function onumitama(num) {
// if num is divisible by 3 and by 5, return 'LaLPoP'
if (num % 3 === 0 && num % 5 === 0) {
return 'LaLPoP'
}
// if num is divisible by 3, return 'LaL'
if (num % 3 === 0) {
return 'LaL'
}
// if num divided by 5 equals 0, return 'PoP'
if (num % 5 === 0) {
return 'PoP'
}
// return num as string
return num.toString()
}
// export onumitama
module.exports = onumitama
// Language: javascript
//import onumitama as constant
const onumitama = require('./onumitama');
// create a test for a function that accepts a number and returns a string
describe('onumitama', function() {
// create a test for onumitama that accepts 3 and returns 'LaL'
it('should return LaL', function() {
expect(onumitama(3)).toBe('LaL');
})
//create a test for onumitama that accepts 10 and returns 'PoP'
it('should return PoP', function() {
expect(onumitama(10)).toBe('PoP');
})
// create a test for onumitama that accepts 5 and returns 'PoP'
it('should return PoP', function() {
expect(onumitama(5)).toBe('PoP');
})
//create a test for onumitama that accepts 15 and returns 'LaLPoP'
it('should return LaLPoP', function() {
expect(onumitama(15)).toBe('LaLPoP');
})
// create a test for onumitama that accepts 1 and return '1'
it('should return 1', function() {
expect(onumitama(1)).toBe('1');
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment