2020-11-24 06:07:36 +03:00
|
|
|
import md5File = require("md5-file");
|
2019-05-08 21:39:02 +03:00
|
|
|
|
2020-11-24 06:07:36 +03:00
|
|
|
import * as validate from "../lib/validate";
|
2019-05-08 21:39:02 +03:00
|
|
|
|
|
|
|
export const validateExamplesRegressionTest = async (file: string) => {
|
|
|
|
try {
|
2020-11-24 06:07:36 +03:00
|
|
|
const hash = await new Promise((resolve) =>
|
2022-04-18 12:52:58 +03:00
|
|
|
md5File(file).then((h) => {
|
2020-11-24 06:07:36 +03:00
|
|
|
resolve(h);
|
2019-05-08 21:39:02 +03:00
|
|
|
})
|
2020-11-24 06:07:36 +03:00
|
|
|
);
|
|
|
|
expect(hash).toMatchSnapshot("input file hash");
|
2019-05-08 21:39:02 +03:00
|
|
|
|
|
|
|
const result = await validate.validateExamples(file, undefined, {
|
2020-11-24 06:07:36 +03:00
|
|
|
pretty: true,
|
|
|
|
});
|
|
|
|
expect(result).toMatchSnapshot("returned results");
|
2019-05-08 21:39:02 +03:00
|
|
|
} catch (e) {
|
2020-11-24 06:07:36 +03:00
|
|
|
expect(e).toMatchSnapshot("thrown exception");
|
2019-05-08 21:39:02 +03:00
|
|
|
}
|
2020-11-24 06:07:36 +03:00
|
|
|
};
|