Hey guys so I am currently working on this async function and writing unit test for this but it is not working it says AssertionError: expected undefined to equal 'Everytime I think of coding, I am happy' this is my code for the function:
async function funcFour() {// async automatically returns a promise
let result = new Promise((resolve) => {// returns a new promise named result
setTimeout(() => {
resolve(`Everytime I think of coding, I am happy`);//resolve happens after three seconds
}, 1500)
});
const response = await result;//closing resolve of new promise
console.log(response);//console.logging response of new promise
} funcFour();
And here is my unit test for it:
describe("flirtFour()", () => {
it("Should return Everytime I think of coding, I am happy", async function () {
return flirtFour().then(result => {
expect(result).to.equal("Everytime I think of coding, I am happy")
})
})
})
This is the first time I write unit test and I am trying to do it with async func so I am new to it. I really want to see how this is done so Thanks in advance :)