summaryrefslogtreecommitdiff
path: root/packages/astro/test/content-layer.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro/test/content-layer.test.js')
-rw-r--r--packages/astro/test/content-layer.test.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js
index c853a3be5..d61d30450 100644
--- a/packages/astro/test/content-layer.test.js
+++ b/packages/astro/test/content-layer.test.js
@@ -200,7 +200,7 @@ describe('Content Layer', () => {
// Vite may not have noticed the saved data store yet. Wait a little just in case.
await fixture.onNextDataStoreChange(1000).catch(() => {
// Ignore timeout, because it may have saved before we get here.
- })
+ });
const rawJsonResponse = await fixture.fetch('/collections.json');
const rawJson = await rawJsonResponse.text();
json = devalue.parse(rawJson);
@@ -279,6 +279,22 @@ describe('Content Layer', () => {
});
});
+ it('reloads data when an integration triggers a content refresh', async () => {
+ const rawJsonResponse = await fixture.fetch('/collections.json');
+ const initialJson = devalue.parse(await rawJsonResponse.text());
+ assert.equal(initialJson.increment.data.lastValue, 1);
+
+ const refreshResponse = await fixture.fetch('/_refresh', {
+ method: 'POST',
+ body: JSON.stringify({}),
+ });
+ const refreshData = await refreshResponse.json();
+ assert.equal(refreshData.message, 'Content refreshed successfully');
+ const updatedJsonResponse = await fixture.fetch('/collections.json');
+ const updated = devalue.parse(await updatedJsonResponse.text());
+ assert.equal(updated.increment.data.lastValue, 2);
+ });
+
it('updates collection when data file is changed', async () => {
const rawJsonResponse = await fixture.fetch('/collections.json');
const initialJson = devalue.parse(await rawJsonResponse.text());