mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 02:05:08 +08:00
Add tests to Math (#423)
* Add prettier config * test: add test to check for absolute function * chore: es5 to es6 * test: add test to check mean function * test: add test for sum of digit * test: add test for factorial * test: add test for fibonnaci * test: add test for find HCF * test: add test for lcm * test: add gridget test * test: add test for mean square error * test: add test for modular binary exponentiation * test: add tests for palindrome * test: add test for pascals triangle * test: add tests for polynomial * test: add tests for prime check * test: add tests for reverse polish notation * test: add tests for sieve of eratosthenes * test: add tests for pi estimation monte carlo method * chore: move tests to test folder * chore: fix standardjs errors
This commit is contained in:

committed by
GitHub

parent
554abf7126
commit
e112434dee
@ -24,7 +24,6 @@ const checkIfPatternExists = (text, pattern) => {
|
||||
// For each iteration of j check if the value of
|
||||
// j + 1 is equal to the length of the pattern
|
||||
if (j + 1 === patternLength) {
|
||||
console.log(`Given pattern is found at index ${i}`)
|
||||
return `Given pattern is found at index ${i}`
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { checkAnagram } from './CheckAnagram'
|
||||
import { checkAnagram } from '../CheckAnagram'
|
||||
|
||||
describe('checkAnagram', () => {
|
||||
it.each`
|
||||
@ -18,7 +18,7 @@ describe('checkAnagram', () => {
|
||||
)
|
||||
it('expects to return "Not anagram" if the arguments have different lengths', () => {
|
||||
const SUT = checkAnagram('abs', 'abds')
|
||||
expect(SUT).toBe('Not Anagram')
|
||||
expect(SUT).toBe('Not anagrams')
|
||||
})
|
||||
it('expects to return "Not anagram" if the arguments are not anagrams', () => {
|
||||
const SUT = checkAnagram('abcs', 'abds')
|
@ -1,4 +1,4 @@
|
||||
import { checkPalindrome } from './CheckPalindrome'
|
||||
import { checkPalindrome } from '../CheckPalindrome'
|
||||
|
||||
describe('checkPalindrome', () => {
|
||||
it('expects to return "Palindrome" if the given string is a palindrome', () => {
|
@ -1,4 +1,4 @@
|
||||
import { checkIfPatternExists } from './PatternMatching'
|
||||
import { checkIfPatternExists } from '../PatternMatching'
|
||||
describe('checkIfPatternExists', () => {
|
||||
it('expects to find a pattern with correct input', () => {
|
||||
const text = 'AABAACAADAABAAAABAA'
|
||||
@ -21,6 +21,8 @@ describe('checkIfPatternExists', () => {
|
||||
it('expects to throw an error message when given inpuut is not a string', () => {
|
||||
const text = 123444456
|
||||
const pattern = 123
|
||||
expect(() => checkIfPatternExists(text, pattern)).toThrow('Given input is not a string')
|
||||
expect(() => checkIfPatternExists(text, pattern)).toThrow(
|
||||
'Given input is not a string'
|
||||
)
|
||||
})
|
||||
})
|
@ -1,7 +1,7 @@
|
||||
import {
|
||||
ReverseStringIterative,
|
||||
ReverseStringIterativeInplace
|
||||
} from './ReverseString'
|
||||
} from '../ReverseString'
|
||||
|
||||
describe('ReverseStringIterative', () => {
|
||||
it('expects to reverse a simple string', () => {
|
@ -1,4 +1,4 @@
|
||||
import { reverseWords } from './ReverseWords'
|
||||
import { reverseWords } from '../ReverseWords'
|
||||
|
||||
describe('reverseWords', () => {
|
||||
it('expects to reverse words to return a joined word', () => {
|
Reference in New Issue
Block a user