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.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js
index 225025b30..10d7790ff 100644
--- a/packages/astro/test/content-layer.test.js
+++ b/packages/astro/test/content-layer.test.js
@@ -467,6 +467,37 @@ describe('Content Layer', () => {
await fixture.resetAllFiles();
});
+ it('removes old entry when slug is changed', async () => {
+ const rawJsonResponse = await fixture.fetch('/collections.json');
+ const initialJson = devalue.parse(await rawJsonResponse.text());
+
+ assert.ok(initialJson.spacecraft.includes('exomars'));
+ assert.ok(!initialJson.spacecraft.includes('rosalind-franklin-rover'));
+
+ await fixture.editFile('/src/content/space/exomars.md', (prev) => {
+ return prev.replace('# slug', 'slug');
+ });
+
+ await fixture.onNextDataStoreChange();
+ const updatedJsonResponse = await fixture.fetch('/collections.json');
+ const updated = devalue.parse(await updatedJsonResponse.text());
+ assert.ok(!updated.spacecraft.includes('exomars'));
+ assert.ok(updated.spacecraft.includes('rosalind-franklin-rover'));
+
+ await fixture.editFile('/src/content/space/exomars.md', (prev) => {
+ return prev.replace('rosalind-franklin-rover', 'rosalind-franklin');
+ })
+
+ await fixture.onNextDataStoreChange();
+ const updatedJsonResponse2 = await fixture.fetch('/collections.json');
+ const updated2 = devalue.parse(await updatedJsonResponse2.text());
+ assert.ok(!updated2.spacecraft.includes('rosalind-franklin-rover'));
+ assert.ok(updated2.spacecraft.includes('rosalind-franklin'));
+
+ await fixture.resetAllFiles();
+
+ });
+
it('returns an error if we render an undefined entry', async () => {
const res = await fixture.fetch('/missing');
const text = await res.text();