From 0b3c33b801672d55724c4eb8f15ecc78d4024089 Mon Sep 17 00:00:00 2001 From: Matthew Kwiecien Date: Sun, 10 Feb 2019 10:09:56 -0600 Subject: [PATCH] Adding unit tests to check for className when file is jsx. --- .../src/test/wrapWithAbbreviation.test.ts | 380 ++++++++++-------- 1 file changed, 210 insertions(+), 170 deletions(-) diff --git a/extensions/emmet/src/test/wrapWithAbbreviation.test.ts b/extensions/emmet/src/test/wrapWithAbbreviation.test.ts index 9fc924508e2..fa15a678751 100644 --- a/extensions/emmet/src/test/wrapWithAbbreviation.test.ts +++ b/extensions/emmet/src/test/wrapWithAbbreviation.test.ts @@ -63,6 +63,22 @@ const wrapInlineElementExpectedFormatFalse = ` `; +const wrapMultiLineJsxExpected = ` + +`; + +const wrapIndividualLinesJsxExpected = ` + +`; + suite('Tests for Wrap with Abbreviations', () => { teardown(closeAllEditors); @@ -135,219 +151,219 @@ suite('Tests for Wrap with Abbreviations', () => { `; - return withRandomFileEditor(contents, 'html', (editor, _) => { - editor.selections = [new Selection(2, 0, 2, 0)]; - const promise = wrapWithAbbreviation({ abbreviation: 'li.hello|c' }); - if (!promise) { - assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); - return Promise.resolve(); - } - return promise.then(() => { - assert.equal(editor.document.getText(), expectedContents); - return Promise.resolve(); - }); + return withRandomFileEditor(contents, 'html', (editor, _) => { + editor.selections = [new Selection(2, 0, 2, 0)]; + const promise = wrapWithAbbreviation({ abbreviation: 'li.hello|c' }); + if (!promise) { + assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); + return Promise.resolve(); + } + return promise.then(() => { + assert.equal(editor.document.getText(), expectedContents); + return Promise.resolve(); }); }); +}); - test('Wrap with abbreviation entire node when cursor is on opening tag', () => { - const contents = ` +test('Wrap with abbreviation entire node when cursor is on opening tag', () => { + const contents = ` + +`; + const expectedContents = ` +
- `; - const expectedContents = ` -
- -
- `; +
+`; - return withRandomFileEditor(contents, 'html', (editor, _) => { - editor.selections = [new Selection(1, 1, 1, 1)]; - const promise = wrapWithAbbreviation({ abbreviation: 'div' }); - if (!promise) { - assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); - return Promise.resolve(); - } - return promise.then(() => { - assert.equal(editor.document.getText(), expectedContents); - return Promise.resolve(); - }); + return withRandomFileEditor(contents, 'html', (editor, _) => { + editor.selections = [new Selection(1, 1, 1, 1)]; + const promise = wrapWithAbbreviation({ abbreviation: 'div' }); + if (!promise) { + assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); + return Promise.resolve(); + } + return promise.then(() => { + assert.equal(editor.document.getText(), expectedContents); + return Promise.resolve(); }); }); +}); - test('Wrap with abbreviation entire node when cursor is on closing tag', () => { - const contents = ` +test('Wrap with abbreviation entire node when cursor is on closing tag', () => { + const contents = ` + +`; + const expectedContents = ` +
- `; - const expectedContents = ` -
- -
- `; +
+`; - return withRandomFileEditor(contents, 'html', (editor, _) => { - editor.selections = [new Selection(3, 1, 3, 1)]; - const promise = wrapWithAbbreviation({ abbreviation: 'div' }); - if (!promise) { - assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); - return Promise.resolve(); - } - return promise.then(() => { - assert.equal(editor.document.getText(), expectedContents); - return Promise.resolve(); - }); + return withRandomFileEditor(contents, 'html', (editor, _) => { + editor.selections = [new Selection(3, 1, 3, 1)]; + const promise = wrapWithAbbreviation({ abbreviation: 'div' }); + if (!promise) { + assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); + return Promise.resolve(); + } + return promise.then(() => { + assert.equal(editor.document.getText(), expectedContents); + return Promise.resolve(); }); }); +}); - test('Wrap with multiline abbreviation doesnt add extra spaces', () => { - // Issue #29898 - const contents = ` - hello - `; - const expectedContents = ` - - `; +test('Wrap with multiline abbreviation doesnt add extra spaces', () => { + // Issue #29898 + const contents = ` +hello +`; + const expectedContents = ` + +`; - return withRandomFileEditor(contents, 'html', (editor, _) => { - editor.selections = [new Selection(1, 2, 1, 2)]; - const promise = wrapWithAbbreviation({ abbreviation: 'ul>li>a' }); - if (!promise) { - assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); - return Promise.resolve(); - } - return promise.then(() => { - assert.equal(editor.document.getText(), expectedContents); - return Promise.resolve(); - }); + return withRandomFileEditor(contents, 'html', (editor, _) => { + editor.selections = [new Selection(1, 2, 1, 2)]; + const promise = wrapWithAbbreviation({ abbreviation: 'ul>li>a' }); + if (!promise) { + assert.equal(1, 2, 'Wrap returned undefined instead of promise.'); + return Promise.resolve(); + } + return promise.then(() => { + assert.equal(editor.document.getText(), expectedContents); + return Promise.resolve(); }); }); +}); - test('Wrap individual lines with abbreviation', () => { - const contents = ` - +test('Wrap individual lines with abbreviation', () => { + const contents = ` + `; - const wrapIndividualLinesExpected = ` -