mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Emmet: Allow css completions in style tag/attribute, html completions in script tags with html type
This commit is contained in:
@@ -7,12 +7,17 @@ import 'mocha';
|
||||
import * as assert from 'assert';
|
||||
import { withRandomFileEditor } from './testUtils';
|
||||
import * as vscode from 'vscode';
|
||||
import { parsePartialStylesheet } from '../util';
|
||||
import { parsePartialStylesheet, getNode } from '../util';
|
||||
import { isValidLocationForEmmetAbbreviation } from '../abbreviationActions';
|
||||
|
||||
|
||||
|
||||
suite('Tests for partial parse of Stylesheets', () => {
|
||||
|
||||
function isValid(doc: vscode.TextDocument, range: vscode.Range, syntax: string): boolean {
|
||||
const rootNode = parsePartialStylesheet(doc, range.end);
|
||||
const currentNode = getNode(rootNode, range.end, true);
|
||||
return isValidLocationForEmmetAbbreviation(doc, rootNode, currentNode, 'css', range.end, range);
|
||||
}
|
||||
|
||||
test('Ignore block comment inside rule', function (): any {
|
||||
const cssContents = `
|
||||
p {
|
||||
@@ -37,10 +42,10 @@ p {
|
||||
|
||||
]
|
||||
rangesForEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'css', range.end, range), true);
|
||||
assert.equal(isValid(doc, range, 'css'), true);
|
||||
});
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'css', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'css'), false);
|
||||
});
|
||||
|
||||
return Promise.resolve();
|
||||
@@ -67,7 +72,7 @@ dn {
|
||||
new vscode.Range(7, 2, 7, 4) // bg after ending of badly constructed block
|
||||
];
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'scss'), false);
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
@@ -102,10 +107,10 @@ comment */
|
||||
new vscode.Range(10, 2, 10, 3) // p after ending of block
|
||||
];
|
||||
rangesForEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'css', range.end, range), true);
|
||||
assert.equal(isValid(doc, range, 'css'), true);
|
||||
});
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'css', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'css'), false);
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
@@ -137,10 +142,10 @@ comment */
|
||||
new vscode.Range(6, 3, 6, 4) // In selector
|
||||
];
|
||||
rangesForEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), true);
|
||||
assert.equal(isValid(doc, range, 'scss'), true);
|
||||
});
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'scss'), false);
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
@@ -169,10 +174,10 @@ comment */
|
||||
new vscode.Range(1, 66, 1, 68) // Outside any ruleset
|
||||
];
|
||||
rangesForEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), true);
|
||||
assert.equal(isValid(doc, range, 'scss'), true);
|
||||
});
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'scss'), false);
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
@@ -204,10 +209,10 @@ p.#{dn} {
|
||||
new vscode.Range(7, 1, 7, 3) // dn inside ruleset whose selector uses nested interpolation
|
||||
];
|
||||
rangesForEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), true);
|
||||
assert.equal(isValid(doc, range, 'scss'), true);
|
||||
});
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'scss'), false);
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
@@ -242,10 +247,10 @@ ment */{
|
||||
new vscode.Range(6, 3, 6, 4) // In c inside block comment
|
||||
];
|
||||
rangesForEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), true);
|
||||
assert.equal(isValid(doc, range, 'scss'), true);
|
||||
});
|
||||
rangesNotEmmet.forEach(range => {
|
||||
assert.equal(isValidLocationForEmmetAbbreviation(doc, parsePartialStylesheet(doc, range.end), 'scss', range.end, range), false);
|
||||
assert.equal(isValid(doc, range, 'scss'), false);
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user