jest-hands-on/templates/promise/promise.test.js
2022-02-24 17:06:32 +09:00

23 lines
618 B
JavaScript

/** @license https://github.com/facebook/jest/blob/master/LICENSE */
// ダミー
const fetchData = () => Promise.resolve("peanut butter");
test("the data is peanut butter", () => {
return fetchData().then((data) => {
expect(data).toBe("peanut butter");
});
});
test("the data is peanut butter", () => {
return expect(fetchData()).resolves.toBe("peanut butter");
});
test("the data is peanut butter", async () => {
const data = await fetchData();
expect(data).toBe("peanut butter");
});
test("the data is peanut butter", async () => {
await expect(fetchData()).resolves.toBe("peanut butter");
});