1import { execFileSync, execSync } from 'child_process'; 2 3import { getDirectoryOfProcessById, getPID } from '../getRunningProcess'; 4 5const asMock = (fn: any): jest.Mock => fn; 6 7describe(getPID, () => { 8 it(`should return the pid value for a running port`, () => { 9 asMock(execFileSync).mockImplementationOnce(() => '63828'); 10 const pid = getPID(63828); 11 expect(pid).toBe(63828); 12 }); 13}); 14 15describe(getDirectoryOfProcessById, () => { 16 it(`should return the directory of a pid`, () => { 17 asMock(execSync).mockImplementationOnce(() => 'cwd'); 18 const directory = getDirectoryOfProcessById(63828); 19 expect(directory).toBe('cwd'); 20 }); 21}); 22