-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- created all required unit tests with jests for the package. all critical methods were covered in these tests - removed/corrected some methods in the package
- Loading branch information
1 parent
0206833
commit efa2393
Showing
14 changed files
with
418 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* app imports */ | ||
import Vowelz from "../src/index.js"; | ||
|
||
/* t-suite */ | ||
describe("Vowelz - countAllVowels method", () => { | ||
let myVowelz = null; | ||
|
||
beforeAll(() => { | ||
myVowelz = new Vowelz(); | ||
}); | ||
|
||
afterAll(() => { | ||
myVowelz = null; | ||
}); | ||
|
||
test("returns all vowels as 'zero' count if input string is empty", () => { | ||
const input = ""; | ||
const output = { | ||
a: 0, | ||
e: 0, | ||
i: 0, | ||
o: 0, | ||
u: 0 | ||
}; | ||
const result = myVowelz.countAllVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("returns all vowels as 'zero' count if there are no vowels in input string", () => { | ||
const input = "My Rhythms fly. My rhythms cry."; | ||
const output = { | ||
a: 0, | ||
e: 0, | ||
i: 0, | ||
o: 0, | ||
u: 0 | ||
}; | ||
const result = myVowelz.countAllVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("returns the correct count of all vowels from an input string", () => { | ||
const input = "Hello World. This is a test message"; | ||
const output = { | ||
a: 2, | ||
e: 4, | ||
i: 2, | ||
o: 2, | ||
u: 0 | ||
}; | ||
const result = myVowelz.countAllVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* app imports */ | ||
import Vowelz from "../src/index.js"; | ||
|
||
/* t-suite */ | ||
describe("Vowelz - extractAllVowelsFromString method", () => { | ||
let myVowelz = null; | ||
|
||
beforeAll(() => { | ||
myVowelz = new Vowelz(); | ||
}); | ||
|
||
afterAll(() => { | ||
myVowelz = null; | ||
}); | ||
|
||
test("will also extract duplicate strings from the input", () => { | ||
const input = "Pool Table"; | ||
const output = ["o", "o", "a", "e"]; | ||
const result = myVowelz.extractAllVowelsFromString(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("preserves the order of vowels in the input string", () => { | ||
const input = "Beautiful World"; | ||
const output = ["e", "a", "u", "i", "u", "o"]; | ||
const result = myVowelz.extractAllVowelsFromString(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("gives an empty array output if no vowels are present in the input", () => { | ||
const input = "1234567890!@#$%^&*()~_+"; | ||
const output = []; | ||
const result = myVowelz.extractAllVowelsFromString(input); | ||
expect(result).toHaveLength(0); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("returns an empty array if the input string is empty", () => { | ||
const input = ""; | ||
const output = []; | ||
const result = myVowelz.extractAllVowelsFromString(input); | ||
expect(result).toHaveLength(0); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("the ouput array of vowels is of the right length", () => { | ||
const input = "Hello World"; | ||
const output = 3; | ||
const result = myVowelz.extractAllVowelsFromString(input); | ||
expect(result).toHaveLength(output); | ||
}); | ||
|
||
test("correct extracts all vowels from a given string", () => { | ||
const input = "Hello, World! This is a test string."; | ||
const output = ["e", "o", "o", "i", "i", "a", "e", "i"]; | ||
const result = myVowelz.extractAllVowelsFromString(input); | ||
expect(result).toEqual(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* app imports */ | ||
import Vowelz from "../src/index.js"; | ||
|
||
/* t-suite */ | ||
describe("Vowelz - getPositionsOfVowels method", () => { | ||
let myVowelz = null; | ||
|
||
beforeAll(() => { | ||
myVowelz = new Vowelz(); | ||
}); | ||
|
||
afterAll(() => { | ||
myVowelz = null; | ||
}); | ||
|
||
test("provides the correct result even when are duplicate vowels", () => { | ||
const input = "Pool Table"; | ||
const output = [1, 2, 6, 9]; | ||
const result = myVowelz.getPositionsOfVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("result prevserves order of indices for vowels in input string", () => { | ||
const input = "hello world"; | ||
const output = [1, 4, 7]; | ||
const result = myVowelz.getPositionsOfVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("no vowels in string: results in empty array", () => { | ||
const input = "~!@#$%^&*()_+1234567890"; | ||
const output = []; | ||
const result = myVowelz.getPositionsOfVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("empty string input: results in empty array", () => { | ||
const input = ""; | ||
const output = []; | ||
const result = myVowelz.getPositionsOfVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
|
||
test("returns an array of numbers, which are indices of vowels in input", () => { | ||
const input = 'Hello, World! This is a test string.'; | ||
const output = [1, 4, 8, 16, 19, 22, 25, 32]; | ||
const result = myVowelz.getPositionsOfVowels(input); | ||
expect(result).toEqual(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* app imports */ | ||
import Vowelz from "../src/index.js"; | ||
|
||
/* t-suite */ | ||
describe("Vowelz - getTotalCount method", () => { | ||
let myVowelz = null; | ||
|
||
beforeAll(() => { | ||
myVowelz = new Vowelz(); | ||
}); | ||
|
||
afterAll(() => { | ||
myVowelz = null; | ||
}); | ||
|
||
test("result includes duplicate vowels present in input string", () => { | ||
const input = "Pool Table"; | ||
const output = 4; | ||
const result = myVowelz.getTotalCount(input); | ||
expect(result).toBe(output); | ||
}); | ||
|
||
test("will return 'zero' if there are no vowels present", () => { | ||
const input = ""; | ||
const output = 0; | ||
const result = myVowelz.getTotalCount(input); | ||
expect(result).toBe(output); | ||
}); | ||
|
||
test("will return 'zero' if input string is empty", () => { | ||
const input = ""; | ||
const output = 0; | ||
const result = myVowelz.getTotalCount(input); | ||
expect(result).toBe(output); | ||
}); | ||
|
||
test("evaluates and returns correct number of vowels in an input string", () => { | ||
const input = "Hello, World! This is a test string."; | ||
const output = 8; | ||
const result = myVowelz.getTotalCount(input); | ||
expect(result).toBe(output); | ||
}); | ||
|
||
test("return a number type when caluclating total count of vowels", () => { | ||
const input = "Hello World!"; | ||
const result = myVowelz.getTotalCount(input); | ||
expect(typeof result).toBe("number"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* app imports */ | ||
import Vowelz from "../src/index.js"; | ||
|
||
/* t-suite */ | ||
describe("Vowelz - replaceVowelsWithCharacter method", () => { | ||
let myVowelz = null; | ||
|
||
beforeAll(() => { | ||
myVowelz = new Vowelz(); | ||
}); | ||
|
||
afterAll(() => { | ||
myVowelz = null; | ||
}); | ||
|
||
test("throws an error if 'character arg' length is greater than 1", () => { | ||
function demoWrapper() { | ||
myVowelz.replaceVowelsWithCharacter("Hello World", "**"); | ||
} | ||
expect(demoWrapper).toThrow(); | ||
}); | ||
|
||
test("will not modify the input string if there are no vowels", () => { | ||
const character = "&"; | ||
const input = "1234567890~!@#$%^&*()_+"; | ||
const output = "1234567890~!@#$%^&*()_+"; | ||
const results = myVowelz.replaceVowelsWithCharacter(input, character); | ||
expect(results).toBe(output); | ||
}); | ||
|
||
test("will return an empty string if the input string is empty", () => { | ||
const character = "&"; | ||
const input = ""; | ||
const output = ""; | ||
const results = myVowelz.replaceVowelsWithCharacter(input, character); | ||
expect(results).toBe(output); | ||
}); | ||
|
||
test("correctly replaces vowels with a given character", () => { | ||
const character = "&"; | ||
const input = "The sky is blue"; | ||
const output = "Th& sky &s bl&&"; | ||
const results = myVowelz.replaceVowelsWithCharacter(input, character); | ||
expect(results).toBe(output); | ||
}); | ||
}); |
Oops, something went wrong.