Skip to content

Commit 3054910

Browse files
committed
less/scss tests
1 parent 6dcbedd commit 3054910

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

src/worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ const service = cssLangService.getCSSLanguageService();
44
const CSS_MODES = {
55
CSS: "css",
66
LESS: "less",
7-
SCSS: "scss",
8-
SASS: "sass"
7+
SCSS: "scss"
98
};
109

1110
function getTextDocument(text, languageID, filePath = "file://placeholder.css") {

test/test-css.worker.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,23 @@ describe(`web worker CSS Language tests`, function () {
4545
expect(output).to.be.not.null;
4646
});
4747

48-
it(`Should getAllSymbols get all css symbols`, async function () {
48+
it(`Should getAllSymbols get all css selectors`, async function () {
4949
messageFromWorker = null;
50-
const text = await (await fetch("test-files/a.css")).text();
50+
const text = await (await fetch("test-files/css-tests/a.css")).text();
5151
worker.postMessage({command: `getAllSymbols`, text, cssMode: "CSS", filePath: "file:///a.css"});
5252
let output = await waitForWorkerMessage(`getAllSymbols`, 1000);
5353
const symbols = output.symbols;
5454
expect(symbols.length).to.eql(29);
5555
expect(symbols.includes(".testClass")).to.be.true;
5656
expect(symbols.includes("@keyframes shooting")).to.be.true;
5757
});
58+
59+
it(`Should getAllSymbols get all less selectors`, async function () {
60+
messageFromWorker = null;
61+
const text = await (await fetch("test-files/css-tests/b.less")).text();
62+
worker.postMessage({command: `getAllSymbols`, text, cssMode: "LESS", filePath: "file:///b.less"});
63+
let output = await waitForWorkerMessage(`getAllSymbols`, 1000);
64+
const symbols = output.symbols;
65+
expect(symbols).to.deep.equal(["#header",".navigation",".logo","& .phcode"]);
66+
});
5867
});

test/test-files/css-tests/b.less

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#header {
2+
color: black;
3+
.navigation {
4+
font-size: 12px;
5+
}
6+
.logo {
7+
width: 300px;
8+
}
9+
& .phcode {
10+
color: green;
11+
}
12+
}

test/test-files/css-tests/c.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@mixin theme($theme: DarkGray) {
2+
background: $theme;
3+
box-shadow: 0 0 1px rgba($theme, .25);
4+
color: #fff;
5+
}
6+
7+
.info {
8+
@include theme;
9+
}
10+
.alert {
11+
@include theme($theme: DarkRed);
12+
}
13+
#success {
14+
@include theme($theme: DarkGreen);
15+
}

0 commit comments

Comments
 (0)