@mintlify/previewing
Version:
Preview Mintlify docs locally
31 lines (30 loc) • 1.52 kB
JavaScript
import path from 'path';
import * as constants from '../constants.js';
describe('configurePreviewPath', () => {
afterEach(() => {
constants.configureSharedPreviewPath();
});
it('keeps non-dev commands outside port workspaces', () => {
constants.configureSharedPreviewPath();
expect(constants.PREVIEW_PATH).toBe(path.join(constants.DOT_MINTLIFY, 'previews', 'shared'));
});
it('isolates preview files by port', () => {
constants.configurePreviewPath(3000);
const defaultPreviewPath = constants.PREVIEW_PATH;
constants.configurePreviewPath(3001);
expect(constants.PREVIEW_PATH).not.toBe(defaultPreviewPath);
expect(constants.PREVIEW_PATH).toBe(path.join(constants.DOT_MINTLIFY, 'previews', '3001'));
expect(constants.MINT_PATH).toBe(path.join(constants.PREVIEW_PATH, 'mint'));
expect(constants.CLIENT_PATH).toBe(path.join(constants.MINT_PATH, 'apps', 'client'));
expect(constants.TAR_PATH).toBe(path.join(constants.PREVIEW_PATH, 'mint.tar.gz'));
});
it('returns to the same files for a reused port', () => {
constants.configurePreviewPath(4000);
const firstPath = constants.PREVIEW_PATH;
constants.configurePreviewPath('4000');
expect(constants.PREVIEW_PATH).toBe(firstPath);
});
it.each([0, 65536, 'not-a-port'])('rejects an invalid port: %s', (port) => {
expect(() => constants.configurePreviewPath(port)).toThrow(`invalid preview port: ${port}`);
});
});