@nx-plugins/slidev
Version:
The Nx Plugin for Slidev that contains executors, generators, and utilities for managing Slidev applications within an Nx workspace.
116 lines • 4.86 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('Build 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 build 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 watch is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
watch: true,
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev build --watch 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 out 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 build --out=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: 'start',
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev build --base=start 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 download is specified', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield (0, executor_1.default)({
entry: 'src/slides.md',
download: true,
}, mockContext);
expect(run_commands_impl_1.default).toHaveBeenCalledWith({
command: `slidev build --download 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 build --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