Skip to content

Commit 222d854

Browse files
committed
test: custom loader options
1 parent e07f22b commit 222d854

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/__tests__/plugin.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import webpack, { Configuration } from "webpack";
22
import { createFsFromVolume, IFs, Volume } from "memfs";
33
import ReactDocgenTypeScriptPlugin from "..";
4+
import { LoaderOptions } from "../types";
45

56
// eslint-disable-next-line
67
const joinPath = require("memory-fs/lib/join");
@@ -84,3 +85,34 @@ test("default options", async () => {
8485

8586
expect(result).toContain("STORYBOOK_REACT_CLASSES");
8687
});
88+
89+
describe("custom options", () => {
90+
describe("loader options", () => {
91+
const options: Record<
92+
keyof LoaderOptions,
93+
Array<LoaderOptions[keyof LoaderOptions]>
94+
> = {
95+
setDisplayName: [true, false, undefined],
96+
typePropName: ["customValue", undefined],
97+
docgenCollectionName: ["customValue", null, undefined],
98+
};
99+
const { defaultOptions } = ReactDocgenTypeScriptPlugin;
100+
101+
(Object.keys(options) as Array<keyof LoaderOptions>).forEach(
102+
(optionName) => {
103+
const values = options[optionName];
104+
105+
test.each(values)(`${optionName}: %p`, (value) => {
106+
const plugin = new ReactDocgenTypeScriptPlugin({
107+
[optionName]: value,
108+
});
109+
const { generateOptions: resultOptions } = plugin.getOptions();
110+
111+
expect(resultOptions[optionName]).toBe(
112+
value === undefined ? defaultOptions[optionName] : value
113+
);
114+
});
115+
}
116+
);
117+
});
118+
});

0 commit comments

Comments
 (0)