Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/unit/azureController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { expect } from "chai";
import { AzureController } from "../../src/azure/azureController";
import * as assert from "assert";
import * as sinon from "sinon";

suite("Azure Controller Tests", () => {
Expand All @@ -23,30 +23,30 @@ suite("Azure Controller Tests", () => {
test("isTokenValid should return false for undefined token", () => {
const actual = AzureController.isTokenValid(undefined, currentTime);
const expected = false;
assert.strictEqual(actual, expected);
expect(actual).to.equal(expected);
});

test("isTokenValid should return false for empty token", () => {
const actual = AzureController.isTokenValid("", currentTime);
const expected = false;
assert.strictEqual(actual, expected);
expect(actual).to.equal(expected);
});

test("isTokenValid should return false for undefined expiresOn", () => {
const actual = AzureController.isTokenValid("token", undefined);
const expected = false;
assert.strictEqual(actual, expected);
expect(actual).to.equal(expected);
});

test("isTokenValid should return false for expired token", () => {
const actual = AzureController.isTokenValid("token", currentTime - 4 * 60);
const expected = false;
assert.strictEqual(actual, expected);
expect(actual).to.equal(expected);
});

test("isTokenValid should return true for valid token", () => {
const actual = AzureController.isTokenValid("token", currentTime + 3 * 60);
const expected = true;
assert.strictEqual(actual, expected);
expect(actual).to.equal(expected);
});
});
4 changes: 2 additions & 2 deletions test/unit/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as assert from "assert";
import { expect } from "chai";

import ConfigUtils from "../../src/configurations/configUtils";

Expand All @@ -12,7 +12,7 @@ suite("Config Tests", () => {
return new Promise((resolve, reject) => {
let config = new ConfigUtils();
let serviceDownloawUrl = config.getSqlToolsServiceDownloadUrl;
assert.notEqual(serviceDownloawUrl, undefined);
expect(serviceDownloawUrl).to.not.equal(undefined);
done();
});
});
Expand Down
12 changes: 8 additions & 4 deletions test/unit/databaseObjectSearchService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import { expect } from "chai";
import * as chai from "chai";
import sinonChai from "sinon-chai";
import * as sinon from "sinon";
import SqlToolsServiceClient from "../../src/languageservice/serviceclient";
import {
Expand All @@ -13,6 +15,8 @@ import {
import { DatabaseObjectSearchService } from "../../src/services/databaseObjectSearchService";
import { ObjectMetadata } from "vscode-mssql";

chai.use(sinonChai);

suite("DatabaseObjectSearchService Tests", () => {
let sandbox: sinon.SinonSandbox;
let client: sinon.SinonStubbedInstance<SqlToolsServiceClient>;
Expand Down Expand Up @@ -62,7 +66,7 @@ suite("DatabaseObjectSearchService Tests", () => {
expect(result.objects.map((o) => o.name).sort()).to.deep.equal(
["Customers", "vTopCustomers"].sort(),
);
sinon.assert.calledOnceWithExactly(client.sendRequest, MetadataQueryRequest.type, {
expect(client.sendRequest).to.have.been.calledOnceWithExactly(MetadataQueryRequest.type, {
ownerUri: "test_uri",
});
});
Expand All @@ -83,7 +87,7 @@ suite("DatabaseObjectSearchService Tests", () => {
await searchService.warmCache("uri1");
await searchService.searchObjects("uri1", "thing");

sinon.assert.calledOnceWithExactly(client.sendRequest, MetadataQueryRequest.type, {
expect(client.sendRequest).to.have.been.calledOnceWithExactly(MetadataQueryRequest.type, {
ownerUri: "uri1",
});
});
Expand All @@ -105,7 +109,7 @@ suite("DatabaseObjectSearchService Tests", () => {
DatabaseObjectSearchService.clearCache("uri2");
await searchService.searchObjects("uri2", "x");

sinon.assert.calledTwice(client.sendRequest);
expect(client.sendRequest).to.have.been.calledTwice;
expect(client.sendRequest.firstCall.args).to.deep.equal([
MetadataQueryRequest.type,
{ ownerUri: "uri2" },
Expand All @@ -122,7 +126,7 @@ suite("DatabaseObjectSearchService Tests", () => {
expect(result.success).to.be.false;
expect(result.objects).to.have.lengthOf(0);
expect(result.error || "").to.match(/Search term cannot be empty/);
sinon.assert.notCalled(client.sendRequest);
expect(client.sendRequest).to.not.have.been.called;
});

test("maps metadata type names to friendly labels", async () => {
Expand Down
Loading