UNPKG

@interaktiv/dia-scripts

Version:

CLI toolbox with common scripts for most sort of projects at DIA

69 lines (63 loc) 2.32 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _serializers = require("../__tests__/helpers/serializers"); expect.addSnapshotSerializer(_serializers.unquoteSerializer); expect.addSnapshotSerializer(_serializers.winPathSerializer); expect.addSnapshotSerializer(_serializers.relativePathSerializer); describe('run test', () => { describe('in a Salesforce DX project', () => { const originalExit = process.exit; let crossSpawnSyncMock; beforeEach(() => { ({ sync: crossSpawnSyncMock } = require('cross-spawn')); jest.mock('../../utils.js', () => (0, _extends2.default)({}, jest.requireActual('../../utils'), { resolveBin: jest.fn((modName, { executable = modName } = {}) => executable), ifSfdxProject: jest.fn(t => t) })); process.exit = jest.fn(); }); afterEach(() => { process.exit = originalExit; jest.resetModules(); }); test('does run Apex and Aura linting too', () => { require('.'); expect(crossSpawnSyncMock).toHaveBeenCalledTimes(1); const [firstCall] = crossSpawnSyncMock.mock.calls; const [script, calledArgs] = firstCall; expect([script, ...calledArgs].join(' ')).toMatchSnapshot(); }); }); describe('in any other project', () => { const originalExit = process.exit; let crossSpawnSyncMock; beforeEach(() => { ({ sync: crossSpawnSyncMock } = require('cross-spawn')); jest.mock('../../utils.js', () => (0, _extends2.default)({}, jest.requireActual('../../utils'), { resolveBin: jest.fn((modName, { executable = modName } = {}) => executable), ifSfdxProject: jest.fn((t, f) => f) })); process.exit = jest.fn(); }); afterEach(() => { process.exit = originalExit; jest.resetModules(); }); test('does not run Apex and Aura linting', () => { require('.'); expect(crossSpawnSyncMock).toHaveBeenCalledTimes(1); const [firstCall] = crossSpawnSyncMock.mock.calls; const [script, calledArgs] = firstCall; expect([script, ...calledArgs].join(' ')).toMatchSnapshot(); }); }); });