Skip to content

Commit 555acfb

Browse files
committed
refactor: cleanup
- annotate types. - rename helpers/ => utils/ - there are already other "utils/" directories - helpers is a stupid name
1 parent c000412 commit 555acfb

File tree

13 files changed

+102
-101
lines changed

13 files changed

+102
-101
lines changed

packages/integration-tests/__tests__/integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import * as fs from 'fs';
44
import * as path from 'path';
55
import * as http from 'http';
66

7-
import { attach } from 'neovim';
7+
import { NeovimClient, attach } from 'neovim';
88

99
describe('Node host', () => {
1010
const testdir = process.cwd();
11-
let proc;
11+
let proc: cp.ChildProcessWithoutNullStreams;
1212
let args;
13-
let nvim;
13+
let nvim: NeovimClient;
1414

1515
beforeAll(async () => {
1616
const plugdir = path.resolve(__dirname);

packages/neovim/src/api/Buffer.test.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-env jest */
2-
import * as cp from 'node:child_process';
32
// eslint-disable-next-line import/no-extraneous-dependencies
43
import * as which from 'which';
5-
import { attach } from '../attach';
6-
import { NeovimClient } from './client';
4+
import * as testUtil from '../testUtil';
75

86
function wait(ms: number): Promise<void> {
97
return new Promise(resolve => {
@@ -25,8 +23,7 @@ try {
2523
}
2624

2725
describe('Buffer API', () => {
28-
let proc;
29-
let nvim: NeovimClient;
26+
let nvim: ReturnType<typeof testUtil.getNvim>;
3027

3128
// utility to allow each test to be run in its
3229
// own buffer
@@ -48,18 +45,12 @@ describe('Buffer API', () => {
4845
}
4946

5047
beforeAll(async () => {
51-
proc = cp.spawn('nvim', ['-u', 'NONE', '--embed', '-n', '--noplugin'], {
52-
cwd: __dirname,
53-
});
54-
55-
nvim = attach({ proc });
48+
testUtil.startNvim2();
49+
nvim = testUtil.getNvim();
5650
});
5751

5852
afterAll(() => {
59-
nvim.quit();
60-
if (proc && proc.connected) {
61-
proc.disconnect();
62-
}
53+
testUtil.stopNvim2();
6354
});
6455

6556
it(
@@ -406,22 +397,15 @@ describe('Buffer API', () => {
406397
});
407398

408399
describe('Buffer event updates', () => {
409-
let proc;
410-
let nvim;
400+
let nvim: ReturnType<typeof testUtil.getNvim>;
411401

412402
beforeAll(async () => {
413-
proc = cp.spawn('nvim', ['-u', 'NONE', '--embed', '-n', '--noplugin'], {
414-
cwd: __dirname,
415-
});
416-
417-
nvim = attach({ proc });
403+
testUtil.startNvim2();
404+
nvim = testUtil.getNvim();
418405
});
419406

420407
afterAll(() => {
421-
nvim.quit();
422-
if (proc && proc.connected) {
423-
proc.disconnect();
424-
}
408+
testUtil.startNvim2();
425409
});
426410

427411
beforeEach(async () => {

packages/neovim/src/api/Neovim.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* eslint-env jest */
2-
import * as cp from 'node:child_process';
32
import * as path from 'node:path';
43
// eslint-disable-next-line import/no-extraneous-dependencies
54
import * as which from 'which';
6-
import { attach } from '../attach';
75
import { Neovim } from './Neovim';
6+
import * as testUtil from '../testUtil';
87

98
try {
109
which.sync('nvim');
@@ -18,22 +17,15 @@ try {
1817
}
1918

2019
describe('Neovim API', () => {
21-
let proc;
22-
let nvim: Neovim;
20+
let nvim: ReturnType<typeof testUtil.getNvim>;
2321

2422
beforeAll(async () => {
25-
proc = cp.spawn('nvim', ['-u', 'NONE', '--embed', '-n', '--noplugin'], {
26-
cwd: __dirname,
27-
});
28-
29-
nvim = attach({ proc });
23+
testUtil.startNvim2();
24+
nvim = testUtil.getNvim();
3025
});
3126

3227
afterAll(() => {
33-
nvim.quit();
34-
if (proc && proc.connected) {
35-
proc.disconnect();
36-
}
28+
testUtil.stopNvim2();
3729
});
3830

3931
it('sets transport when initialized', () => {

packages/neovim/src/api/Neovim.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BaseApi } from './Base';
2-
import { createChainableApi } from './helpers/createChainableApi';
2+
import { createChainableApi } from './utils/createChainableApi';
33
import { Buffer, AsyncBuffer } from './Buffer';
44
import { Tabpage, AsyncTabpage } from './Tabpage';
55
import { Window, AsyncWindow } from './Window';

packages/neovim/src/api/Tabpage.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-env jest */
2-
import * as cp from 'node:child_process';
32
// eslint-disable-next-line import/no-extraneous-dependencies
43
import * as which from 'which';
5-
import { attach } from '../attach';
4+
import * as testUtil from '../testUtil';
65

76
try {
87
which.sync('nvim');
@@ -16,22 +15,15 @@ try {
1615
}
1716

1817
describe('Tabpage API', () => {
19-
let proc;
20-
let nvim;
18+
let nvim: ReturnType<typeof testUtil.getNvim>;
2119

2220
beforeAll(async () => {
23-
proc = cp.spawn('nvim', ['-u', 'NONE', '--embed', '-n', '--noplugin'], {
24-
cwd: __dirname,
25-
});
26-
27-
nvim = attach({ proc });
21+
testUtil.startNvim2();
22+
nvim = testUtil.getNvim();
2823
});
2924

3025
afterAll(() => {
31-
nvim.quit();
32-
if (proc && proc.connected) {
33-
proc.disconnect();
34-
}
26+
testUtil.stopNvim2();
3527
});
3628

3729
beforeEach(() => {});

packages/neovim/src/api/Tabpage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BaseApi } from './Base';
22
import { ExtType, Metadata, Promisify } from './types';
3-
import { createChainableApi } from './helpers/createChainableApi';
3+
import { createChainableApi } from './utils/createChainableApi';
44
import { Window, AsyncWindow } from './Window';
55

66
export class Tabpage extends BaseApi {

packages/neovim/src/api/Window.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-env jest */
2-
import * as cp from 'node:child_process';
32
// eslint-disable-next-line import/no-extraneous-dependencies
43
import * as which from 'which';
5-
import { attach } from '../attach';
6-
import { NeovimClient } from './client';
4+
import * as testUtil from '../testUtil';
75

86
try {
97
which.sync('nvim');
@@ -17,22 +15,15 @@ try {
1715
}
1816

1917
describe('Window API', () => {
20-
let proc;
21-
let nvim: NeovimClient;
18+
let nvim: ReturnType<typeof testUtil.getNvim>;
2219

2320
beforeAll(async () => {
24-
proc = cp.spawn('nvim', ['-u', 'NONE', '--embed', '-n', '--noplugin'], {
25-
cwd: __dirname,
26-
});
27-
28-
nvim = attach({ proc });
21+
testUtil.startNvim2();
22+
nvim = testUtil.getNvim();
2923
});
3024

3125
afterAll(() => {
32-
nvim.quit();
33-
if (proc && proc.connected) {
34-
proc.disconnect();
35-
}
26+
testUtil.stopNvim2();
3627
});
3728

3829
beforeEach(() => {});

packages/neovim/src/api/Window.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BaseApi } from './Base';
22
import { ExtType, Metadata, Promisify } from './types';
3-
import { createChainableApi } from './helpers/createChainableApi';
3+
import { createChainableApi } from './utils/createChainableApi';
44
import { Tabpage, AsyncTabpage } from './Tabpage';
55
import { Buffer, AsyncBuffer } from './Buffer';
66

0 commit comments

Comments
 (0)