mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
32
extensions/mssql/src/test/util/utils.test.ts
Normal file
32
extensions/mssql/src/test/util/utils.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user