Skip to content

Commit 582dee6

Browse files
committed
chore: add unit-tests for emmet-stylesheets
1 parent 84bcace commit 582dee6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/extensions/default/CSSCodeHints/unittests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ define(function (require, exports, module) {
110110
expect(hintList[0]).toBe(expectedFirstHint);
111111
}
112112

113+
function verifySecondAttrHint(hintList, expectedSecondHint) {
114+
expect(hintList.indexOf("div")).toBe(-1);
115+
expect(hintList[1]).toBe(expectedSecondHint);
116+
}
113117

114118
function selectHint(provider, expectedHint, implicitChar) {
115119
var hintList = expectHints(provider, implicitChar);
@@ -174,6 +178,14 @@ define(function (require, exports, module) {
174178
// bottom should come at top as it is coming from emmet, and it has the highest priority
175179
});
176180

181+
it("should list the second prop-name hint starting with 'b'", function () {
182+
testEditor.setCursorPos({ line: 6, ch: 2 });
183+
184+
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
185+
verifySecondAttrHint(hintList, "background-color"); // filtered on "b" ,
186+
// background-color should be displayed at second. as first will be bottom coming from emmet
187+
});
188+
177189
it("should list all prop-name hints starting with 'bord' ", function () {
178190
// insert semicolon after previous rule to avoid incorrect tokenizing
179191
testDocument.replaceRange(";", { line: 6, ch: 2 });
@@ -244,6 +256,15 @@ define(function (require, exports, module) {
244256
testDocument = null;
245257
});
246258

259+
it("should expand m0 to margin: 0; when Emmet hint is used", function () {
260+
testDocument.replaceRange("m0", { line: 6, ch: 2 });
261+
testEditor.setCursorPos({ line: 6, ch: 4 });
262+
263+
selectHint(CSSCodeHints.cssPropHintProvider, "margin: 0;");
264+
expect(testDocument.getLine(6)).toBe(" margin: 0;");
265+
});
266+
267+
247268
it("should insert colon prop-name selected", function () {
248269
// insert semicolon after previous rule to avoid incorrect tokenizing
249270
testDocument.replaceRange(";", { line: 6, ch: 2 });
@@ -462,6 +483,13 @@ define(function (require, exports, module) {
462483
verifyAttrHints(hintList, "bottom"); // filtered on "b"
463484
});
464485

486+
it("should list the second prop-name hint starting with 'b' for style value context", function () {
487+
testEditor.setCursorPos({ line: 6, ch: 2 });
488+
489+
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
490+
verifySecondAttrHint(hintList, "background-color"); // second result when filtered on "b"
491+
});
492+
465493
it("should list all prop-name hints starting with 'bord' for style value context", function () {
466494
// insert semicolon after previous rule to avoid incorrect tokenizing
467495
testDocument.replaceRange(";", { line: 6, ch: 2 });

0 commit comments

Comments
 (0)