Skip to content

Commit 4cc7767

Browse files
committed
Remove some explicit setup/teardown code in tests
1 parent 1e6504e commit 4cc7767

File tree

11 files changed

+9
-39
lines changed

11 files changed

+9
-39
lines changed

test/actions/insertLine.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as assert from 'assert';
22
import * as vscode from 'vscode';
33
import { getAndUpdateModeHandler } from '../../extension';
44
import { ModeHandler } from '../../src/mode/modeHandler';
5-
import { cleanUpWorkspace, setupWorkspace } from '../testUtils';
5+
import { setupWorkspace } from '../testUtils';
66

77
suite('insertLineBefore', () => {
88
let modeHandler: ModeHandler;
@@ -18,8 +18,6 @@ suite('insertLineBefore', () => {
1818
modeHandler = (await getAndUpdateModeHandler())!;
1919
});
2020

21-
suiteTeardown(cleanUpWorkspace);
22-
2321
test('tabs are added to match previous line even if line above does not match', async () => {
2422
// Setup the test
2523
await modeHandler.handleMultipleKeyEvents(['<Esc>', 'g', 'g', 'd', 'G']);

test/cmd_line/breakpoints.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getAndUpdateModeHandler } from '../../extension';
55
import { ExCommandLine } from '../../src/cmd_line/commandLine';
66
import { ModeHandler } from '../../src/mode/modeHandler';
77
import { exCommandParser } from '../../src/vimscript/exCommandParser';
8-
import { cleanUpWorkspace, setupWorkspace } from '../testUtils';
8+
import { setupWorkspace } from '../testUtils';
99

1010
function clearBreakpoints() {
1111
vscode.debug.removeBreakpoints(vscode.debug.breakpoints);
@@ -18,7 +18,6 @@ suite('Breakpoints command', () => {
1818
await setupWorkspace();
1919
modeHandler = (await getAndUpdateModeHandler())!;
2020
});
21-
suiteTeardown(cleanUpWorkspace);
2221

2322
test('`:breaka` adds breakpoint', async () => {
2423
clearBreakpoints();

test/cmd_line/change.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { Mode } from '../../src/mode/mode';
22
import { newTest } from '../testSimplifier';
3-
import { setupWorkspace } from '../testUtils';
43

54
suite('cmd_line change', () => {
6-
suiteSetup(setupWorkspace);
7-
85
newTest({
96
title: 'c deletes current line and enters insert mode',
107
start: ['first line', 'sec|ond line', 'third line'],

test/cmd_line/smile.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ suite('Smile command', () => {
1515
modeHandler = (await getAndUpdateModeHandler())!;
1616
});
1717

18-
test(':smile creates new tab', async () => {
18+
test(':smile creates new tab containing smile', async () => {
1919
await new ExCommandLine('smile', modeHandler.vimState.currentMode).run(modeHandler.vimState);
2020
await waitForTabChange();
2121

@@ -24,13 +24,7 @@ suite('Smile command', () => {
2424
1,
2525
':smile did not create a new untitled file',
2626
);
27-
});
28-
29-
test(':smile editor contains smile text', async () => {
30-
await new ExCommandLine('smile', modeHandler.vimState.currentMode).run(modeHandler.vimState);
31-
await waitForTabChange();
32-
const textArray = SmileCommand.smileText.split('\n');
3327

34-
assertEqualLines(textArray);
28+
assertEqualLines(SmileCommand.smileText.split('\n'));
3529
});
3630
});

test/cmd_line/substitute.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Configuration } from '../testConfiguration';
22
import { newTest } from '../testSimplifier';
3-
import { cleanUpWorkspace, reloadConfiguration, setupWorkspace } from './../testUtils';
3+
import { reloadConfiguration, setupWorkspace } from './../testUtils';
44

55
function sub(
66
pattern: string,
@@ -15,7 +15,6 @@ function sub(
1515

1616
suite('Basic substitute', () => {
1717
setup(setupWorkspace);
18-
suiteTeardown(cleanUpWorkspace);
1918

2019
newTest({
2120
title: 'Replace single word once',

test/cmd_line/writequit.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getAndUpdateModeHandler } from '../../extension';
55
import { ExCommandLine } from '../../src/cmd_line/commandLine';
66
import { ModeHandler } from '../../src/mode/modeHandler';
77
import { newTest } from '../testSimplifier';
8-
import { cleanUpWorkspace, setupWorkspace, waitForEditorsToClose } from './../testUtils';
8+
import { setupWorkspace, waitForEditorsToClose } from './../testUtils';
99

1010
suite('Basic write-quit', () => {
1111
let modeHandler: ModeHandler;
@@ -15,8 +15,6 @@ suite('Basic write-quit', () => {
1515
modeHandler = (await getAndUpdateModeHandler())!;
1616
});
1717

18-
suiteTeardown(cleanUpWorkspace);
19-
2018
test('Run write and quit', async () => {
2119
await modeHandler.handleMultipleKeyEvents(['i', 'a', 'b', 'a', '<Esc>']);
2220

test/completion/lineCompletion.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getAndUpdateModeHandler } from '../../extension';
55
import { getCompletionsForCurrentLine } from '../../src/completion/lineCompletionProvider';
66
import { ModeHandler } from '../../src/mode/modeHandler';
77
import { VimState } from '../../src/state/vimState';
8-
import { cleanUpWorkspace, setupWorkspace } from '../testUtils';
8+
import { setupWorkspace } from '../testUtils';
99

1010
suite('Provide line completions', () => {
1111
let modeHandler: ModeHandler;
@@ -16,7 +16,6 @@ suite('Provide line completions', () => {
1616
modeHandler = (await getAndUpdateModeHandler())!;
1717
vimState = modeHandler.vimState;
1818
});
19-
suiteTeardown(cleanUpWorkspace);
2019

2120
const setupTestWithLines = async (lines: string[]) => {
2221
vimState.cursorStopPosition = new Position(0, 0);

test/configuration/langmap.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Mode } from '../../src/mode/mode';
22
import { newTest } from '../testSimplifier';
3-
import { cleanUpWorkspace, setupWorkspace } from '../testUtils';
3+
import { setupWorkspace } from '../testUtils';
44

55
const dvorakLangmap =
66
'\'q,\\,w,.e,pr,yt,fy,gu,ci,ro,lp,/[,=],aa,os,ed,uf,ig,dh,hj,tk,nl,s\\;,-\',\\;z,qx,jc,kv,xb,bn,mm,w\\,,v.,z/,[-,]=,"Q,<W,>E,PR,YT,FY,GU,CI,RO,LP,?{,+},AA,OS,ED,UF,IG,DH,HJ,TK,NL,S:,_",:Z,QX,JC,KV,XB,BN,MM,W<,V>,Z?';
@@ -13,14 +13,6 @@ suite('Langmap', () => {
1313
},
1414
});
1515
});
16-
suiteTeardown(async () => {
17-
await setupWorkspace({
18-
config: {
19-
langmap: '',
20-
},
21-
});
22-
await cleanUpWorkspace();
23-
});
2416

2517
newTest({
2618
title: 'Test example binding (ee → dd)',

test/jumpTracker.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import { Position } from 'vscode';
55
import { JumpTracker } from '../src/jumps/jumpTracker';
66
import { Jump } from './../src/jumps/jump';
77
import { ITestObject, newTest, newTestSkip } from './testSimplifier';
8-
import { setupWorkspace } from './testUtils';
98

109
suite('Record and navigate jumps', () => {
11-
suiteSetup(setupWorkspace);
12-
1310
const newJumpTest = (options: ITestObject | Omit<ITestObject, 'title'>) => {
1411
return newTest({
1512
title: `Can track jumps for keys: ${options.keysPressed.replace(/\n/g, '<CR>')}`,

test/marks.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Mode } from '../src/mode/mode';
55
import { ModeHandler } from '../src/mode/modeHandler';
66
import { ModeHandlerMap } from '../src/mode/modeHandlerMap';
77
import { newTest, newTestSkip } from './testSimplifier';
8-
import { cleanUpWorkspace, setupWorkspace } from './testUtils';
8+
import { setupWorkspace } from './testUtils';
99

1010
suite('Marks', () => {
1111
let modeHandler: ModeHandler;
@@ -15,8 +15,6 @@ suite('Marks', () => {
1515
modeHandler = (await getAndUpdateModeHandler())!;
1616
});
1717

18-
suiteTeardown(cleanUpWorkspace);
19-
2018
const jumpToNewFile = async () => {
2119
await setupWorkspace({
2220
config: {

0 commit comments

Comments
 (0)