Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Sep 2, 2024
1 parent 00c4739 commit 5a77243
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/astro/test/content-layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { sep as posixSep } from 'node:path/posix';
import { after, before, describe, it } from 'node:test';
import * as devalue from 'devalue';

const pause = (ms = 700) => new Promise((r) => setTimeout(r, ms));

import { loadFixture } from './test-utils.js';
describe('Content Layer', () => {
/** @type {import("./test-utils.js").Fixture} */
Expand Down Expand Up @@ -192,7 +194,8 @@ describe('Content Layer', () => {
let devServer;
let json;
before(async () => {
devServer = await fixture.startDevServer();
devServer = await fixture.startDevServer({ force: true });
await pause()
const rawJsonResponse = await fixture.fetch('/collections.json');
const rawJson = await rawJsonResponse.text();
json = devalue.parse(rawJson);
Expand Down Expand Up @@ -282,13 +285,14 @@ describe('Content Layer', () => {
return JSON.stringify(data, null, 2);
});

// Writes are debounced to 500ms
await new Promise((r) => setTimeout(r, 700));
// Writes are debounced, so we need to wait a few ms
await pause()

const updatedJsonResponse = await fixture.fetch('/collections.json');
const updated = devalue.parse(await updatedJsonResponse.text());
assert.ok(updated.fileLoader[0].data.temperament.includes('Bouncy'));
await fixture.resetAllFiles();
await pause()
});

it('reloads data when an integration triggers a content refresh', async () => {
Expand Down

0 comments on commit 5a77243

Please sign in to comment.