Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 4a79d66

Browse files
Merge pull request #10752 from adobe/prksingh/unitTestsForPR#10242
Adding unit tests for the fix for #10160
2 parents 65b44d2 + 63f2d3f commit 4a79d66

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

test/spec/CodeHint-test-files/test1.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
<
55
<
66
</body>
7+
<script>
8+
function test(x) {
9+
return (/\.(eot|wo)$/i);
10+
}
11+
</script>
712
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Function containing regular expression
2+
function test() {
3+
return (/\.(eot|otf|ttf|wo)$/i);
4+
}

test/spec/CodeHint-test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,49 @@ define(function (require, exports, module) {
114114
return codeHintList;
115115
}
116116

117+
// TODO: There seems to be an issue with CodeHintManager._removeHintProvider because of which the tests
118+
// added for "Hint Provider Registration" are interfering with this test case
119+
// (mock provider added for new language shows up for RegExp, even though no code hint should show up)
120+
// I am unable to reproduce this in a real scenario though/
121+
// This is the reason this test case is being added before the registration test cases.
122+
// We need to either figure out whats going wrong with register or change the RegExp code hint fix to bail
123+
// before HintUtils (Something like the fix for no code hints for multiple selection)
124+
describe("RegExp codehint tests", function () {
125+
it("should not show codehints for regular expression in a script block in html", function () {
126+
var editor,
127+
pos = {line: 8, ch: 30};
128+
129+
// Place cursor inside a sample regular expression
130+
// Note: line for pos is 0-based and editor lines numbers are 1-based
131+
initCodeHintTest("test1.html", pos);
132+
133+
runs(function () {
134+
editor = EditorManager.getCurrentFullEditor();
135+
expect(editor).toBeTruthy();
136+
invokeCodeHints();
137+
expectNoHints();
138+
editor = null;
139+
});
140+
});
141+
142+
it("should not show codehints for regular expression in a Javascript file", function () {
143+
var editor,
144+
pos = {line: 2, ch: 30};
145+
146+
// Place cursor inside a sample regular expression
147+
// Note: line for pos is 0-based and editor lines numbers are 1-based
148+
initCodeHintTest("testRegexp.js", pos);
149+
150+
runs(function () {
151+
editor = EditorManager.getCurrentFullEditor();
152+
expect(editor).toBeTruthy();
153+
invokeCodeHints();
154+
expectNoHints();
155+
editor = null;
156+
});
157+
});
158+
});
159+
117160
describe("Hint Provider Registration", function () {
118161
beforeEach(function () {
119162
initCodeHintTest("test1.html", {line: 0, ch: 0});

0 commit comments

Comments
 (0)