This converts all pure tests to Jest. This was done by first running `npx jest-codemods` with the Mocha transformation, then manually fixing any places where it hadn't automatically converted the correct thing or had missed things (mostly Sinon). This also sets up VSCode correctly for running Jest.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import * as path from "path";
|
|
import { DbConfig } from "../../../../src/databases/config/db-config";
|
|
import { DbConfigValidator } from "../../../../src/databases/config/db-config-validator";
|
|
|
|
describe("db config validation", () => {
|
|
const extensionPath = path.join(__dirname, "../../../..");
|
|
const configValidator = new DbConfigValidator(extensionPath);
|
|
|
|
it("should return error when file is not valid", async () => {
|
|
// We're intentionally bypassing the type check because we'd
|
|
// like to make sure validation errors are highlighted.
|
|
const dbConfig = {
|
|
databases: {
|
|
remote: {
|
|
repositoryLists: [
|
|
{
|
|
name: "repoList1",
|
|
repositories: ["foo/bar", "foo/baz"],
|
|
},
|
|
],
|
|
repositories: ["owner/repo1", "owner/repo2", "owner/repo3"],
|
|
somethingElse: "bar",
|
|
},
|
|
},
|
|
} as any as DbConfig;
|
|
|
|
const validationOutput = configValidator.validate(dbConfig);
|
|
|
|
expect(validationOutput).toHaveLength(3);
|
|
|
|
expect(validationOutput[0]).toEqual(
|
|
"/databases must have required property 'local'",
|
|
);
|
|
expect(validationOutput[1]).toEqual(
|
|
"/databases/remote must have required property 'owners'",
|
|
);
|
|
expect(validationOutput[2]).toEqual(
|
|
"/databases/remote must NOT have additional properties",
|
|
);
|
|
});
|
|
});
|