Skip to content

Commit c8738bc

Browse files
committed
test: indent guides integ tests
1 parent 1068d17 commit c8738bc

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

test/spec/Generic-integ-test.js

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*/
2121

22-
/*global describe, path, it, expect, awaitsForDone, beforeAll, afterAll */
22+
/*global describe, path, it, expect, awaitsForDone, beforeAll, afterAll, awaitsFor */
2323

2424
define(function (require, exports, module) {
2525

@@ -73,6 +73,68 @@ define(function (require, exports, module) {
7373
await awaitsForDone(CommandManager.execute(Commands.FILE_REOPEN_CLOSED));
7474
}
7575

76+
describe("Indent Guides", function () {
77+
let currentProjectPath;
78+
beforeAll(async function () {
79+
// Working set behavior is sensitive to whether file lives in the project or outside it, so make
80+
// the project root a known quantity.
81+
currentProjectPath = await SpecRunnerUtils.getTestPath("/spec/space-detect-test-files");
82+
await SpecRunnerUtils.loadProjectInTestWindow(currentProjectPath);
83+
});
84+
85+
async function verify(fileName, expectedIndentLines) {
86+
const isChecked = CommandManager.get(Commands.TOGGLE_INDENT_GUIDES).getChecked();
87+
if(!isChecked){
88+
await awaitsForDone(CommandManager.execute(Commands.TOGGLE_INDENT_GUIDES));
89+
}
90+
await _openProjectFile(fileName);
91+
await awaitsFor(function () {
92+
const _isChecked = CommandManager.get(Commands.TOGGLE_INDENT_GUIDES).getChecked();
93+
return _isChecked &&
94+
_$("#first-pane .cm-phcode-indent-guides:visible").length === expectedIndentLines;
95+
}, ()=>{
96+
return `Indent guides tobe ${expectedIndentLines} but got
97+
${_$("#first-pane .cm-phcode-indent-guides:visible").length}`;
98+
});
99+
await awaitsForDone(CommandManager.execute(Commands.TOGGLE_INDENT_GUIDES));
100+
await awaitsFor(function () {
101+
const _isChecked = CommandManager.get(Commands.TOGGLE_INDENT_GUIDES).getChecked();
102+
return !_isChecked && _$("#first-pane .cm-phcode-indent-guides:visible").length === 0;
103+
}, ()=>{
104+
return `Indent guides to go, but got ${_$("#first-pane .cm-phcode-indent-guides:visible").length}`;
105+
});
106+
await awaitsForDone(CommandManager.execute(Commands.TOGGLE_INDENT_GUIDES));
107+
await awaitsFor(function () {
108+
const _isChecked = CommandManager.get(Commands.TOGGLE_INDENT_GUIDES).getChecked();
109+
return _isChecked &&
110+
_$("#first-pane .cm-phcode-indent-guides:visible").length === expectedIndentLines;
111+
}, ()=>{
112+
return `Guides to be back ${expectedIndentLines} but got
113+
${_$("#first-pane .cm-phcode-indent-guides:visible").length}`;
114+
});
115+
}
116+
117+
it("should show and toggle indent guides with 1 space file", async function () {
118+
await verify("space-1.js", 1);
119+
});
120+
121+
it("should show and toggle indent guides with 12 space file", async function () {
122+
await verify("space-12.js", 3);
123+
});
124+
125+
it("should show and toggle indent guides with no space file", async function () {
126+
await verify("space-none.js", 0);
127+
});
128+
129+
it("should show and toggle indent guides with 2 tabs", async function () {
130+
await verify("tab-2.js", 2);
131+
});
132+
133+
it("should show and toggle indent guides with 12 tabs", async function () {
134+
await verify("tab-12.js", 12);
135+
});
136+
});
137+
76138
describe("reopen closed files test", function () {
77139
let currentProjectPath;
78140
beforeAll(async function () {

0 commit comments

Comments
 (0)