Respect selfClosingStyle when joining tags Fixes #44417

This commit is contained in:
Ramya Achutha Rao
2018-03-26 15:04:51 -07:00
parent 84318e5892
commit 871e610848
2 changed files with 40 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
import 'mocha';
import * as assert from 'assert';
import { Selection } from 'vscode';
import { Selection, workspace } from 'vscode';
import { withRandomFileEditor, closeAllEditors } from './testUtils';
import { removeTag } from '../removeTag';
import { updateTag } from '../updateTag';
@@ -14,7 +14,10 @@ import { splitJoinTag } from '../splitJoinTag';
import { mergeLines } from '../mergeLines';
suite('Tests for Emmet actions on html tags', () => {
teardown(closeAllEditors);
teardown(() => {
// Reset config and close all editors
return workspace.getConfiguration('emmet').update('syntaxProfiles', {}).then(closeAllEditors);
});
const contents = `
<div class="hello">
@@ -102,6 +105,32 @@ suite('Tests for Emmet actions on html tags', () => {
});
});
test('split/join tag in jsx with xhtml self closing tag', () => {
const expectedContents = `
<div class="hello">
<ul>
<li><span /></li>
<li><span>There</span></li>
<div><li><span>Bye</span></li></div>
</ul>
<span></span>
</div>
`;
return workspace.getConfiguration('emmet').update('syntaxProfiles', {jsx: {selfClosingStyle: 'xhtml'}}).then(() =>{
return withRandomFileEditor(contents, 'jsx', (editor, doc) => {
editor.selections = [
new Selection(3, 17, 3, 17), // join tag
new Selection(7, 5, 7, 5), // split tag
];
return splitJoinTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve()
});
});
});
});
test('match tag with mutliple cursors', () => {
return withRandomFileEditor(contents, 'html', (editor, doc) => {
editor.selections = [