UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

61 lines 2.71 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const ensure_wrangler_config_1 = require("../../src/cloudflare/wrangler/ensure-wrangler-config"); const node_fs_1 = __importDefault(require("node:fs")); const node_path_1 = __importDefault(require("node:path")); const node_os_1 = __importDefault(require("node:os")); const { clackMocks } = vitest_1.vi.hoisted(() => { const info = vitest_1.vi.fn(); const step = vitest_1.vi.fn(); const success = vitest_1.vi.fn(); return { clackMocks: { info, step, success, }, }; }); vitest_1.vi.mock('@clack/prompts', () => { return { __esModule: true, default: { log: { info: clackMocks.info, step: clackMocks.step, success: clackMocks.success, }, }, }; }); (0, vitest_1.describe)('ensure-wrangler-config', () => { let tmpDir; (0, vitest_1.beforeEach)(() => { vitest_1.vi.clearAllMocks(); tmpDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'ensure-wrangler-config-')); vitest_1.vi.spyOn(process, 'cwd').mockReturnValue(tmpDir); }); (0, vitest_1.afterEach)(() => { if (node_fs_1.default.existsSync(tmpDir)) { node_fs_1.default.rmSync(tmpDir, { recursive: true }); } vitest_1.vi.restoreAllMocks(); }); (0, vitest_1.it)('does nothing if config already exists', () => { node_fs_1.default.writeFileSync(node_path_1.default.join(tmpDir, 'wrangler.jsonc'), '{}'); (0, ensure_wrangler_config_1.ensureWranglerConfig)(); (0, vitest_1.expect)(clackMocks.info).toHaveBeenCalledWith(vitest_1.expect.stringContaining('Found existing Wrangler config')); (0, vitest_1.expect)(node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'wrangler.jsonc'))).toBe(true); }); (0, vitest_1.it)('creates config if none exists', () => { (0, vitest_1.expect)(node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'wrangler.jsonc'))).toBe(false); (0, ensure_wrangler_config_1.ensureWranglerConfig)(); (0, vitest_1.expect)(clackMocks.info).not.toHaveBeenCalledWith(vitest_1.expect.stringContaining('Found existing Wrangler config')); (0, vitest_1.expect)(node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'wrangler.jsonc'))).toBe(true); }); }); //# sourceMappingURL=ensure-wrangler-config.test.js.map