Skip to content

Commit 60a44be

Browse files
committed
feat: custom snippets integration tests
1 parent 061fda0 commit 60a44be

File tree

9 files changed

+1065
-2
lines changed

9 files changed

+1065
-2
lines changed

src/extensionsIntegrated/CustomSnippets/codeHintIntegration.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ define(function (require, exports, module) {
116116
);
117117
if (matchedSnippet) {
118118
// Get current editor from EditorManager since it's not passed
119-
const editor = EditorManager.getFocusedEditor();
119+
const editor = EditorManager.getActiveEditor();
120120

121121
if (editor) {
122122
// to track the usage metrics
@@ -154,4 +154,5 @@ define(function (require, exports, module) {
154154
}
155155

156156
exports.init = init;
157+
exports._CustomSnippetsHandler = CustomSnippetsHandler; // exposed for integration testing
157158
});

src/extensionsIntegrated/CustomSnippets/main.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ define(function (require, exports, module) {
267267
CodeHintIntegration.init();
268268

269269
// load snippets from file storage
270-
SnippetsState.loadSnippetsFromState()
270+
const _snippetsLoadedPromise = SnippetsState.loadSnippetsFromState()
271271
.then(function () {
272272
// track boot-time snippet count (only if user has snippets)
273273
const snippetCount = Global.SnippetHintsList.length;
@@ -281,5 +281,15 @@ define(function (require, exports, module) {
281281
});
282282

283283
SnippetCursorManager.registerHandlers();
284+
285+
// Expose modules for integration testing
286+
if (brackets.test) {
287+
brackets.test.CustomSnippetsGlobal = Global;
288+
brackets.test.CustomSnippetsHelper = Helper;
289+
brackets.test.CustomSnippetsCursorManager = SnippetCursorManager;
290+
brackets.test.CustomSnippetsCodeHintHandler = CodeHintIntegration._CustomSnippetsHandler;
291+
brackets.test.CustomSnippetsDriver = Driver;
292+
brackets.test._customSnippetsLoadedPromise = _snippetsLoadedPromise;
293+
}
284294
});
285295
});

src/extensionsIntegrated/CustomSnippets/snippetCursorManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,6 @@ define(function (require, exports, module) {
529529
exports.handleCursorActivity = handleCursorActivity;
530530
exports.endSnippetSession = endSnippetSession;
531531
exports.registerHandlers = registerHandlers;
532+
exports.navigateToNextTabStop = navigateToNextTabStop; // exposed for integration testing
533+
exports.navigateToPreviousTabStop = navigateToPreviousTabStop; // exposed for integration testing
532534
});

test/UnitTestSuite.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ define(function (require, exports, module) {
133133
require("spec/Extn-CollapseFolders-integ-test");
134134
require("spec/Extn-Tabbar-integ-test");
135135
require("spec/Extn-CustomSnippets-test");
136+
require("spec/Extn-CustomSnippets-integ-test");
136137
// extension integration tests
137138
require("spec/Extn-CSSCodeHints-integ-test");
138139
require("spec/Extn-HTMLCodeHints-Lint-integ-test");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
5+
<script>
6+
var x = 1;
7+
8+
</script>
9+
</body>
10+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// test file for custom snippets integration tests
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# test file for custom snippets integration tests
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// test file for custom snippets integration tests

0 commit comments

Comments
 (0)