@storybook/angular
Version:
Storybook for Angular: Develop Angular components in isolation with hot reloading.
87 lines (86 loc) • 3.44 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const { runCompodoc } = require('./run-compodoc');
const mockRunScript = jest.fn();
jest.mock('@storybook/cli', () => ({
JsPackageManagerFactory: {
getPackageManager: () => ({
runPackageCommandSync: mockRunScript,
}),
},
}));
const builderContextLoggerMock = {
createChild: jest.fn(),
log: jest.fn(),
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
fatal: jest.fn(),
};
describe('runCompodoc', () => {
afterEach(() => {
mockRunScript.mockClear();
});
it('should run compodoc with tsconfig from context', async () => {
runCompodoc({
compodocArgs: [],
tsconfig: 'path/to/tsconfig.json',
}, {
workspaceRoot: 'path/to/project',
logger: builderContextLoggerMock,
})
.pipe((0, operators_1.take)(1))
.subscribe();
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
});
it('should run compodoc with tsconfig from compodocArgs', async () => {
runCompodoc({
compodocArgs: ['-p', 'path/to/tsconfig.stories.json'],
tsconfig: 'path/to/tsconfig.json',
}, {
workspaceRoot: 'path/to/project',
logger: builderContextLoggerMock,
})
.pipe((0, operators_1.take)(1))
.subscribe();
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-d', 'path/to/project', '-p', 'path/to/tsconfig.stories.json'], 'path/to/project', 'inherit');
});
it('should run compodoc with default output folder.', async () => {
runCompodoc({
compodocArgs: [],
tsconfig: 'path/to/tsconfig.json',
}, {
workspaceRoot: 'path/to/project',
logger: builderContextLoggerMock,
})
.pipe((0, operators_1.take)(1))
.subscribe();
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
});
it('should run with custom output folder specified with --output compodocArgs', async () => {
runCompodoc({
compodocArgs: ['--output', 'path/to/customFolder'],
tsconfig: 'path/to/tsconfig.json',
}, {
workspaceRoot: 'path/to/project',
logger: builderContextLoggerMock,
})
.pipe((0, operators_1.take)(1))
.subscribe();
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '--output', 'path/to/customFolder'], 'path/to/project', 'inherit');
});
it('should run with custom output folder specified with -d compodocArgs', async () => {
runCompodoc({
compodocArgs: ['-d', 'path/to/customFolder'],
tsconfig: 'path/to/tsconfig.json',
}, {
workspaceRoot: 'path/to/project',
logger: builderContextLoggerMock,
})
.pipe((0, operators_1.take)(1))
.subscribe();
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/customFolder'], 'path/to/project', 'inherit');
});
});