Welcome to the Linux Foundation Forum!

Lab 16.3 April 2021 edition

My test for the failure case works fine. My test for the success case times out. If I promisify the callback based store from lab 2, my test passes and I can see that it is in fact waiting. Am I doing something wrong or is there something wrong with the lab?

const store = require('./store');
const { promisify } = require('util')
const store2 = promisify(require('../labs-2/store'));

describe("store", () => {
//SUCCEEDS
it("should throw if not given a buffer", async () => {
try {
await store("bad");
} catch (err) {
expect(err).toEqual(new Error("input must be a buffer"));
}
});

//SUCCEEDS and has a delay between the console.logs
it("should return an id with a length of 4 given a buffer", async () => {
    console.log(new Date())
    const result = await store2(Buffer.from("good"));
    console.log(new Date())
    expect(result.id.length).toBe(4);
});

//Times out
it("should return an id with a length of 4 given a buffer", async () => {
    console.log(new Date())
    const result = await store(Buffer.from("good"));
    console.log(new Date())
    expect(result.id.length).toBe(4);
});

});

Comments

Sign In or Register to comment.