Skip to content

Commit

Permalink
test: make test robust for glob order randomness
Browse files Browse the repository at this point in the history
The literal order in the list isn't that important, as long as
the directories and files are correct.
  • Loading branch information
wkillerud committed Nov 18, 2024
1 parent 484480c commit c60f7b2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/publish-files-definitions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ test("when a recursive glob is specified", async (t) => {
// @ts-expect-error
const { files } = await cli.publish(config(pattern, address, token, cwd));

t.equal(files[4].pathname, "/client.js", "client.js should be packaged at /");
t.equal(
files[11].pathname,
files.find((f) => f.pathname.endsWith("client.js")).pathname,
"/client.js",
"client.js should be packaged at /",
);
t.equal(
files.find((f) => f.pathname.endsWith("checkboxes.svg")).pathname,
"/icons/checkboxes.svg",
"svgs should be packaged under /icons",
);
Expand All @@ -255,7 +259,11 @@ test("when a non recursive glob is specified", async (t) => {

const nested = files.filter((file) => file.pathname.includes("icons"));

t.equal(files[4].pathname, "/client.js", "client.js should be packaged at /");
t.equal(
files.find((f) => f.pathname.endsWith("client.js")).pathname,
"/client.js",
"client.js should be packaged at /",
);
t.equal(nested.length, 0, "no nested files should be present");
});

Expand Down

0 comments on commit c60f7b2

Please sign in to comment.