From c198a9f53d2880d8cbbbc4482c20cec18a4a87f1 Mon Sep 17 00:00:00 2001 From: Omkarnath Parida Date: Sun, 3 Oct 2021 17:28:17 +0530 Subject: [PATCH] Added test for ScrambleStrings and formatted folder structure for other folders --- Navigation/{ => test}/Haversine.test.js | 2 +- Sorts/{ => test}/QuickSortRecursive.test.js | 2 +- Sorts/{ => test}/SelectionSort.test.js | 2 +- String/ScrambleStrings.js | 2 +- String/{ => test}/CheckVowels.test.js | 2 +- String/{ => test}/CheckWordOcurrence.test.js | 2 +- String/{ => test}/FormatPhoneNumber.test.js | 2 +- String/{ => test}/LevenshteinDistance.test.js | 2 +- String/{ => test}/MaxCharacter.test.js | 2 +- String/{ => test}/PermutateString.test.js | 2 +- String/test/ScrambleStrings.test.js | 15 +++++++++++++++ Timing-Functions/{ => test}/GetMonthDays.test.js | 2 +- 12 files changed, 26 insertions(+), 11 deletions(-) rename Navigation/{ => test}/Haversine.test.js (88%) rename Sorts/{ => test}/QuickSortRecursive.test.js (95%) rename Sorts/{ => test}/SelectionSort.test.js (94%) rename String/{ => test}/CheckVowels.test.js (97%) rename String/{ => test}/CheckWordOcurrence.test.js (95%) rename String/{ => test}/FormatPhoneNumber.test.js (92%) rename String/{ => test}/LevenshteinDistance.test.js (94%) rename String/{ => test}/MaxCharacter.test.js (87%) rename String/{ => test}/PermutateString.test.js (93%) create mode 100644 String/test/ScrambleStrings.test.js rename Timing-Functions/{ => test}/GetMonthDays.test.js (90%) diff --git a/Navigation/Haversine.test.js b/Navigation/test/Haversine.test.js similarity index 88% rename from Navigation/Haversine.test.js rename to Navigation/test/Haversine.test.js index e779da045..3d89dcfda 100644 --- a/Navigation/Haversine.test.js +++ b/Navigation/test/Haversine.test.js @@ -1,4 +1,4 @@ -import { haversineDistance } from './Haversine' +import { haversineDistance } from '../Haversine' describe('Testing the haversine distance calculator', () => { it('Calculate distance', () => { diff --git a/Sorts/QuickSortRecursive.test.js b/Sorts/test/QuickSortRecursive.test.js similarity index 95% rename from Sorts/QuickSortRecursive.test.js rename to Sorts/test/QuickSortRecursive.test.js index d82299aa3..39a44eb8b 100644 --- a/Sorts/QuickSortRecursive.test.js +++ b/Sorts/test/QuickSortRecursive.test.js @@ -1,4 +1,4 @@ -import { quickSort } from './QuickSortRecursive' +import { quickSort } from '../QuickSortRecursive' describe('QuickSortRecursive | Partition In Place Method', () => { it('Expectedly, throw some error if we pass a non-array input', () => { diff --git a/Sorts/SelectionSort.test.js b/Sorts/test/SelectionSort.test.js similarity index 94% rename from Sorts/SelectionSort.test.js rename to Sorts/test/SelectionSort.test.js index 090ccc0a5..79f8ce303 100644 --- a/Sorts/SelectionSort.test.js +++ b/Sorts/test/SelectionSort.test.js @@ -1,4 +1,4 @@ -import { selectionSort } from './SelectionSort' +import { selectionSort } from '../SelectionSort' describe('selectionSort', () => { it('expects to return the array sorted in ascending order', () => { diff --git a/String/ScrambleStrings.js b/String/ScrambleStrings.js index 14c9eb68f..d9e02b066 100644 --- a/String/ScrambleStrings.js +++ b/String/ScrambleStrings.js @@ -47,4 +47,4 @@ const helper = function (dp, s1, s2) { return false } -console.log(isScramble('great', 'rgeat')) +export { isScramble } diff --git a/String/CheckVowels.test.js b/String/test/CheckVowels.test.js similarity index 97% rename from String/CheckVowels.test.js rename to String/test/CheckVowels.test.js index fe002a8c1..e430fd4a2 100644 --- a/String/CheckVowels.test.js +++ b/String/test/CheckVowels.test.js @@ -1,4 +1,4 @@ -import { checkVowels } from './CheckVowels' +import { checkVowels } from '../CheckVowels' describe('Test the checkVowels function', () => { it('expect throws on use wrong param', () => { diff --git a/String/CheckWordOcurrence.test.js b/String/test/CheckWordOcurrence.test.js similarity index 95% rename from String/CheckWordOcurrence.test.js rename to String/test/CheckWordOcurrence.test.js index 2b1a88782..0779e0d29 100644 --- a/String/CheckWordOcurrence.test.js +++ b/String/test/CheckWordOcurrence.test.js @@ -1,4 +1,4 @@ -import { checkWordOccurrence } from './CheckWordOccurrence' +import { checkWordOccurrence } from '../CheckWordOccurrence' describe('checkWordOccurrence', () => { it('expects throw on insert wrong string', () => { const value = 123 diff --git a/String/FormatPhoneNumber.test.js b/String/test/FormatPhoneNumber.test.js similarity index 92% rename from String/FormatPhoneNumber.test.js rename to String/test/FormatPhoneNumber.test.js index 85291b84c..0e9febcb7 100644 --- a/String/FormatPhoneNumber.test.js +++ b/String/test/FormatPhoneNumber.test.js @@ -1,4 +1,4 @@ -import { formatPhoneNumber } from './FormatPhoneNumber' +import { formatPhoneNumber } from '../FormatPhoneNumber' describe('PhoneNumberFormatting', () => { it('expects to return the formatted phone number', () => { diff --git a/String/LevenshteinDistance.test.js b/String/test/LevenshteinDistance.test.js similarity index 94% rename from String/LevenshteinDistance.test.js rename to String/test/LevenshteinDistance.test.js index e713f6d9e..a901fd7ca 100644 --- a/String/LevenshteinDistance.test.js +++ b/String/test/LevenshteinDistance.test.js @@ -1,4 +1,4 @@ -import { levenshteinDistance } from './LevenshteinDistance' +import { levenshteinDistance } from '../LevenshteinDistance' describe('levenshteinDistance', () => { it('should calculate edit distance between two strings', () => { diff --git a/String/MaxCharacter.test.js b/String/test/MaxCharacter.test.js similarity index 87% rename from String/MaxCharacter.test.js rename to String/test/MaxCharacter.test.js index d82afa039..6fd419ec3 100644 --- a/String/MaxCharacter.test.js +++ b/String/test/MaxCharacter.test.js @@ -1,4 +1,4 @@ -import { maxCharacter } from './MaxCharacter' +import { maxCharacter } from '../MaxCharacter' describe('Testing the maxCharacter function', () => { it('Expect throw with wrong arg', () => { diff --git a/String/PermutateString.test.js b/String/test/PermutateString.test.js similarity index 93% rename from String/PermutateString.test.js rename to String/test/PermutateString.test.js index 71df87b5e..9d86ebc03 100644 --- a/String/PermutateString.test.js +++ b/String/test/PermutateString.test.js @@ -1,4 +1,4 @@ -import { permutate } from './PermutateString' +import { permutate } from '../PermutateString' describe('Permutate a string', () => { it('expects to throw an Error with an empty string', () => { diff --git a/String/test/ScrambleStrings.test.js b/String/test/ScrambleStrings.test.js new file mode 100644 index 000000000..00d8ef202 --- /dev/null +++ b/String/test/ScrambleStrings.test.js @@ -0,0 +1,15 @@ +import { isScramble } from '../ScrambleStrings' + +describe('ScrambleStrings', () => { + it('expects to return true for same string', () => { + expect(isScramble('a', 'a')).toBe(true) + }) + + it('expects to return false for non-scrambled strings', () => { + expect(isScramble('abcde', 'caebd')).toBe(false) + }) + + it('expects to return true for scrambled strings', () => { + expect(isScramble('great', 'rgeat')).toBe(true) + }) +}) \ No newline at end of file diff --git a/Timing-Functions/GetMonthDays.test.js b/Timing-Functions/test/GetMonthDays.test.js similarity index 90% rename from Timing-Functions/GetMonthDays.test.js rename to Timing-Functions/test/GetMonthDays.test.js index 2be43982c..ca9285702 100644 --- a/Timing-Functions/GetMonthDays.test.js +++ b/Timing-Functions/test/GetMonthDays.test.js @@ -1,4 +1,4 @@ -import { getMonthDays } from './GetMonthDays' +import { getMonthDays } from '../GetMonthDays' describe('Get the Days of a Month', () => { it('expects to return 28', () => {