-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Maaaartin/fix/allow_exec_with_muliple_params
Fix/allow exec with muliple params
- Loading branch information
Showing
12 changed files
with
249 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { Client } from '../../lib'; | ||
import { mockExec } from '../../mockery/execMock'; | ||
import { execFile } from 'child_process'; | ||
|
||
jest.mock('child_process', () => ({ | ||
execFile: jest.fn() | ||
})); | ||
|
||
const mockExecFile = execFile as unknown as jest.Mock; | ||
|
||
describe('Client connection tests', () => { | ||
it('Should try to start server on ECONNREFUSED error', async () => { | ||
const mocked = mockExec(null); | ||
mockExecFile.mockImplementation((_cmd, _args, callback_) => { | ||
callback_(null, '', ''); | ||
}); | ||
const client = new Client({ port: 1 }); | ||
await expect(() => client['connection']()).rejects.toThrow(); | ||
expect(mocked).toHaveBeenCalledTimes(1); | ||
expect(mockExecFile).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.