Skip to content

Commit 7d8bf61

Browse files
committed
refactor: var to const and let
1 parent 5e18379 commit 7d8bf61

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/spec/Document-test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ define(function (require, exports, module) {
3232
describe("doMultipleEdits", function () {
3333
// Even though these are Document unit tests, we need to create an editor in order to
3434
// be able to test actual edit ops.
35-
var myEditor, myDocument, initialContentLines;
35+
let myEditor, myDocument, initialContentLines;
3636

3737
function makeDummyLines(num) {
38-
var content = [], i;
38+
let content = [], i;
3939
for (i = 0; i < num; i++) {
4040
content.push("this is line " + i);
4141
}
@@ -45,7 +45,7 @@ define(function (require, exports, module) {
4545
beforeEach(function () {
4646
// Each line from 0-9 is 14 chars long, each line from 10-19 is 15 chars long
4747
initialContentLines = makeDummyLines(20);
48-
var mocks = SpecRunnerUtils.createMockEditor(initialContentLines.join("\n"), "unknown");
48+
const mocks = SpecRunnerUtils.createMockEditor(initialContentLines.join("\n"), "unknown");
4949
myDocument = mocks.doc;
5050
myEditor = mocks.editor;
5151
});
@@ -59,7 +59,7 @@ define(function (require, exports, module) {
5959
});
6060

6161
function _verifySingleEdit() {
62-
var result = myDocument.doMultipleEdits([{edit: {text: "new content", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}},
62+
const result = myDocument.doMultipleEdits([{edit: {text: "new content", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}},
6363
selection: {start: {line: 2, ch: 4}, end: {line: 2, ch: 4}, reversed: true, isBeforeEdit: true}}]);
6464
initialContentLines[2] = "new content";
6565
expect(myDocument.getText()).toEqual(initialContentLines.join("\n"));
@@ -83,7 +83,7 @@ define(function (require, exports, module) {
8383
});
8484

8585
it("should do a single edit, leaving a non-beforeEdit selection untouched and preserving reversed flag", function () {
86-
var result = myDocument.doMultipleEdits([{edit: {text: "new content", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}},
86+
const result = myDocument.doMultipleEdits([{edit: {text: "new content", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}},
8787
selection: {start: {line: 2, ch: 4}, end: {line: 2, ch: 4}, reversed: true}}]);
8888
initialContentLines[2] = "new content";
8989
expect(myDocument.getText()).toEqual(initialContentLines.join("\n"));
@@ -96,7 +96,7 @@ define(function (require, exports, module) {
9696
});
9797

9898
it("should do multiple edits, fixing up isBeforeEdit selections with respect to both edits and preserving other selection attributes", function () {
99-
var result = myDocument.doMultipleEdits([
99+
const result = myDocument.doMultipleEdits([
100100
{edit: {text: "modified line 2\n", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}},
101101
selection: {start: {line: 2, ch: 4}, end: {line: 2, ch: 4}, isBeforeEdit: true, primary: true}},
102102
{edit: {text: "modified line 4\n", start: {line: 4, ch: 0}, end: {line: 4, ch: 14}},
@@ -121,7 +121,7 @@ define(function (require, exports, module) {
121121
});
122122

123123
it("should do multiple edits, fixing up non-isBeforeEdit selections only with respect to other edits", function () {
124-
var result = myDocument.doMultipleEdits([
124+
const result = myDocument.doMultipleEdits([
125125
{edit: {text: "modified line 2\n", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}},
126126
selection: {start: {line: 2, ch: 4}, end: {line: 2, ch: 4}, primary: true}},
127127
{edit: {text: "modified line 4\n", start: {line: 4, ch: 0}, end: {line: 4, ch: 14}},
@@ -146,7 +146,7 @@ define(function (require, exports, module) {
146146
});
147147

148148
it("should perform multiple changes/track multiple selections within a single edit, selections specified as isBeforeEdit", function () {
149-
var result = myDocument.doMultipleEdits([
149+
const result = myDocument.doMultipleEdits([
150150
{edit: [{text: "modified line 1", start: {line: 1, ch: 0}, end: {line: 1, ch: 14}},
151151
{text: "modified line 2\n", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}}],
152152
selection: [{start: {line: 1, ch: 4}, end: {line: 1, ch: 4}, isBeforeEdit: true},
@@ -179,7 +179,7 @@ define(function (require, exports, module) {
179179
});
180180

181181
it("should perform multiple changes/track multiple selections within a single edit, selections not specified as isBeforeEdit", function () {
182-
var result = myDocument.doMultipleEdits([
182+
const result = myDocument.doMultipleEdits([
183183
{edit: [{text: "modified line 1", start: {line: 1, ch: 0}, end: {line: 1, ch: 14}},
184184
{text: "modified line 2\n", start: {line: 2, ch: 0}, end: {line: 2, ch: 14}}],
185185
selection: [{start: {line: 1, ch: 4}, end: {line: 1, ch: 4}},
@@ -237,10 +237,10 @@ define(function (require, exports, module) {
237237
});
238238

239239
describe("posFromIndex", function () {
240-
var myEditor, myDocument;
240+
let myEditor, myDocument;
241241

242242
beforeEach(function () {
243-
var mocks = SpecRunnerUtils.createMockEditor("line0\nline1\nline2\n", "unknown");
243+
const mocks = SpecRunnerUtils.createMockEditor("line0\nline1\nline2\n", "unknown");
244244
myDocument = mocks.doc;
245245
myEditor = mocks.editor;
246246
});
@@ -254,28 +254,28 @@ define(function (require, exports, module) {
254254
});
255255

256256
it("should return {0,0} for index 0", function () {
257-
var pos = myDocument.posFromIndex(0);
257+
const pos = myDocument.posFromIndex(0);
258258
expect(pos.line).toBe(0);
259259
expect(pos.ch).toBe(0);
260260
});
261261

262262
it("should return correct position within first line", function () {
263263
// "line0" — index 3 is 'e'
264-
var pos = myDocument.posFromIndex(3);
264+
const pos = myDocument.posFromIndex(3);
265265
expect(pos.line).toBe(0);
266266
expect(pos.ch).toBe(3);
267267
});
268268

269269
it("should return start of second line after newline", function () {
270270
// "line0\n" is 6 chars, so index 6 is start of line 1
271-
var pos = myDocument.posFromIndex(6);
271+
const pos = myDocument.posFromIndex(6);
272272
expect(pos.line).toBe(1);
273273
expect(pos.ch).toBe(0);
274274
});
275275

276276
it("should return correct position on third line", function () {
277277
// "line0\nline1\n" is 12 chars, index 14 is 'n' in "line2"
278-
var pos = myDocument.posFromIndex(14);
278+
const pos = myDocument.posFromIndex(14);
279279
expect(pos.line).toBe(2);
280280
expect(pos.ch).toBe(2);
281281
});
@@ -289,7 +289,7 @@ define(function (require, exports, module) {
289289
// Content is "line0\nline1\nline2\n" — same as beforeEach
290290
expect(myDocument._masterEditor).toBe(null);
291291

292-
var pos = myDocument.posFromIndex(0);
292+
let pos = myDocument.posFromIndex(0);
293293
expect(pos.line).toBe(0);
294294
expect(pos.ch).toBe(0);
295295

0 commit comments

Comments
 (0)