Skip to content

Commit

Permalink
chore: add test (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas authored Apr 3, 2024
1 parent 7367241 commit 73ba445
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,4 +715,51 @@ describe('list', () => {
expect(mockStore.fulfilled).toBeTruthy()
})
})

test('Uses the uncached edge URL if `consistency: "strong"`', async () => {
const uncachedEdgeURL = 'https://uncached-edge.netlify'
const mockStore = new MockFetch().get({
headers: { authorization: `Bearer ${edgeToken}` },
response: new Response(
JSON.stringify({
blobs: [
{
etag: 'etag1',
key: 'key1',
size: 1,
last_modified: '2023-07-18T12:59:06Z',
},
{
etag: 'etag2',
key: 'key2',
size: 2,
last_modified: '2023-07-18T12:59:06Z',
},
],
directories: [],
}),
),
url: `${uncachedEdgeURL}/${siteID}/site:${storeName}`,
})

globalThis.fetch = mockStore.fetch

const store = getStore({
consistency: 'strong',
edgeURL,
name: storeName,
token: edgeToken,
siteID,
uncachedEdgeURL,
})

const { blobs, directories } = await store.list()

expect(blobs).toEqual([
{ etag: 'etag1', key: 'key1' },
{ etag: 'etag2', key: 'key2' },
])
expect(directories).toEqual([])
expect(mockStore.fulfilled).toBeTruthy()
})
})

0 comments on commit 73ba445

Please sign in to comment.