Files
JavaScript/Maths/test/SumOfDigits.test.js
Legendary Noob b3b4ad43a3 chore: Added Sum of Digits Implementation (#684)
* Added the main logic, need to work on Tests

* Added tests for SOD

* Fix typo and add Wikipedia link in comments

* Fix mistake in SumOfDigitsUsingStrings

I intended to initially write a different implementation but I wrote something else 🤦‍♂️

* Converted Spacing from Tabs to Spaces

* Oops, forgot about the test file

* Fixed semicolon problems...

* Oops, I missed a few semicolons

* Linting is hell TwT

Co-authored-by: SpiderMath <{ID}+{username}@users.noreply.github.com>
2021-09-13 19:41:28 +05:30

17 lines
461 B
JavaScript

import { sumOfDigitsUsingLoop, sumOfDigitsUsingRecursion, sumOfDigitsUsingString } from '../SumOfDigits'
test('Testing on sumOfDigitsUsingLoop', () => {
const sum = sumOfDigitsUsingLoop(123)
expect(sum).toBe(6)
})
test('Testing on sumOfDigitsUsingRecursion', () => {
const sum = sumOfDigitsUsingRecursion(123)
expect(sum).toBe(6)
})
test('Testing on sumOfDigitsUsingString', () => {
const sum = sumOfDigitsUsingString(123)
expect(sum).toBe(6)
})