From 65e5ea655a0293b63ffe19154400ced45050c936 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 19 Nov 2024 14:55:43 -0600 Subject: [PATCH] Async function test via docs --- test/QueueTest.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/QueueTest.js b/test/QueueTest.js index 4d1b6e9..e6405e1 100644 --- a/test/QueueTest.js +++ b/test/QueueTest.js @@ -95,3 +95,25 @@ test("Double Fetch 404 errors should only fetch once", async (t) => { await t.throwsAsync(async () => await ac2); }); +test("Docs example https://www.11ty.dev/docs/plugins/fetch/#manually-store-your-own-data-in-the-cache", async (t) => { + t.plan(2); + + async function fn() { + t.true(true); + return new Promise(resolve => { + setTimeout(() => { + resolve({ followerCount: 1000 }) + }); + }); + } + + let fakeFollowers = Cache(fn, { + type: "json", + dryRun: true, + requestId: "zachleat_twitter_followers" + }); + + t.deepEqual(await fakeFollowers, { + followerCount: 1000 + }); +});