Skip to content

Commit 15b0858

Browse files
committed
feat: unit tests for emmet code hints for css
1 parent 2affd39 commit 15b0858

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

src/extensions/default/CSSCodeHints/unittests.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,69 @@ define(function (require, exports, module) {
829829
expectNoHints(CSSCodeHints.cssPropHintProvider, " ");
830830
});
831831
});
832+
833+
834+
const emmetContent = "body {\n" +
835+
" m\n" +
836+
" bgc\n" +
837+
" m0\n" +
838+
" pt10\n" +
839+
" ma\n" +
840+
"}";
841+
842+
describe("Emmet hints for CSS", function () {
843+
844+
beforeEach(function () {
845+
setupTest(emmetContent, "css");
846+
});
847+
848+
afterEach(function () {
849+
tearDownTest();
850+
});
851+
852+
it("should display emmet hint margin when m is pressed", function () {
853+
testEditor.setCursorPos({ line: 1, ch: 3 });
854+
const hints = expectHints(CSSCodeHints.cssPropHintProvider);
855+
verifyAttrHints(hints, "margin");
856+
expect(hints.indexOf("margin")).toBe(0);
857+
});
858+
859+
it("should display emmet hint background-color when bgc is pressed", function () {
860+
testEditor.setCursorPos({ line: 2, ch: 5 });
861+
const hints = expectHints(CSSCodeHints.cssPropHintProvider);
862+
verifyAttrHints(hints, "background-color");
863+
expect(hints.indexOf("background-color")).toBe(0);
864+
});
865+
866+
it("should complete margin property when m0 is pressed", function () {
867+
testEditor.setCursorPos({ line: 3, ch: 4 });
868+
const hints = expectHints(CSSCodeHints.cssPropHintProvider);
869+
verifyAttrHints(hints, "margin: 0;");
870+
expect(hints.indexOf("margin: 0;")).toBe(0);
871+
872+
selectHint(CSSCodeHints.cssPropHintProvider, "margin: 0;");
873+
expect(testDocument.getLine(3)).toBe(" margin: 0;");
874+
expectCursorAt({ line: 3, ch: 12 });
875+
});
876+
877+
it("should complete padding-top property when pt10 is pressed", function () {
878+
testEditor.setCursorPos({ line: 4, ch: 6 });
879+
const hints = expectHints(CSSCodeHints.cssPropHintProvider);
880+
verifyAttrHints(hints, "padding-top: 10px;");
881+
expect(hints.indexOf("padding-top: 10px;")).toBe(0);
882+
883+
selectHint(CSSCodeHints.cssPropHintProvider, "padding-top: 10px;");
884+
expect(testDocument.getLine(4)).toBe(" padding-top: 10px;");
885+
expectCursorAt({ line: 4, ch: 20 });
886+
});
887+
888+
it("should not hint margin when ma is pressed", function () {
889+
testEditor.setCursorPos({ line: 5, ch: 4 });
890+
const hints = expectHints(CSSCodeHints.cssPropHintProvider);
891+
expect(hints.indexOf("margin")).toBe(1); // this should not be 0, as max-width comes first
892+
});
893+
894+
});
832895
});
833896
});
834897

0 commit comments

Comments
 (0)