I had done Bootcamp in JS but never understood TDD until now doing a course on YT. I made some basic tests for angram, Can someone tell me is it good test to get started, I am building on top of it but I wanted to ask if I am on the right path
*.test.js
describe('Angrams', () => {
it('should return true if Angram', () => {
const input = "elbow"
const valueToCheck = "below"
const actual = getLetterCount(input, valueToCheck);
const expected = true
expect(actual).toBe(expected)
});
it('should return false if not a Angram', () => {
const input = "water"
const valueToCheck = "radio"
const actual = getLetterCount(input, valueToCheck);
const expected = false
expect(actual).toBe(expected)
});
*.js
function getLetterCount(string, ingram){
//split the args into array
let arrayOne = string.split("");
let arrayTwo = ingram.split("");
console.log(arrayOne);
console.log(arrayTwo);
//sort each args using array's .sort method
let arrayOneSorted = arrayOne.sort();
let arrayTwoSorted = arrayTwo.sort();
//join array that has been sorted
//compare if new sorted item are same,
let sortedOne = arrayOneSorted.join("");
let sortedSecond = arrayTwoSorted.join("");
//if they are, return true
if(sortedOne == sortedSecond){
return true
}else{
return false
}
}
Edit ; As @RandellDawson pointed out in post # 2, there was mistake in description so I have updated the question