Skip to content

Commit d89c152

Browse files
committed
refactor(tests): Rename zeroBasedLine to naturalEditorLine
1 parent 09b0b58 commit d89c152

File tree

11 files changed

+72
-63
lines changed

11 files changed

+72
-63
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { openDocument } from './openDocument';
22
import { NaturalEditorPosition } from './NaturalEditorPosition';
3-
import { zeroBasedLine } from './zeroBasedLine';
3+
import { naturalEditorLine } from './naturalEditorLine';
44
import { expectActiveTextEditorWithFile } from './expectActiveTextEditorWithFile';
55
import { documentLinesChanged } from './documentLinesChanged';
66
export {
77
openDocument,
88
NaturalEditorPosition,
9-
zeroBasedLine,
9+
naturalEditorLine,
1010
expectActiveTextEditorWithFile,
1111
documentLinesChanged,
1212
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const naturalEditorLine = ({
2+
visualLine,
3+
}: {
4+
visualLine: number;
5+
}): number => {
6+
return visualLine - 1;
7+
};

src/test/integration/helpers/zeroBasedLine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const zeroBasedLine = ({
1+
export const naturalEditorLine = ({
22
visualLine,
33
}: {
44
visualLine: number;

src/test/integration/js/log-feature/class/classFunction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mocha, { it, describe } from 'mocha';
33
import { expect } from 'chai';
44
import {
55
openDocument,
6-
zeroBasedLine,
6+
naturalEditorLine,
77
NaturalEditorPosition,
88
expectActiveTextEditorWithFile,
99
documentLinesChanged,
@@ -28,7 +28,7 @@ export default (): void => {
2828
it('Should insert a log message related to parameter of a function inside a class', async () => {
2929
const { activeTextEditor } = vscode.window;
3030
expectActiveTextEditorWithFile(activeTextEditor, 'classFunction.js');
31-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 3 });
31+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 3 });
3232
if (activeTextEditor) {
3333
activeTextEditor.selections = [
3434
new vscode.Selection(

src/test/integration/js/log-feature/class/classNestedFunctions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect } from 'chai';
44
import {
55
openDocument,
66
NaturalEditorPosition,
7-
zeroBasedLine,
7+
naturalEditorLine,
88
expectActiveTextEditorWithFile,
99
documentLinesChanged,
1010
} from '../../../helpers';
@@ -31,7 +31,7 @@ export default (): void => {
3131
activeTextEditor,
3232
'classNestedFunctions.js',
3333
);
34-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 4 });
34+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 4 });
3535
if (activeTextEditor) {
3636
activeTextEditor.selections = [
3737
new vscode.Selection(

src/test/integration/js/log-feature/function/anonymousFunctions.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mocha, { describe, it } from 'mocha';
33
import { expect } from 'chai';
44
import {
55
openDocument,
6-
zeroBasedLine,
6+
naturalEditorLine,
77
NaturalEditorPosition,
88
expectActiveTextEditorWithFile,
99
documentLinesChanged,
@@ -50,17 +50,17 @@ export default (): void => {
5050
const textDocument = activeTextEditor.document;
5151
expect(
5252
/\{\s*$/.test(
53-
textDocument.lineAt(zeroBasedLine({ visualLine: 3 })).text,
53+
textDocument.lineAt(naturalEditorLine({ visualLine: 3 })).text,
5454
),
5555
).to.equal(true);
5656
expect(
5757
/console\.log\(.*/.test(
58-
textDocument.lineAt(zeroBasedLine({ visualLine: 4 })).text,
58+
textDocument.lineAt(naturalEditorLine({ visualLine: 4 })).text,
5959
),
6060
).to.equal(true);
6161
expect(
6262
/return /.test(
63-
textDocument.lineAt(zeroBasedLine({ visualLine: 5 })).text,
63+
textDocument.lineAt(naturalEditorLine({ visualLine: 5 })).text,
6464
),
6565
).to.equal(true);
6666
}
@@ -88,22 +88,22 @@ export default (): void => {
8888
const textDocument = activeTextEditor.document;
8989
expect(
9090
/\{\s*$/.test(
91-
textDocument.lineAt(zeroBasedLine({ visualLine: 5 })).text,
91+
textDocument.lineAt(naturalEditorLine({ visualLine: 5 })).text,
9292
),
9393
).to.equal(true);
9494
expect(
9595
/console\.log\(.*/.test(
96-
textDocument.lineAt(zeroBasedLine({ visualLine: 6 })).text,
96+
textDocument.lineAt(naturalEditorLine({ visualLine: 6 })).text,
9797
),
9898
).to.equal(true);
9999
expect(
100100
/return member.include\('S'\)/.test(
101-
textDocument.lineAt(zeroBasedLine({ visualLine: 7 })).text,
101+
textDocument.lineAt(naturalEditorLine({ visualLine: 7 })).text,
102102
),
103103
).to.equal(true);
104104
expect(
105105
/}\)/.test(
106-
textDocument.lineAt(zeroBasedLine({ visualLine: 8 })).text,
106+
textDocument.lineAt(naturalEditorLine({ visualLine: 8 })).text,
107107
),
108108
).to.equal(true);
109109
}
@@ -131,22 +131,22 @@ export default (): void => {
131131
const textDocument = activeTextEditor.document;
132132
expect(
133133
/\{\s*$/.test(
134-
textDocument.lineAt(zeroBasedLine({ visualLine: 8 })).text,
134+
textDocument.lineAt(naturalEditorLine({ visualLine: 8 })).text,
135135
),
136136
).to.equal(true);
137137
expect(
138138
/console\.log\(.*/.test(
139-
textDocument.lineAt(zeroBasedLine({ visualLine: 9 })).text,
139+
textDocument.lineAt(naturalEditorLine({ visualLine: 9 })).text,
140140
),
141141
).to.equal(true);
142142
expect(
143143
/return item.index !== original.index/.test(
144-
textDocument.lineAt(zeroBasedLine({ visualLine: 10 })).text,
144+
textDocument.lineAt(naturalEditorLine({ visualLine: 10 })).text,
145145
),
146146
).to.equal(true);
147147
expect(
148148
/}\)/.test(
149-
textDocument.lineAt(zeroBasedLine({ visualLine: 11 })).text,
149+
textDocument.lineAt(naturalEditorLine({ visualLine: 11 })).text,
150150
),
151151
).to.equal(true);
152152
}
@@ -177,22 +177,22 @@ export default (): void => {
177177
const textDocument = activeTextEditor.document;
178178
expect(
179179
/\{\s*$/.test(
180-
textDocument.lineAt(zeroBasedLine({ visualLine: 12 })).text,
180+
textDocument.lineAt(naturalEditorLine({ visualLine: 12 })).text,
181181
),
182182
).to.equal(true);
183183
expect(
184184
/console\.log\(.*/.test(
185-
textDocument.lineAt(zeroBasedLine({ visualLine: 13 })).text,
185+
textDocument.lineAt(naturalEditorLine({ visualLine: 13 })).text,
186186
),
187187
).to.equal(true);
188188
expect(
189189
/return checkAccountingPeriodDivide\(budget._id, accountingPeriodId\)/.test(
190-
textDocument.lineAt(zeroBasedLine({ visualLine: 14 })).text,
190+
textDocument.lineAt(naturalEditorLine({ visualLine: 14 })).text,
191191
),
192192
).to.equal(true);
193193
expect(
194194
/}\)/.test(
195-
textDocument.lineAt(zeroBasedLine({ visualLine: 15 })).text,
195+
textDocument.lineAt(naturalEditorLine({ visualLine: 15 })).text,
196196
),
197197
).to.equal(true);
198198
}
@@ -220,22 +220,22 @@ export default (): void => {
220220
const textDocument = activeTextEditor.document;
221221
expect(
222222
/\{\s*$/.test(
223-
textDocument.lineAt(zeroBasedLine({ visualLine: 19 })).text,
223+
textDocument.lineAt(naturalEditorLine({ visualLine: 19 })).text,
224224
),
225225
).to.equal(true);
226226
expect(
227227
/console\.log\(.*/.test(
228-
textDocument.lineAt(zeroBasedLine({ visualLine: 20 })).text,
228+
textDocument.lineAt(naturalEditorLine({ visualLine: 20 })).text,
229229
),
230230
).to.equal(true);
231231
expect(
232232
/return checkAccountingPeriodDivide\(budget._id\)/.test(
233-
textDocument.lineAt(zeroBasedLine({ visualLine: 21 })).text,
233+
textDocument.lineAt(naturalEditorLine({ visualLine: 21 })).text,
234234
),
235235
).to.equal(true);
236236
expect(
237237
/}\)/.test(
238-
textDocument.lineAt(zeroBasedLine({ visualLine: 23 })).text,
238+
textDocument.lineAt(naturalEditorLine({ visualLine: 23 })).text,
239239
),
240240
).to.equal(true);
241241
}
@@ -263,22 +263,22 @@ export default (): void => {
263263
const textDocument = activeTextEditor.document;
264264
expect(
265265
/\{\s*$/.test(
266-
textDocument.lineAt(zeroBasedLine({ visualLine: 27 })).text,
266+
textDocument.lineAt(naturalEditorLine({ visualLine: 27 })).text,
267267
),
268268
).to.equal(true);
269269
expect(
270270
/console\.log\(.*/.test(
271-
textDocument.lineAt(zeroBasedLine({ visualLine: 28 })).text,
271+
textDocument.lineAt(naturalEditorLine({ visualLine: 28 })).text,
272272
),
273273
).to.equal(true);
274274
expect(
275275
/return checkAccountingPeriodDivide\(budget._id, accountingPeriodId\)/.test(
276-
textDocument.lineAt(zeroBasedLine({ visualLine: 29 })).text,
276+
textDocument.lineAt(naturalEditorLine({ visualLine: 29 })).text,
277277
),
278278
).to.equal(true);
279279
expect(
280280
/}\)/.test(
281-
textDocument.lineAt(zeroBasedLine({ visualLine: 30 })).text,
281+
textDocument.lineAt(naturalEditorLine({ visualLine: 30 })).text,
282282
),
283283
).to.equal(true);
284284
}
@@ -306,22 +306,22 @@ export default (): void => {
306306
const textDocument = activeTextEditor.document;
307307
expect(
308308
/\{\s*$/.test(
309-
textDocument.lineAt(zeroBasedLine({ visualLine: 35 })).text,
309+
textDocument.lineAt(naturalEditorLine({ visualLine: 35 })).text,
310310
),
311311
).to.equal(true);
312312
expect(
313313
/console\.log\(.*/.test(
314-
textDocument.lineAt(zeroBasedLine({ visualLine: 36 })).text,
314+
textDocument.lineAt(naturalEditorLine({ visualLine: 36 })).text,
315315
),
316316
).to.equal(true);
317317
expect(
318318
/return checkAccountingPeriodDivide\(budget._id\)/.test(
319-
textDocument.lineAt(zeroBasedLine({ visualLine: 37 })).text,
319+
textDocument.lineAt(naturalEditorLine({ visualLine: 37 })).text,
320320
),
321321
).to.equal(true);
322322
expect(
323323
/}\)/.test(
324-
textDocument.lineAt(zeroBasedLine({ visualLine: 39 })).text,
324+
textDocument.lineAt(naturalEditorLine({ visualLine: 39 })).text,
325325
),
326326
).to.equal(true);
327327
}

src/test/integration/js/log-feature/function/emptyFunc.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect } from 'chai';
44
import {
55
openDocument,
66
NaturalEditorPosition,
7-
zeroBasedLine,
7+
naturalEditorLine,
88
expectActiveTextEditorWithFile,
99
documentLinesChanged,
1010
} from '../../../helpers';
@@ -41,17 +41,17 @@ export default (): void => {
4141
);
4242
await Promise.all(
4343
documentLinesChanged(activeTextEditor.document, [
44-
zeroBasedLine({ visualLine: 7 }),
44+
naturalEditorLine({ visualLine: 7 }),
4545
]),
4646
);
4747
const textDocument = activeTextEditor.document;
4848
expect(
4949
/\{\s*$/.test(
50-
textDocument.lineAt(zeroBasedLine({ visualLine: 7 })).text,
50+
textDocument.lineAt(naturalEditorLine({ visualLine: 7 })).text,
5151
),
5252
).to.equal(true);
5353
const logMessage = textDocument.lineAt(
54-
zeroBasedLine({ visualLine: 8 }),
54+
naturalEditorLine({ visualLine: 8 }),
5555
).text;
5656
expect(/console\.log\(.*/.test(logMessage)).to.equal(true);
5757
}
@@ -72,17 +72,17 @@ export default (): void => {
7272
);
7373
await Promise.all(
7474
documentLinesChanged(activeTextEditor.document, [
75-
zeroBasedLine({ visualLine: 15 }),
75+
naturalEditorLine({ visualLine: 15 }),
7676
]),
7777
);
7878
const textDocument = activeTextEditor.document;
7979
expect(
8080
/\{\s*$/.test(
81-
textDocument.lineAt(zeroBasedLine({ visualLine: 14 })).text,
81+
textDocument.lineAt(naturalEditorLine({ visualLine: 14 })).text,
8282
),
8383
).to.equal(true);
8484
const logMessage = textDocument.lineAt(
85-
zeroBasedLine({ visualLine: 15 }),
85+
naturalEditorLine({ visualLine: 15 }),
8686
).text;
8787
expect(/console\.log\(.*/.test(logMessage)).to.equal(true);
8888
}

src/test/integration/js/log-feature/function/functionAssignedToVariable.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mocha, { describe, it } from 'mocha';
33
import { expect } from 'chai';
44
import {
55
openDocument,
6-
zeroBasedLine,
6+
naturalEditorLine,
77
NaturalEditorPosition,
88
expectActiveTextEditorWithFile,
99
documentLinesChanged,
@@ -31,7 +31,7 @@ export default (): void => {
3131
activeTextEditor,
3232
'functionAssignedToVariable.ts',
3333
);
34-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 6 });
34+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 6 });
3535
if (activeTextEditor) {
3636
const textDocument = activeTextEditor.document;
3737
activeTextEditor.selection = new vscode.Selection(
@@ -60,7 +60,7 @@ export default (): void => {
6060
activeTextEditor,
6161
'functionAssignedToVariable.ts',
6262
);
63-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 10 });
63+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 10 });
6464
if (activeTextEditor) {
6565
const textDocument = activeTextEditor.document;
6666
activeTextEditor.selection = new vscode.Selection(
@@ -89,7 +89,7 @@ export default (): void => {
8989
activeTextEditor,
9090
'functionAssignedToVariable.ts',
9191
);
92-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 17 });
92+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 17 });
9393
if (activeTextEditor) {
9494
const textDocument = activeTextEditor.document;
9595
activeTextEditor.selection = new vscode.Selection(
@@ -118,7 +118,7 @@ export default (): void => {
118118
activeTextEditor,
119119
'functionAssignedToVariable.ts',
120120
);
121-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 19 });
121+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 19 });
122122
if (activeTextEditor) {
123123
const textDocument = activeTextEditor.document;
124124
activeTextEditor.selection = new vscode.Selection(

src/test/integration/js/log-feature/function/functionWithDecorators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect } from 'chai';
44
import {
55
openDocument,
66
NaturalEditorPosition,
7-
zeroBasedLine,
7+
naturalEditorLine,
88
expectActiveTextEditorWithFile,
99
documentLinesChanged,
1010
} from '../../../helpers';
@@ -31,7 +31,7 @@ export default (): void => {
3131
activeTextEditor,
3232
'functionWithDecorators.ts',
3333
);
34-
const expectedLogMessageLine = zeroBasedLine({ visualLine: 14 });
34+
const expectedLogMessageLine = naturalEditorLine({ visualLine: 14 });
3535
if (activeTextEditor) {
3636
activeTextEditor.selections = [
3737
new vscode.Selection(

0 commit comments

Comments
 (0)