Skip to content

Commit

Permalink
test: doc ref counting integ test with tab spacing config
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Aug 20, 2024
1 parent 6c0b617 commit e63fbb3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/spec/Document-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ define(function (require, exports, module) {
// TODO: additional, simpler ref counting test cases such as Live Development, open/close inline editor (refs from
// both editor & rule list TextRanges), navigate files w/o adding to working set, etc.

it("should clean up (later) a master Editor auto-created by calling read-only Document API, if Editor not used by UI", async function () {
async function testRef(useAutoTabSpaces) {
var promise,
cssDoc,
cssMasterEditor;
Editor.Editor.setAutoTabSpaces(false);
Editor.Editor.setAutoTabSpaces(useAutoTabSpaces);
promise = CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, {fullPath: HTML_FILE});
await awaitsForDone(promise, "Open into working set");

Expand All @@ -309,8 +309,12 @@ define(function (require, exports, module) {

// Force creation of master editor for CSS file
cssDoc = DocumentManager.getOpenDocumentForPath(CSS_FILE);
expect(cssDoc._masterEditor).toBeFalsy();
DocumentManager.getOpenDocumentForPath(CSS_FILE).getLine(0);
if(!useAutoTabSpaces){
// if auto tab spaces is enabled, the space detect algo will read the file contents for detecting
// spacing, so these 2 lines won't apply.
expect(cssDoc._masterEditor).toBeFalsy();
DocumentManager.getOpenDocumentForPath(CSS_FILE).getLine(0);
}
expect(cssDoc._masterEditor).toBeTruthy();

// Close inline editor
Expand All @@ -337,6 +341,14 @@ define(function (require, exports, module) {
expect(testWindow.$(".CodeMirror").length).toBe(2); // HTML editor (working set) & JS editor (current)

cssDoc = cssMasterEditor = null;
}

it("should clean up (later) a master Editor auto-created by calling read-only Document API, if Editor not used by UI", async function () {
await testRef(false);
});

it("should clean up (later) a master Editor in auto tab space detect mode, auto-created by calling read-only Document API, if Editor not used by UI", async function () {
await testRef(true);
});
});
});
Expand Down

0 comments on commit e63fbb3

Please sign in to comment.