@nx-plugins/slidev
Version:
The Nx Plugin for Slidev that contains executors, generators, and utilities for managing Slidev applications within an Nx workspace.
142 lines • 6.11 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const executor_1 = require("./executor");
const run_commands_impl_1 = require("@nrwl/workspace/src/executors/run-commands/run-commands.impl");
const path_1 = require("path");
const vitest_1 = require("vitest");
vitest_1.vi.mock('@nrwl/workspace/src/executors/run-commands/run-commands.impl', () => {
return {
default: vitest_1.vi.fn(() => Promise.resolve({
results: {
success: true,
},
})),
};
});
describe('Export Executor', () => {
let mockContext;
beforeEach(() => {
mockContext = {
root: '/root',
projectName: 'proj',
workspace: {
version: 2,
projects: {
proj: {
root: 'proj',
sourceRoot: 'proj/src',
targets: {},
},
},
npmScope: '',
},
cwd: '/root',
isVerbose: true,
};
});
it('should send appropriate options to slidev', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when output is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
output: 'dist',
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --output=dist src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when base is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
base: 'pdf',
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --base=pdf src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when timeout is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
timeout: 2000,
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --timeout=2000 src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when range is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
range: '4-5',
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --range=4-5 src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when dark is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
dark: true,
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --dark src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when withClicks is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
withClicks: true,
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --with-clicks src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
it('should send appropriate options when theme is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
theme: 'mytheme',
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev export --theme=mytheme src/slides.md`,
parallel: false,
color: true,
__unparsed__: [],
cwd: (0, path_1.join)(mockContext.root, mockContext.workspace.projects['proj'].root),
}, mockContext);
}));
});
//# sourceMappingURL=executor.spec.js.map