UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

46 lines 1.94 kB
"use strict"; // Note for future maintainers: // // This test file is mocking the `child_process` module. // As other tests are using the `child_process` module, we can not have them in the same file. Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const macos_system_helper_1 = require("../../src/apple/macos-system-helper"); const { execSyncMock } = vitest_1.vi.hoisted(() => { return { execSyncMock: vitest_1.vi.fn(), }; }); vitest_1.vi.mock('node:child_process', async () => { return { ...(await vitest_1.vi.importActual('node:child_process')), execSync: execSyncMock, }; }); (0, vitest_1.describe)('MacOSSystemHelpers', () => { (0, vitest_1.afterEach)(() => { vitest_1.vi.clearAllMocks(); vitest_1.vi.restoreAllMocks(); }); (0, vitest_1.describe)('readXcodeBuildSettings', () => { (0, vitest_1.describe)('project path', () => { (0, vitest_1.it)('should escape quotes', () => { // -- Arrange -- const projectPath = 'some path" && echo "Hello World"'; // Use spyOn instead of vi.mock execSyncMock.mockImplementationOnce(() => { return ' ACTION = build'; }); // -- Act -- const buildSettings = macos_system_helper_1.MacOSSystemHelpers.readXcodeBuildSettings(projectPath); // -- Assert -- (0, vitest_1.expect)(buildSettings).toEqual({ ACTION: 'build', }); // We expect the project path to be escaped (0, vitest_1.expect)(execSyncMock).toHaveBeenCalledWith(`"xcodebuild" "-project" "some path\\" && echo \\"Hello World\\"" "-showBuildSettings"`, { encoding: 'utf8' }); }); }); }); }); //# sourceMappingURL=macos-system-helper-mocked.test.js.map