summaryrefslogtreecommitdiff
path: root/packages/astro/test/content-layer.test.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/astro/test/content-layer.test.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js
index e2d92df3d..16aa96c29 100644
--- a/packages/astro/test/content-layer.test.js
+++ b/packages/astro/test/content-layer.test.js
@@ -424,5 +424,26 @@ describe('Content Layer', () => {
assert.equal(res.status, 500);
assert.ok(text.includes('RenderUndefinedEntryError'));
});
+
+ it('update the store when a file is renamed', async () => {
+ const rawJsonResponse = await fixture.fetch('/collections.json');
+ const initialJson = devalue.parse(await rawJsonResponse.text());
+ assert.equal(initialJson.numbers.map((e) => e.id).includes('src/data/glob-data/three'), true);
+
+ const oldPath = new URL('./data/glob-data/three.json', fixture.config.srcDir);
+ const newPath = new URL('./data/glob-data/four.json', fixture.config.srcDir);
+
+ await fs.rename(oldPath, newPath);
+ await fixture.onNextDataStoreChange();
+
+ try {
+ const updatedJsonResponse = await fixture.fetch('/collections.json');
+ const updated = devalue.parse(await updatedJsonResponse.text());
+ assert.equal(updated.numbers.map((e) => e.id).includes('src/data/glob-data/three'), false);
+ assert.equal(updated.numbers.map((e) => e.id).includes('src/data/glob-data/four'), true);
+ } finally {
+ await fs.rename(newPath, oldPath);
+ }
+ });
});
});