Skip to content

Commit bb19286

Browse files
committed
fix: css code hints tests
1 parent 756913b commit bb19286

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

src/extensions/default/CSSCodeHints/unittests.js

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,22 @@ define(function (require, exports, module) {
156156
it("should list all prop-name hints right after curly bracket", function () {
157157
testEditor.setCursorPos({ line: 4, ch: 11 }); // after {
158158
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
159-
verifyAttrHints(hintList, "accent-color"); // filtered on "empty string"
159+
verifyAttrHints(hintList, "display"); // filtered on "empty string"
160160
});
161161

162162
it("should list all prop-name hints in new line", function () {
163163
testEditor.setCursorPos({ line: 5, ch: 1 });
164164

165165
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
166-
verifyAttrHints(hintList, "accent-color"); // filtered on "empty string"
166+
verifyAttrHints(hintList, "display"); // filtered on "empty string"
167167
});
168168

169169
it("should list all prop-name hints starting with 'b' in new line", function () {
170170
testEditor.setCursorPos({ line: 6, ch: 2 });
171171

172172
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
173-
verifyAttrHints(hintList, "backdrop-filter"); // filtered on "b"
173+
verifyAttrHints(hintList, "background-color"); // filtered on "b" ,
174+
// background color should come at top as its boosted for UX
174175
});
175176

176177
it("should list all prop-name hints starting with 'bord' ", function () {
@@ -188,25 +189,25 @@ define(function (require, exports, module) {
188189

189190
testEditor.setCursorPos({ line: 8, ch: 8 });
190191
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
191-
verifyAttrHints(hintList, "border-block"); // filtered on "border-"
192+
verifyAttrHints(hintList, "border-radius"); // filtered on "border-"
192193
});
193194

194195
it("should list only prop-name hint border-color", function () {
195196
// insert semicolon after previous rule to avoid incorrect tokenizing
196197
testDocument.replaceRange(";", { line: 8, ch: 8 });
197198

198199
testEditor.setCursorPos({ line: 9, ch: 12 });
199-
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
200+
var hintList = expectHints(CSSCodeHints.cssPropHintProvider); // filtered on "border-colo"
200201
verifyAttrHints(hintList, "border-color"); // filtered on "border-color"
201-
expect(hintList.length).toBe(16);
202+
expect(hintList.length).toBe(17);
202203
expect(hintList[0]).toBe("border-color");
203-
expect(hintList[1]).toBe("border-left-color");
204+
expect(hintList[1]).toBe("border-collapse: collapse;"); // due to "border-colo" matches in split segment
204205
});
205206

206207
it("should list prop-name hints at end of property-value finished by ;", function () {
207208
testEditor.setCursorPos({ line: 10, ch: 19 }); // after ;
208209
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
209-
verifyAttrHints(hintList, "accent-color"); // filtered on "empty string"
210+
verifyAttrHints(hintList, "display"); // filtered on "empty string"
210211
});
211212

212213
it("should NOT list prop-name hints right before curly bracket", function () {
@@ -397,7 +398,7 @@ define(function (require, exports, module) {
397398
it("should list prop-name hints inside multi-line styletags with cursor in last line", function () {
398399
testEditor.setCursorPos({ line: 10, ch: 5 }); // inside style, after colo
399400
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
400-
expect(hintList.length).toBe(84);
401+
expect(hintList.length).toBe(50);
401402
expect(hintList[0]).toBe("color");
402403
expect(hintList[1]).toBe("color-adjust");
403404
});
@@ -437,21 +438,21 @@ define(function (require, exports, module) {
437438
it("should list all prop-name hints right after the open quote for style value context", function () {
438439
testEditor.setCursorPos({ line: 4, ch: 12 }); // after "='"
439440
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
440-
verifyAttrHints(hintList, "accent-color"); // filtered on "empty string"
441+
verifyAttrHints(hintList, "display"); // filtered on "empty string"
441442
});
442443

443444
it("should list all prop-name hints in new line for style value context", function () {
444445
testEditor.setCursorPos({ line: 5, ch: 0 });
445446

446447
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
447-
verifyAttrHints(hintList, "accent-color"); // filtered on "empty string"
448+
verifyAttrHints(hintList, "display"); // filtered on "empty string"
448449
});
449450

450451
it("should list all prop-name hints starting with 'b' in new line for style value context", function () {
451452
testEditor.setCursorPos({ line: 6, ch: 2 });
452453

453454
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
454-
verifyAttrHints(hintList, "backdrop-filter"); // filtered on "b"
455+
verifyAttrHints(hintList, "background-color"); // filtered on "b"
455456
});
456457

457458
it("should list all prop-name hints starting with 'bord' for style value context", function () {
@@ -469,7 +470,7 @@ define(function (require, exports, module) {
469470

470471
testEditor.setCursorPos({ line: 8, ch: 8 });
471472
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
472-
verifyAttrHints(hintList, "border-block"); // filtered on "border-"
473+
verifyAttrHints(hintList, "border-radius"); // filtered on "border-"
473474
});
474475

475476
it("should list only prop-name hint border-color for style value context", function () {
@@ -478,15 +479,15 @@ define(function (require, exports, module) {
478479

479480
testEditor.setCursorPos({ line: 9, ch: 12 });
480481
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
481-
expect(hintList.length).toBe(16);
482+
expect(hintList.length).toBe(17);
482483
expect(hintList[0]).toBe("border-color");
483-
expect(hintList[1]).toBe("border-left-color");
484+
expect(hintList[1]).toBe("border-collapse: collapse;");
484485
});
485486

486487
it("should list prop-name hints at end of property-value finished by ; for style value context", function () {
487488
testEditor.setCursorPos({ line: 10, ch: 19 }); // after ;
488489
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
489-
verifyAttrHints(hintList, "accent-color"); // filtered on "empty string"
490+
verifyAttrHints(hintList, "display"); // filtered on "empty string"
490491
});
491492

492493
it("should NOT list prop-name hints right before style value context", function () {
@@ -756,20 +757,11 @@ define(function (require, exports, module) {
756757
var hints = expectHints(CSSCodeHints.cssPropHintProvider, undefined, true).hints,
757758
hintList = extractHintList(hints);
758759
verifyAttrHints(hintList, "currentColor"); // first hint should be currentColor
759-
verifyAllValues(hintList, ["currentColor", "darkmagenta", "transparent"]);
760+
verifyAllValues(hintList, ["currentColor", "transparent"]);
760761
expect(hints[0].find(".color-swatch").length).toBe(0); // no swatch for currentColor
761-
expect(hints[2].find(".color-swatch").length).toBe(0); // no swatch for transparent
762+
expect(hints[1].find(".color-swatch").length).toBe(0); // no swatch for transparent
762763
expect(hints[0].hasClass("no-swatch-margin")).toBeTruthy(); // no-swatch-margin applied to currentColor
763-
expect(hints[2].hasClass("no-swatch-margin")).toBeTruthy(); // no-swatch-margin applied to transparent
764-
});
765-
766-
it("should remove class no-swatch-margin from transparent if it's the only one in the list", function () {
767-
testEditor.setCursorPos({ line: 103, ch: 22 }); // after color
768-
var hints = expectHints(CSSCodeHints.cssPropHintProvider, undefined, true).hints,
769-
hintList = extractHintList(hints);
770-
verifyAllValues(hintList, ["transparent"]);
771-
expect(hints[0].find(".color-swatch").length).toBe(0); // no swatch for transparent
772-
expect(hints[0].hasClass("no-swatch-margin")).toBeFalsy(); // no-swatch-margin not applied to transparent
764+
expect(hints[1].hasClass("no-swatch-margin")).toBeTruthy(); // no-swatch-margin applied to transparent
773765
});
774766

775767
it("should insert color names correctly", function () {

src/language/CodeInspection.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ define(function (require, exports, module) {
555555
* @param {?string} providerName name of the provider that is requesting a run
556556
*/
557557
function run() {
558+
if(!problemsPanel){
559+
return;
560+
}
558561
if (!_enabled) {
559562
_hasErrors = false;
560563
_currentPromise = null;

0 commit comments

Comments
 (0)