Skip to content

Commit 3c78a05

Browse files
Add tests.
1 parent 545fa20 commit 3c78a05

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/cases/unittests/services/documentRegistry.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ describe("DocumentRegistry", () => {
5050
});
5151

5252
it("Acquiring document gets correct version 2", () => {
53-
debugger;
5453
var documentRegistry = ts.createDocumentRegistry();
5554
var defaultCompilerOptions = ts.getDefaultCompilerOptions();
5655

5756
var contents = "var x = 1;"
5857
var snapshot = ts.ScriptSnapshot.fromString(contents);
5958

59+
// Always treat any change as a full change.
60+
snapshot.getChangeRange = old => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length);
61+
6062
// Simulate one LS getting the document.
6163
var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1");
6264

6365
// Simulate another LS getting that document.
6466
var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1");
6567

6668
// Now LS1 updates their document.
67-
var f3 = documentRegistry.updateDocument(f1, "file1.ts", defaultCompilerOptions, snapshot, /* version */ "2",
68-
ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length));
69+
var f3 = documentRegistry.updateDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "2");
6970

7071
// Now LS2 tries to update their document.
71-
var f4 = documentRegistry.updateDocument(f1, "file1.ts", defaultCompilerOptions, snapshot, /* version */ "3",
72-
ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length));
72+
var f4 = documentRegistry.updateDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "3");
7373
});
7474
});

0 commit comments

Comments
 (0)