1
1
/* eslint-env jest */
2
- import * as cp from 'node:child_process' ;
3
2
// eslint-disable-next-line import/no-extraneous-dependencies
4
3
import * as which from 'which' ;
5
- import { attach } from '../attach' ;
6
- import { NeovimClient } from './client' ;
4
+ import * as testUtil from '../testUtil' ;
7
5
8
6
function wait ( ms : number ) : Promise < void > {
9
7
return new Promise ( resolve => {
25
23
}
26
24
27
25
describe ( 'Buffer API' , ( ) => {
28
- let proc ;
29
- let nvim : NeovimClient ;
26
+ let nvim : ReturnType < typeof testUtil . getNvim > ;
30
27
31
28
// utility to allow each test to be run in its
32
29
// own buffer
@@ -48,18 +45,12 @@ describe('Buffer API', () => {
48
45
}
49
46
50
47
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 ( ) ;
56
50
} ) ;
57
51
58
52
afterAll ( ( ) => {
59
- nvim . quit ( ) ;
60
- if ( proc && proc . connected ) {
61
- proc . disconnect ( ) ;
62
- }
53
+ testUtil . stopNvim2 ( ) ;
63
54
} ) ;
64
55
65
56
it (
@@ -406,22 +397,15 @@ describe('Buffer API', () => {
406
397
} ) ;
407
398
408
399
describe ( 'Buffer event updates' , ( ) => {
409
- let proc ;
410
- let nvim ;
400
+ let nvim : ReturnType < typeof testUtil . getNvim > ;
411
401
412
402
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 ( ) ;
418
405
} ) ;
419
406
420
407
afterAll ( ( ) => {
421
- nvim . quit ( ) ;
422
- if ( proc && proc . connected ) {
423
- proc . disconnect ( ) ;
424
- }
408
+ testUtil . startNvim2 ( ) ;
425
409
} ) ;
426
410
427
411
beforeEach ( async ( ) => {
0 commit comments