browsertrix-crawler/tests/collection_name.test.js
Emma Segal-Grossman 2a49406df7
Add Prettier to the repo, and format all the files! (#428)
This adds prettier to the repo, and sets up the pre-commit hook to
auto-format as well as lint.
Also updates ignores files to exclude crawls, test-crawls, scratch, dist as needed.
2023-11-09 16:11:11 -08:00

32 lines
886 B
JavaScript

import util from "util";
import { exec as execCallback } from "child_process";
const exec = util.promisify(execCallback);
test("check that the collection name is properly validated", async () => {
let passed = "";
try {
await exec(
"docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --url http://www.example.com/ --collection valid_collection-nameisvalid",
);
passed = true;
} catch (error) {
passed = false;
}
expect(passed).toBe(true);
});
test("check that the collection name is not accepted if it doesn't meets our standards", async () => {
let passed = "";
try {
await exec(
"docker run webrecorder/browsertrix-crawler crawl --url http://www.example.com/ --collection invalid_c!!ollection-nameisvalid",
);
passed = true;
} catch (e) {
passed = false;
}
expect(passed).toBe(false);
});