|
19 | 19 | * |
20 | 20 | */ |
21 | 21 |
|
22 | | -/*global describe, path, it, expect, awaitsForDone, beforeAll, afterAll */ |
| 22 | +/*global describe, path, it, expect, awaitsForDone, beforeAll, afterAll, awaitsFor */ |
23 | 23 |
|
24 | 24 | define(function (require, exports, module) { |
25 | 25 |
|
@@ -73,6 +73,68 @@ define(function (require, exports, module) { |
73 | 73 | await awaitsForDone(CommandManager.execute(Commands.FILE_REOPEN_CLOSED)); |
74 | 74 | } |
75 | 75 |
|
| 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 | + |
76 | 138 | describe("reopen closed files test", function () { |
77 | 139 | let currentProjectPath; |
78 | 140 | beforeAll(async function () { |
|
0 commit comments