@sentry/wizard
Version:
Sentry wizard helping you to configure your project
48 lines • 1.98 kB
JavaScript
;
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 node_fs_1 = __importDefault(require("node:fs"));
const create_wrangler_config_1 = require("../../src/cloudflare/wrangler/create-wrangler-config");
const node_path_1 = __importDefault(require("node:path"));
const { clackMocks } = vitest_1.vi.hoisted(() => {
const info = vitest_1.vi.fn();
const success = vitest_1.vi.fn();
return {
clackMocks: {
info,
success,
},
};
});
vitest_1.vi.mock('@clack/prompts', () => {
return {
__esModule: true,
default: {
log: {
info: clackMocks.info,
success: clackMocks.success,
},
},
};
});
(0, vitest_1.describe)('createWranglerConfig', () => {
(0, vitest_1.beforeEach)(() => {
vitest_1.vi.clearAllMocks();
});
(0, vitest_1.afterEach)(() => {
vitest_1.vi.restoreAllMocks();
});
(0, vitest_1.it)('creates a wrangler.jsonc file with basic configuration', () => {
const writeFileSyncMock = vitest_1.vi.spyOn(node_fs_1.default, 'writeFileSync');
const joinMock = vitest_1.vi.spyOn(node_path_1.default, 'join');
joinMock.mockReturnValue('/project/wrangler.jsonc');
writeFileSyncMock.mockImplementation(() => undefined);
(0, create_wrangler_config_1.createWranglerConfig)();
(0, vitest_1.expect)(writeFileSyncMock).toHaveBeenCalledWith('/project/wrangler.jsonc', vitest_1.expect.stringContaining('"name": "my-worker"'), 'utf-8');
(0, vitest_1.expect)(writeFileSyncMock).toHaveBeenCalledWith('/project/wrangler.jsonc', vitest_1.expect.stringContaining('"main": "src/index.ts"'), 'utf-8');
});
});
//# sourceMappingURL=create-wrangler-config.test.js.map