Files
babel/packages/babel-preset-flow/test/normalize-options.skip-bundled.js

38 lines
1.4 KiB
JavaScript

import normalizeOptions from "../lib/normalize-options.js";
describe("normalize options", () => {
describe("Babel 8", () => {
it("should throw on unknown options", () => {
expect(() => normalizeOptions({ al: true }))
.toThrowErrorMatchingInlineSnapshot(`
"@babel/preset-flow: 'al' is not a valid top-level option.
- Did you mean 'all'?"
`);
});
it("should throw on Babel 7 `allowDeclareFields` option", () => {
expect(() =>
normalizeOptions({ allowDeclareFields: true }),
).toThrowErrorMatchingInlineSnapshot(
`"@babel/preset-flow: Since Babel 8, \`declare property: A\` is always supported, and the "allowDeclareFields" option is no longer available. Please remove it from your config."`,
);
});
it.each(["all"])("should throw when `%p` is not a boolean", optionName => {
expect(() => normalizeOptions({ [optionName]: 0 })).toThrow(
`@babel/preset-flow: '${optionName}' option must be a boolean.`,
);
});
it("should not throw when options is not defined", () => {
expect(() => normalizeOptions()).not.toThrow();
});
it("default values", () => {
expect(normalizeOptions({})).toMatchInlineSnapshot(`
{
"all": undefined,
"experimental_useHermesParser": undefined,
"ignoreExtensions": undefined,
}
`);
});
});
});