2021-07-27 10:54:21 +09:00
|
|
|
/** @license https://github.com/facebook/jest/blob/master/LICENSE */
|
|
|
|
|
|
|
|
// ダミー
|
|
|
|
const fetchData = () => Promise.resolve("peanut butter");
|
|
|
|
|
2022-02-24 21:50:24 +09:00
|
|
|
test("the data is peanut butter - return promise", () => {
|
2021-07-27 10:54:21 +09:00
|
|
|
return fetchData().then((data) => {
|
|
|
|
expect(data).toBe("peanut butter");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-02-24 21:50:24 +09:00
|
|
|
test("the data is peanut butter - return promise with resolves", () => {
|
2021-07-27 10:54:21 +09:00
|
|
|
return expect(fetchData()).resolves.toBe("peanut butter");
|
|
|
|
});
|
|
|
|
|
2022-02-24 21:50:24 +09:00
|
|
|
test("the data is peanut butter - async/await", async () => {
|
2021-07-27 10:54:21 +09:00
|
|
|
const data = await fetchData();
|
|
|
|
expect(data).toBe("peanut butter");
|
|
|
|
});
|
|
|
|
|
2022-02-24 21:50:24 +09:00
|
|
|
test("the data is peanut butter - async/await with resolves", async () => {
|
2021-07-27 10:54:21 +09:00
|
|
|
await expect(fetchData()).resolves.toBe("peanut butter");
|
|
|
|
});
|