Skip to content

Commit

Permalink
grey out some logs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Aug 20, 2024
1 parent 75be99a commit 720401e
Show file tree
Hide file tree
Showing 22 changed files with 315 additions and 127 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { assert } from "@jsenv/assert";
import { resolveUrl } from "@jsenv/urls";

import {
ensureEmptyDirectory,
registerDirectoryLifecycle,
Expand All @@ -10,6 +8,7 @@ import {
writeFile,
} from "@jsenv/filesystem";
import { wait } from "@jsenv/filesystem/tests/testHelpers.js";
import { resolveUrl } from "@jsenv/urls";

const tempDirectoryUrl = resolveUrl("./temp/", import.meta.url);
await ensureEmptyDirectory(tempDirectoryUrl);
Expand All @@ -20,7 +19,7 @@ await ensureEmptyDirectory(tempDirectoryUrl);
const mutations = [];
const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { "./file": "toto" },
cooldownBetweenFileEvents: 150,
cooldownBetweenFileEvents: 200,
// debug: true,
added: (data) => {
mutations.push({ name: "added", ...data });
Expand All @@ -31,13 +30,13 @@ await ensureEmptyDirectory(tempDirectoryUrl);
keepProcessAlive: false,
});

await wait(200);
await wait(400);
await writeFile(fileUrl);
await wait(200);
await wait(400);
await removeEntry(fileUrl);
await wait(200);
await wait(400);
await writeFile(fileUrl);
await wait(200);
await wait(400);
const actual = mutations;
const expect = [
{
Expand Down Expand Up @@ -67,7 +66,7 @@ await ensureEmptyDirectory(tempDirectoryUrl);
const mutations = [];
const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { "dir/": "toto" },
cooldownBetweenFileEvents: 100,
cooldownBetweenFileEvents: 200,
added: (data) => {
mutations.push({ name: "added", ...data });
},
Expand All @@ -78,9 +77,9 @@ await ensureEmptyDirectory(tempDirectoryUrl);
recursive: true,
});
await writeDirectory(directoryUrl);
await wait(200);
await wait(400);
await writeFile(fileUrl);
await wait(200);
await wait(400);

const actual = mutations;
const expect = [
Expand Down Expand Up @@ -110,7 +109,7 @@ await ensureEmptyDirectory(tempDirectoryUrl);
const mutations = [];
const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { file: "toto" },
cooldownBetweenFileEvents: 100,
cooldownBetweenFileEvents: 200,
added: (data) => {
mutations.push({ name: "added", ...data });
},
Expand All @@ -123,11 +122,11 @@ await ensureEmptyDirectory(tempDirectoryUrl);
keepProcessAlive: false,
});
await writeFile(fileUrl);
await wait(200);
await wait(400);
await writeEntryModificationTime(fileUrl, Date.now());
await wait(200);
await wait(400);
await removeEntry(fileUrl);
await wait(200);
await wait(400);

const actual = mutations;
const expect = [
Expand Down Expand Up @@ -167,7 +166,7 @@ await ensureEmptyDirectory(tempDirectoryUrl);

const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { file: "toto" },
cooldownBetweenFileEvents: 100,
cooldownBetweenFileEvents: 200,
updated: (data) => {
mutations.push({ name: "updated", ...data });
},
Expand All @@ -177,11 +176,11 @@ await ensureEmptyDirectory(tempDirectoryUrl);
keepProcessAlive: false,
});
await removeEntry(fileUrl);
await wait(200);
await wait(400);
await writeFile(fileUrl);
await wait(200);
await wait(400);
await removeEntry(fileUrl);
await wait(200);
await wait(400);
const actual = mutations;
const expect = [
{
Expand Down Expand Up @@ -214,7 +213,7 @@ await ensureEmptyDirectory(tempDirectoryUrl);

const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { "dir/": "toto" },
cooldownBetweenFileEvents: 150,
cooldownBetweenFileEvents: 200,
removed: (data) => {
mutations.push({ name: "removed", ...data });
},
Expand Down Expand Up @@ -274,21 +273,21 @@ await ensureEmptyDirectory(tempDirectoryUrl);

const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { file: "toto" },
cooldownBetweenFileEvents: 100,
cooldownBetweenFileEvents: 200,
updated: (data) => {
mutations.push({ name: "updated", ...data });
},
keepProcessAlive: false,
});
await writeEntryModificationTime(fileUrl, Date.now());
await wait(200);
await wait(400);
// file removed and created in between
await removeEntry(fileUrl);
await wait(200);
await wait(400);
await writeFile(fileUrl);
await wait(200);
await wait(400);
await writeEntryModificationTime(fileUrl, Date.now() + 1000);
await wait(200);
await wait(400);
const actual = mutations;
const expect = [
{
Expand Down Expand Up @@ -317,23 +316,23 @@ await ensureEmptyDirectory(tempDirectoryUrl);
{
const fileUrl = resolveUrl("file", tempDirectoryUrl);
await writeFile(fileUrl);
await wait(200);
await wait(400);
const mutations = [];

const unregister = registerDirectoryLifecycle(tempDirectoryUrl, {
watchPatterns: { file: "toto" },
cooldownBetweenFileEvents: 100,
cooldownBetweenFileEvents: 200,
updated: (data) => {
mutations.push({ name: "updated", ...data });
},
keepProcessAlive: false,
});
await writeEntryModificationTime(fileUrl, Date.now());
await wait(200);
await wait(400);
await writeEntryModificationTime(fileUrl, Date.now());
await wait(200);
await wait(400);
await writeEntryModificationTime(fileUrl, Date.now());
await wait(200);
await wait(400);
const actual = mutations;
const expect = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.8.14"
"version": "2.8.17"
}
Loading

0 comments on commit 720401e

Please sign in to comment.