Files
azuredatastudio/extensions/mssql/src/test/util/utils.test.ts
Sai Avishkar Sreerama acfa93fbb8 Enabling options tab for database properties (#23448)
* Initial commit for adding a basic general tab for the database properties

* Refactoring for dialog inputs

* removed properties nodeType and using database node and additional cleanup, diabling the functionality.

* Changes according to STS data fetch

* Reuse database Dialog

* Undo contract file change

* more refactoring

* fetched scrollbar fix into this PR

* Tabbed panel is being used for horizontal tabs

* stying fix for general tab button

* final commit for today :)

* Updates according to STS changes

* missed updates

* Refactored updates

* moved options as discussed and added collapsible sections... need to fix scroll bar

* Fixing the horizontal scroll bar of tabbedpanel

* initial updates

* need to fix the error!

* rror fixed and options are loading with sample values

* need to load real values for all felds and map values to dropdown options

* Dd loading correctly, need to add validation to recovery field and save options back

* refactor

* removing nullable property

* All changes done except recoveryTime validation

* Refactoring

* all values are saving as expected, isDirty flag is fixed. Todo: recovery validation and tests

* added general section for the options tab

* modifying pageVerify and userAccess to string array

* updates to general section of options tb

* disabling couple of general properties for MI

* Adding server edition conditions and toggling the UI options

* adding numeric validation to the recovey time

* Removing serveInfo logic and using the unsupported options approach from STS

* addressing comments and little code refactor

* changes with nullOrUndefined helper method

* replacing dropdowns with checkboxes

* adding unit test for helper method

* removed commented sample code and added comments
2023-07-06 18:22:20 -05:00

39 lines
2.0 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { convertNumToTwoDecimalStringInMB, escapeSingleQuotes } from '../../objectManagement/utils';
import 'mocha';
import * as should from 'should';
describe('escapeSingleQuotes Method Tests', () => {
it('Should return original string if no single quotes', function (): void {
const dbName = "My Database";
const testString: string = "Server/Database[@Name='My Database']";
const ret = `Server/Database[@Name='${escapeSingleQuotes(dbName)}']`;
should(ret).equal(testString);
});
it('Should return original string if it contains single quotes', function (): void {
const dbName = "My'Database";
const testString: string = "Server/Database[@Name='My'Database']";
const ret = `Server/Database[@Name='${escapeSingleQuotes(dbName)}']`;
should(ret).equal(testString);
});
it('Should return escaped original string if it contains an escaped single quote', function (): void {
const dbName = "My Database\'WithEscapedSingleQuote";
const testString: string = "Server/Database[@Name='My Database\'WithEscapedSingleQuote']";
const ret = `Server/Database[@Name='${escapeSingleQuotes(dbName)}']`;
should(ret).equal(testString);
});
it('convertNumToTwoDecimalStringInMB function should convert and return the passed integer value to string with two decimals and in MB units', () => {
should(convertNumToTwoDecimalStringInMB(0)).equals('0.00 MB', 'should return string value In MB with two decimals');
should(convertNumToTwoDecimalStringInMB(10)).equals('10.00 MB', 'should return string value In MB with two decimals');
should(convertNumToTwoDecimalStringInMB(10.23)).equals('10.23 MB', 'should return string value In MB with two decimals');
});
});