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.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js
index 3ac37514b..6b833085d 100644
--- a/packages/astro/test/content-layer.test.js
+++ b/packages/astro/test/content-layer.test.js
@@ -83,6 +83,16 @@ describe('Content Layer', () => {
]);
});
+ it('handles negative matches in glob() loader', async () => {
+ assert.ok(json.hasOwnProperty('probes'));
+ assert.ok(Array.isArray(json.probes));
+ assert.equal(json.probes.length, 5);
+ assert.ok(
+ json.probes.every(({ id }) => !id.startsWith('voyager')),
+ 'Voyager probes should not be included',
+ );
+ });
+
it('Returns data entry by id', async () => {
assert.ok(json.hasOwnProperty('dataEntry'));
assert.equal(json.dataEntry.filePath?.split(sep).join(posixSep), 'src/data/dogs.json');
@@ -279,6 +289,24 @@ 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 now = new Date().toISOString();
+
+ const refreshResponse = await fixture.fetch('/_refresh', {
+ method: 'POST',
+ body: JSON.stringify({ now }),
+ });
+ 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);
+ assert.deepEqual(updated.increment.data.refreshContextData, { webhookBody: { now } });
+ });
+
it('updates collection when data file is changed', async () => {
const rawJsonResponse = await fixture.fetch('/collections.json');
const initialJson = devalue.parse(await rawJsonResponse.text());