Skip to content

Commit c9a3dd0

Browse files
author
Billy Vong
committed
Add better control for killing nvim process
1 parent 6ae98c7 commit c9a3dd0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/attach.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ describe('Nvim Promise API', () => {
3939
done();
4040
});
4141

42+
afterAll(() => {
43+
if (proc) {
44+
proc.kill();
45+
}
46+
});
47+
4248
beforeEach(() => {
4349
requests = [];
4450
notifications = [];
@@ -96,8 +102,15 @@ describe('Nvim Promise API', () => {
96102
});
97103

98104
it('emits "disconnect" after quit', done => {
99-
nvim.on('disconnect', done);
105+
const disconnectMock = jest.fn();
106+
nvim.on('disconnect', disconnectMock);
100107
nvim.quit();
108+
109+
proc.on('close', () => {
110+
expect(disconnectMock.mock.calls.length).toBe(1);
111+
done();
112+
});
113+
101114
// Event doesn't actually emit when we quit nvim, but when the child process is killed
102115
proc.kill();
103116
});

0 commit comments

Comments
 (0)