mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 01:25:36 -05:00
Inital platform relayering (#6385)
* moving test files and inital refactoring * relayer extension host code * fix imports * make insights work * relayer dashboard * relayer notebooks * moveing more code around * formatting * accept angular as browser * fix serializer * add missing files * remove declarations from extensions * fix build errors * more relayering * change urls to relative to help code relayering * remove layering to prep for merge * fix hygiene errors * fix hygiene errors * fix tests
This commit is contained in:
42
src/sql/base/test/browser/ui/table/gridFormatters.test.ts
Normal file
42
src/sql/base/test/browser/ui/table/gridFormatters.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as SharedServices from 'sql/base/browser/ui/table/formatters';
|
||||
|
||||
const testText = '<div>test text</div>';
|
||||
|
||||
suite('Grid shared services tests', () => {
|
||||
test('textFormatter should encode HTML when formatting a DBCellValue object', () => {
|
||||
// If I format a DBCellValue object that contains HTML
|
||||
let cellValue = new SharedServices.DBCellValue();
|
||||
cellValue.displayValue = testText;
|
||||
cellValue.isNull = false;
|
||||
let formattedHtml = SharedServices.textFormatter(undefined, undefined, cellValue, undefined, undefined);
|
||||
let hyperlink = SharedServices.hyperLinkFormatter(undefined, undefined, cellValue, undefined, undefined);
|
||||
|
||||
// Then the result is HTML for a span element containing the cell value's display value as plain text
|
||||
verifyFormattedHtml(formattedHtml, testText);
|
||||
});
|
||||
|
||||
test('textFormatter should encode HTML when formatting a string', () => {
|
||||
// If I format a string that contains HTML
|
||||
let formattedHtml = SharedServices.textFormatter(undefined, undefined, testText, undefined, undefined);
|
||||
|
||||
// Then the result is HTML for a span element containing the given text as plain text
|
||||
verifyFormattedHtml(formattedHtml, testText);
|
||||
});
|
||||
});
|
||||
|
||||
function verifyFormattedHtml(formattedHtml: string, expectedText: string): void {
|
||||
// Create an element containing the span returned by the format call
|
||||
let element = document.createElement('div');
|
||||
element.innerHTML = formattedHtml;
|
||||
let spanElement = element.children[0];
|
||||
|
||||
// Verify that the span element's text, not its innerHTML, matches the expected text
|
||||
assert.equal(spanElement.textContent, testText);
|
||||
assert.notEqual(spanElement.innerHTML, testText);
|
||||
}
|
||||
Reference in New Issue
Block a user