How do I write the login and get functions in javascript? I have a feeling that it's possible with some mixture of inline functions, bind and this magic. Or is it impossible?
Promise.all([
login("user1", () => {
console.log(get("/healthy")); // prints "user1/healthy"
}),
login("user2", () => {
console.log(get("/ready")); // prints "user2/ready"
})
]);
I know it would be possible to write it like this. But I got curious about writing it without the obj.
login("user1", (obj) => {
obj.get("/ready");
});
Isn't this similar to how Jest have coded the descript/it pattern?
describe("Login test", () => {
test("Login", async () => {
expect("ready").toEqual("ready");
});
});