Getting closer to shared config #59803

This commit is contained in:
Ramya Achutha Rao
2018-10-02 20:00:19 -07:00
parent 5ae10c4ee3
commit 6ad61f018a
19 changed files with 128 additions and 122 deletions

View File

@@ -56,7 +56,7 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
teardown(closeAllEditors);
test('Expand abbreviation (CSS)', () => {
return withRandomFileEditor(cssContents, 'css', (editor, doc) => {
return withRandomFileEditor(cssContents, 'css', (editor, _) => {
editor.selections = [new Selection(3, 1, 3, 6), new Selection(5, 1, 5, 6)];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), cssContents.replace(/pos:f/g, 'position: fixed;'));
@@ -75,7 +75,7 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(3, 4, 3, 4);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -98,7 +98,7 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
nav#
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(5, 4, 5, 4);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -120,7 +120,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(2, 10, 2, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -137,7 +137,7 @@ nav#
test('Skip when typing the last property value in single line rules (CSS)', () => {
const testContent = `.foo {padding: 10px; margin: a}`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(0, 30, 0, 30);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -159,7 +159,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
const cancelSrc = new CancellationTokenSource();
const completionPromise1 = completionProvider.provideCompletionItems(editor.document, new Position(2, 12), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(2, 14), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -198,7 +198,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(3, 10, 3, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -220,7 +220,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
const cancelSrc = new CancellationTokenSource();
const completionPromise1 = completionProvider.provideCompletionItems(editor.document, new Position(3, 12), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(3, 14), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -258,7 +258,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(2, 10, 2, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -279,7 +279,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
const cancelSrc = new CancellationTokenSource();
const completionPromise1 = completionProvider.provideCompletionItems(editor.document, new Position(2, 12), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(2, 14), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -317,7 +317,7 @@ nav#
}
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(2, 2, 2, 2);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
@@ -336,7 +336,7 @@ nav#
const abbreviation = 'pos:f';
const expandedText = 'position: fixed;';
return withRandomFileEditor(cssContents, 'css', (editor, doc) => {
return withRandomFileEditor(cssContents, 'css', (editor, _) => {
editor.selection = new Selection(3, 1, 3, 6);
const cancelSrc = new CancellationTokenSource();
const completionPromise1 = completionProvider.provideCompletionItems(editor.document, new Position(3, 6), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -366,7 +366,7 @@ nav#
});
test('Expand abbreviation (SCSS)', () => {
return withRandomFileEditor(scssContents, 'scss', (editor, doc) => {
return withRandomFileEditor(scssContents, 'scss', (editor, _) => {
editor.selections = [
new Selection(3, 4, 3, 4),
new Selection(5, 5, 5, 5),
@@ -382,7 +382,7 @@ nav#
test('Expand abbreviation in completion list (SCSS)', () => {
return withRandomFileEditor(scssContents, 'scss', (editor, doc) => {
return withRandomFileEditor(scssContents, 'scss', (editor, _) => {
editor.selection = new Selection(3, 4, 3, 4);
const cancelSrc = new CancellationTokenSource();
const completionPromise1 = completionProvider.provideCompletionItems(editor.document, new Position(3, 4), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -439,7 +439,7 @@ m10
}
`;
return withRandomFileEditor(scssContentsNoExpand, 'scss', (editor, doc) => {
return withRandomFileEditor(scssContentsNoExpand, 'scss', (editor, _) => {
editor.selections = [
new Selection(1, 3, 1, 3), // outside rule
new Selection(5, 15, 5, 15) // in the value part of property value
@@ -462,7 +462,7 @@ m10
}
`;
return withRandomFileEditor(scssContentsNoExpand, 'scss', (editor, doc) => {
return withRandomFileEditor(scssContentsNoExpand, 'scss', (editor, _) => {
editor.selection = new Selection(1, 3, 1, 3); // outside rule
const cancelSrc = new CancellationTokenSource();
let completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -487,7 +487,7 @@ m10
});
test('Skip when typing property values when there is a nested rule in the next line (SCSS)', () => {
return withRandomFileEditor(scssContents, 'scss', (editor, doc) => {
return withRandomFileEditor(scssContents, 'scss', (editor, _) => {
editor.selection = new Selection(19, 10, 19, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), scssContents);

View File

@@ -59,7 +59,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
`;
test('Emmet Next/Prev Edit point in html file', function (): any {
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
return withRandomFileEditor(htmlContents, '.html', (editor, _) => {
editor.selections = [new Selection(1, 5, 1, 5)];
let expectedNextEditPoints: [number, number][] = [[4, 16], [6, 8], [10, 2], [20, 0]];
@@ -79,7 +79,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Select Next/Prev Item in html file', function (): any {
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
return withRandomFileEditor(htmlContents, '.html', (editor, _) => {
editor.selections = [new Selection(2, 2, 2, 2)];
let expectedNextItemPoints: [number, number, number][] = [
@@ -114,7 +114,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Select Next/Prev item at boundary', function(): any {
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
return withRandomFileEditor(htmlContents, '.html', (editor, _) => {
editor.selections = [new Selection(4, 1, 4, 1)];
fetchSelectItem('next');
@@ -138,7 +138,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
</div>
</script>
`;
return withRandomFileEditor(templateContents, '.html', (editor, doc) => {
return withRandomFileEditor(templateContents, '.html', (editor, _) => {
editor.selections = [new Selection(2, 2, 2, 2)];
let expectedNextItemPoints: [number, number, number][] = [
@@ -167,7 +167,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Select Next/Prev Item in css file', function (): any {
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
return withRandomFileEditor(cssContents, '.css', (editor, _) => {
editor.selections = [new Selection(0, 0, 0, 0)];
let expectedNextItemPoints: [number, number, number][] = [
@@ -198,7 +198,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Select Next/Prev Item in scss file with nested rules', function (): any {
return withRandomFileEditor(scssContents, '.scss', (editor, doc) => {
return withRandomFileEditor(scssContents, '.scss', (editor, _) => {
editor.selections = [new Selection(0, 0, 0, 0)];
let expectedNextItemPoints: [number, number, number][] = [
@@ -229,7 +229,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Balance Out in html file', function (): any {
return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
return withRandomFileEditor(htmlContents, 'html', (editor, _) => {
editor.selections = [new Selection(14, 6, 14, 10)];
let expectedBalanceOutRanges: [number, number, number, number][] = [
@@ -266,7 +266,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Balance In using the same stack as Balance out in html file', function (): any {
return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
return withRandomFileEditor(htmlContents, 'html', (editor, _) => {
editor.selections = [new Selection(15, 6, 15, 10)];
let expectedBalanceOutRanges: [number, number, number, number][] = [
@@ -295,7 +295,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
test('Emmet Balance In when selection doesnt span entire node or its inner contents', function (): any {
return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
return withRandomFileEditor(htmlContents, 'html', (editor, _) => {
editor.selection = new Selection(13, 7, 13, 10); // Inside the open tag of <ul class="nav main">
balanceIn();
@@ -324,7 +324,7 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
</div>
</script>`;
return withRandomFileEditor(htmlTemplate, 'html', (editor, doc) => {
return withRandomFileEditor(htmlTemplate, 'html', (editor, _) => {
editor.selections = [new Selection(5, 24, 5, 24)];
let expectedBalanceOutRanges: [number, number, number, number][] = [

View File

@@ -9,7 +9,7 @@ import { Selection } from 'vscode';
import { withRandomFileEditor, closeAllEditors } from './testUtils';
import { incrementDecrement as incrementDecrementImpl } from '../incrementDecrement';
function incrementDecrement(delta): Thenable<boolean> {
function incrementDecrement(delta: number): Thenable<boolean> {
const result = incrementDecrementImpl(delta);
assert.ok(result);
return result!;

View File

@@ -15,7 +15,7 @@ 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);
return isValidLocationForEmmetAbbreviation(doc, rootNode, currentNode, syntax, range.end, range);
}
test('Ignore block comment inside rule', function (): any {
@@ -27,7 +27,7 @@ p {
p.
} p
`;
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
return withRandomFileEditor(cssContents, '.css', (_, doc) => {
let rangesForEmmet = [
new vscode.Range(3, 18, 3, 19), // Same line after block comment
new vscode.Range(4, 1, 4, 2), // p after block comment
@@ -62,7 +62,7 @@ dn {
@
} bg
`;
return withRandomFileEditor(sassContents, '.scss', (editor, doc) => {
return withRandomFileEditor(sassContents, '.scss', (_, doc) => {
let rangesNotEmmet = [
new vscode.Range(1, 0, 1, 4), // Selector
new vscode.Range(2, 3, 2, 7), // Line commented selector
@@ -91,7 +91,7 @@ comment */
p.
} p
`;
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
return withRandomFileEditor(cssContents, '.css', (_, doc) => {
let rangesForEmmet = [
new vscode.Range(7, 18, 7, 19), // Same line after block comment
new vscode.Range(8, 1, 8, 2), // p after block comment
@@ -130,7 +130,7 @@ comment */
}
}}}
`;
return withRandomFileEditor(sassContents, '.scss', (editor, doc) => {
return withRandomFileEditor(sassContents, '.scss', (_, doc) => {
let rangesForEmmet = [
new vscode.Range(2, 1, 2, 2), // Inside a ruleset before errors
new vscode.Range(3, 1, 3, 2), // Inside a ruleset after no serious error
@@ -155,7 +155,7 @@ comment */
const sassContents = `
.foo{dn}.bar{.boo{dn}dn}.comd{/*{dn*/p{div{dn}} }.foo{.other{dn}} dn
`;
return withRandomFileEditor(sassContents, '.scss', (editor, doc) => {
return withRandomFileEditor(sassContents, '.scss', (_, doc) => {
let rangesForEmmet = [
new vscode.Range(1, 5, 1, 7), // Inside a ruleset
new vscode.Range(1, 18, 1, 20), // Inside a nested ruleset
@@ -194,7 +194,7 @@ p.#{dn} {
dn
}
`;
return withRandomFileEditor(sassContents, '.scss', (editor, doc) => {
return withRandomFileEditor(sassContents, '.scss', (_, doc) => {
let rangesForEmmet = [
new vscode.Range(2, 1, 2, 4), // p.3 inside a ruleset whose selector uses interpolation
new vscode.Range(4, 1, 4, 3) // dn inside ruleset after property with variable
@@ -234,7 +234,7 @@ ment */{
op.3
}
`;
return withRandomFileEditor(sassContents, '.scss', (editor, doc) => {
return withRandomFileEditor(sassContents, '.scss', (_, doc) => {
let rangesForEmmet = [
new vscode.Range(2, 14, 2, 21), // brs6-2p with a block commented line comment ('/* */' overrides '//')
new vscode.Range(3, 1, 3, 3), // dn after a line with combined comments inside a ruleset

View File

@@ -295,7 +295,7 @@ suite('Tests for Emmet actions on html tags', () => {
// #region match tag
test('match tag with mutliple cursors', () => {
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [
new Selection(1, 0, 1, 0), // just before tag starts, i.e before <
new Selection(1, 1, 1, 1), // just before tag name starts
@@ -326,7 +326,7 @@ suite('Tests for Emmet actions on html tags', () => {
</div>
</script>`;
return withRandomFileEditor(templateScript, 'html', (editor, doc) => {
return withRandomFileEditor(templateScript, 'html', (editor, _) => {
editor.selections = [
new Selection(2, 2, 2, 2), // just before div tag starts, i.e before <
];

View File

@@ -57,7 +57,7 @@ export function withRandomFileEditor(initialContents: string, fileExtension: str
return vscode.window.showTextDocument(doc).then((editor) => {
return run(editor, doc).then(_ => {
if (doc.isDirty) {
return doc.save().then(saved => {
return doc.save().then(() => {
return deleteFile(file);
});
} else {

View File

@@ -127,7 +127,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(2, 0, 2, 0)];
const promise = wrapWithAbbreviation({ abbreviation: 'li.hello|c' });
if (!promise) {
@@ -155,7 +155,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</div>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(1, 1, 1, 1)];
const promise = wrapWithAbbreviation({ abbreviation: 'div' });
if (!promise) {
@@ -183,7 +183,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</div>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(3, 1, 3, 1)];
const promise = wrapWithAbbreviation({ abbreviation: 'div' });
if (!promise) {
@@ -208,7 +208,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(1, 2, 1, 2)];
const promise = wrapWithAbbreviation({ abbreviation: 'ul>li>a' });
if (!promise) {
@@ -237,7 +237,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
</ul>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(2, 2, 3, 33)];
const promise = wrapIndividualLinesWithAbbreviation({ abbreviation: 'ul>li.hello$*' });
if (!promise) {
@@ -266,7 +266,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
</ul>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(2, 1, 4, 0)];
const promise = wrapIndividualLinesWithAbbreviation({ abbreviation: 'ul>li.hello$*' });
if (!promise) {
@@ -297,7 +297,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
</ul>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(2, 2, 3, 33)];
const promise = wrapIndividualLinesWithAbbreviation({ abbreviation: 'ul>li.hello*|c' });
if (!promise) {
@@ -326,7 +326,7 @@ suite('Tests for Wrap with Abbreviations', () => {
</ul>
</ul>
`;
return withRandomFileEditor(contents, 'html', (editor, doc) => {
return withRandomFileEditor(contents, 'html', (editor, _) => {
editor.selections = [new Selection(2, 3, 3, 16)];
const promise = wrapIndividualLinesWithAbbreviation({ abbreviation: 'ul>li.hello$*|t' });
if (!promise) {
@@ -344,7 +344,7 @@ suite('Tests for Wrap with Abbreviations', () => {
function testWrapWithAbbreviation(selections: Selection[], abbreviation: string, expectedContents: string): Thenable<any> {
return withRandomFileEditor(htmlContentsForWrapTests, 'html', (editor, doc) => {
return withRandomFileEditor(htmlContentsForWrapTests, 'html', (editor, _) => {
editor.selections = selections;
const promise = wrapWithAbbreviation({ abbreviation });
if (!promise) {