Skip to content

Commit

Permalink
doing some more filecheck tests (#3251)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Mar 16, 2021
1 parent e5e65c4 commit 5e6d3b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions testing/tests/filecheck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,27 @@ describe("checking files", () => {
"<path> contains an unsafe attribute: 'onload'"
);
});

it("should spot files that are not mentioned in source", async () => {
const filePath = path.join(SAMPLES_DIRECTORY, "orphan.png");
// Sanity check the test itself
console.assert(fs.existsSync(filePath), `${filePath} does not exist`);
await expect(checkFile(filePath)).rejects.toThrow("is not mentioned in");
});

it("should spot files that are completely empty", async () => {
const filePath = path.join(SAMPLES_DIRECTORY, "zero.gif");
// Sanity check the test itself
console.assert(fs.existsSync(filePath), `${filePath} does not exist`);
await expect(checkFile(filePath)).rejects.toThrow("is 0 bytes");
});

it("should spot mismatch between file-type and file extension", async () => {
const filePath = path.join(SAMPLES_DIRECTORY, "png.jpeg");
// Sanity check the test itself
console.assert(fs.existsSync(filePath), `${filePath} does not exist`);
await expect(checkFile(filePath)).rejects.toThrow(
"is type 'image/png' but named extension is '.jpeg'"
);
});
});
Binary file added testing/tests/samplefiles/orphan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testing/tests/samplefiles/png.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e6d3b7

Please sign in to comment.