UNPKG

storybook-addon-jsdoc-to-mdx

Version:

Storybook addon that automatically generates MDX documentation from JSDoc comments in your TypeScript and JavaScript files. Supports HTML tags in comments, complex TypeScript types, and integrates seamlessly with Storybook 7.x and 8.x.

35 lines (34 loc) 1.43 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const analyzeFolders_1 = require("./analyzeFolders"); const regenerate_1 = require("./regenerate"); // Mock the analyzeFolders module jest.mock('./analyzeFolders', () => ({ analyzeFolders: jest.fn() })); // Mock console.log to prevent output during tests jest.spyOn(console, 'log').mockImplementation(() => { }); describe('regenerateMdxFiles', () => { // Clear mocks before each test beforeEach(() => { jest.clearAllMocks(); }); it('should call analyzeFolders with the correct parameters', () => { // Call the function directly (0, regenerate_1.regenerateMdxFiles)(); // Assert const expectedPath = path_1.default.resolve(__dirname, '../examples/code'); expect(analyzeFolders_1.analyzeFolders).toHaveBeenCalledTimes(1); expect(analyzeFolders_1.analyzeFolders).toHaveBeenCalledWith([expectedPath], ['ts', 'js']); }); it('should log a message when regeneration is complete', () => { // Call the function directly (0, regenerate_1.regenerateMdxFiles)(); // Assert expect(console.log).toHaveBeenCalledWith('MDX files have been regenerated.'); }); });