UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

105 lines (104 loc) 4.34 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const example_component_1 = require("../../src/angular/example-component"); const clackUtils = __importStar(require("../../src/utils/clack")); const fsMocks = vitest_1.vi.hoisted(() => ({ existsSyncMock: vitest_1.vi.fn(() => true), writeFileSyncMock: vitest_1.vi.fn(), mkdirSyncMock: vitest_1.vi.fn(), })); vitest_1.vi.mock('fs', () => ({ existsSync: fsMocks.existsSyncMock, writeFileSync: fsMocks.writeFileSyncMock, mkdirSync: fsMocks.mkdirSyncMock, })); vitest_1.vi.mock('@clack/prompts', () => ({ log: { info: vitest_1.vi.fn(), success: vitest_1.vi.fn(), warn: vitest_1.vi.fn(), error: vitest_1.vi.fn(), step: vitest_1.vi.fn(), }, outro: vitest_1.vi.fn(), text: vitest_1.vi.fn(), confirm: vitest_1.vi.fn(), cancel: vitest_1.vi.fn(), // passthrough for abortIfCancelled isCancel: vitest_1.vi.fn().mockReturnValue(false), spinner: vitest_1.vi .fn() .mockImplementation(() => ({ start: vitest_1.vi.fn(), stop: vitest_1.vi.fn() })), select: vitest_1.vi.fn(), })); (0, vitest_1.describe)('createExampleComponent', () => { const showCopyPasteSnippetSpy = vitest_1.vi.spyOn(clackUtils, 'showCopyPasteInstructions'); (0, vitest_1.beforeEach)(() => { vitest_1.vi.clearAllMocks(); }); (0, vitest_1.it)('creates an example component file', async () => { const options = { url: 'https://sentry.io', orgSlug: 'myOrg', projectId: '123456789', }; // Mock the abortIfCancelled function to return the appRootPath vitest_1.vi.spyOn(clackUtils, 'abortIfCancelled').mockResolvedValue('src/app'); // Mock the getSentryExampleComponentCode function const exampleComponentCode = (0, example_component_1.getSentryExampleComponentCode)(options); // Call the function to create the example component await (0, example_component_1.createExampleComponent)(options); (0, vitest_1.expect)(fsMocks.writeFileSyncMock).toHaveBeenCalledWith('./src/app/sentry-example.component.ts', exampleComponentCode); (0, vitest_1.expect)(showCopyPasteSnippetSpy).toHaveBeenCalledWith({ codeSnippet: `import { SentryExample } from './sentry-example.component' @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet, SentryExample], template: \` <div class="app"> <h1>Your Application</h1> <app-sentry-example></app-sentry-example> </div> \`, }) `, instructions: 'Add the example component one of your pages or components (for example, in app.component.ts).', }); }); }); (0, vitest_1.describe)('getSentryExampleComponentCode', () => { (0, vitest_1.it)('includes the correct issue stream URL', () => { const exampleComponentCode = (0, example_component_1.getSentryExampleComponentCode)({ orgSlug: 'myOrg', projectId: '123456789', url: 'https://sentry.io', }); (0, vitest_1.expect)(exampleComponentCode).toContain('https://myorg.sentry.io/issues/?project=123456789'); }); }); //# sourceMappingURL=example-component.test.js.map