Skip to content

Commit

Permalink
Async function test via docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 19, 2024
1 parent e2dc044 commit 65e5ea6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/QueueTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});

0 comments on commit 65e5ea6

Please sign in to comment.