From a6ec94c6a4917adb6347afa48ec14b9a54256d35 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 May 2017 11:02:28 -0400 Subject: [PATCH 1/6] Replace let with const where necessary --- .../teamservicesclient.integration.test.ts | 22 +- .../servercontext.integration.test.ts | 6 +- test-integration/helpers-integration/mocks.ts | 6 +- .../helpers/credentialmanager.test.ts | 12 +- .../services/build.integration.test.ts | 34 +-- .../services/gitvc.integration.test.ts | 26 +- test/contexts/externalcontext.test.ts | 64 +++-- test/contexts/gitcontext.test.ts | 53 ++-- test/contexts/servercontext.test.ts | 6 +- test/helpers/logger.test.ts | 4 +- test/helpers/utils.test.ts | 82 +++--- test/info/credentialinfo.test.ts | 30 +- test/info/repositoryinfo.test.ts | 14 +- test/info/userinfo.test.ts | 2 +- test/services/build.test.ts | 12 +- test/services/gitvc.test.ts | 28 +- test/services/workitemtracking.test.ts | 28 +- test/tfvc/commands/add.test.ts | 152 +++++------ test/tfvc/commands/argumentbuilder.test.ts | 56 ++-- test/tfvc/commands/checkin.test.ts | 106 ++++---- test/tfvc/commands/delete.test.ts | 188 ++++++------- test/tfvc/commands/findconflicts.test.ts | 82 +++--- test/tfvc/commands/findworkspace.test.ts | 110 ++++---- test/tfvc/commands/getfilecontent.test.ts | 104 +++---- test/tfvc/commands/getinfo.test.ts | 114 ++++---- test/tfvc/commands/getversion.test.ts | 56 ++-- test/tfvc/commands/rename.test.ts | 168 ++++++------ test/tfvc/commands/resolveconflicts.test.ts | 112 ++++---- test/tfvc/commands/status.test.ts | 128 ++++----- test/tfvc/commands/sync.test.ts | 256 +++++++++--------- test/tfvc/commands/undo.test.ts | 240 ++++++++-------- test/tfvc/scm/resourcegroup.test.ts | 6 +- test/tfvc/tfvcerror.test.ts | 16 +- test/tfvc/tfvcversion.test.ts | 30 +- 34 files changed, 1188 insertions(+), 1165 deletions(-) diff --git a/test-integration/clients/teamservicesclient.integration.test.ts b/test-integration/clients/teamservicesclient.integration.test.ts index 862a7596bb..b226ac11e2 100644 --- a/test-integration/clients/teamservicesclient.integration.test.ts +++ b/test-integration/clients/teamservicesclient.integration.test.ts @@ -17,8 +17,8 @@ import { TeamServicesApi } from "../../src/clients/teamservicesclient"; describe("TeamServicesClient-Integration", function() { this.timeout(TestSettings.SuiteTimeout); //http://mochajs.org/#timeouts - let credentialManager: CredentialManager = new CredentialManager(); - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const credentialManager: CredentialManager = new CredentialManager(); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); before(function() { UserAgentProvider.VSCodeVersion = "0.0.0"; @@ -35,8 +35,8 @@ describe("TeamServicesClient-Integration", function() { it("should verify repositoryClient.getVstsInfo", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteRepositoryUrl, [CredentialManager.GetCredentialHandler()]); - let repoInfo: any = await repositoryClient.getVstsInfo(); + const repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteRepositoryUrl, [CredentialManager.GetCredentialHandler()]); + const repoInfo: any = await repositoryClient.getVstsInfo(); assert.isNotNull(repoInfo, "repoInfo was null when it shouldn't have been"); assert.equal(repoInfo.serverUrl, TestSettings.AccountUrl); assert.equal(repoInfo.collection.name, TestSettings.CollectionName); @@ -49,8 +49,8 @@ describe("TeamServicesClient-Integration", function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts try { - let repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteRepositoryUrl + "1", [CredentialManager.GetCredentialHandler()]); - let repoInfo: any = await repositoryClient.getVstsInfo(); + const repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteRepositoryUrl + "1", [CredentialManager.GetCredentialHandler()]); + const repoInfo: any = await repositoryClient.getVstsInfo(); assert.isNull(repoInfo); } catch (err) { assert.isNotNull(err, "err was null when it shouldn't have been"); @@ -61,8 +61,8 @@ describe("TeamServicesClient-Integration", function() { it("should verify accountClient.connect", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let accountClient: TeamServicesApi = new TeamServicesApi(TestSettings.AccountUrl, [CredentialManager.GetCredentialHandler()]); - let settings: any = await accountClient.connect(); + const accountClient: TeamServicesApi = new TeamServicesApi(TestSettings.AccountUrl, [CredentialManager.GetCredentialHandler()]); + const settings: any = await accountClient.connect(); //console.log(settings); assert.isNotNull(settings, "settings was null when it shouldn't have been"); assert.isNotNull(settings.providerDisplayName); @@ -74,9 +74,9 @@ describe("TeamServicesClient-Integration", function() { it("should verify repositoryClient.validateTfvcCollectionUrl", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let success: boolean; + let success: boolean = false; try { - let repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteTfvcRepositoryUrl, [CredentialManager.GetCredentialHandler()]); + const repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteTfvcRepositoryUrl, [CredentialManager.GetCredentialHandler()]); await repositoryClient.validateTfvcCollectionUrl(); success = true; } finally { @@ -88,7 +88,7 @@ describe("TeamServicesClient-Integration", function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts try { - let repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteTfvcRepositoryUrl + "1", [CredentialManager.GetCredentialHandler()]); + const repositoryClient: TeamServicesApi = new TeamServicesApi(TestSettings.RemoteTfvcRepositoryUrl + "1", [CredentialManager.GetCredentialHandler()]); await repositoryClient.validateTfvcCollectionUrl(); assert.fail(undefined, undefined, "validateTfvcCollectionUrl should have thrown but didn't."); //It shouldn't get here } catch (err) { diff --git a/test-integration/contexts/servercontext.integration.test.ts b/test-integration/contexts/servercontext.integration.test.ts index ba95ef0be1..a2557387a8 100644 --- a/test-integration/contexts/servercontext.integration.test.ts +++ b/test-integration/contexts/servercontext.integration.test.ts @@ -15,8 +15,8 @@ import { TeamServerContext } from "../../src/contexts/servercontext"; describe("ServerContext-Integration", function() { this.timeout(TestSettings.SuiteTimeout); - let credentialManager: CredentialManager = new CredentialManager(); - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const credentialManager: CredentialManager = new CredentialManager(); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); before(function() { return credentialManager.StoreCredentials(TestSettings.Account, TestSettings.AccountUser, TestSettings.Password); @@ -32,7 +32,7 @@ describe("ServerContext-Integration", function() { it("should verify ServerContext CredentialHandler, UserInfo", function(done) { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; diff --git a/test-integration/helpers-integration/mocks.ts b/test-integration/helpers-integration/mocks.ts index 35ea966359..9e00e4a50f 100644 --- a/test-integration/helpers-integration/mocks.ts +++ b/test-integration/helpers-integration/mocks.ts @@ -10,12 +10,12 @@ import { TestSettings } from "./testsettings"; export class Mocks { - public static TeamServerContext(repositoryUrl: string) : TeamServerContext { + public static TeamServerContext(repositoryUrl: string): TeamServerContext { return new TeamServerContext(repositoryUrl); } - public static RepositoryInfo() : RepositoryInfo { - let repositoryInfo : any = { + public static RepositoryInfo(): RepositoryInfo { + const repositoryInfo: any = { "serverUrl":"undefined", "collection":{ "id":"undefined", diff --git a/test-integration/helpers/credentialmanager.test.ts b/test-integration/helpers/credentialmanager.test.ts index a13f6212f9..5e23c90167 100644 --- a/test-integration/helpers/credentialmanager.test.ts +++ b/test-integration/helpers/credentialmanager.test.ts @@ -17,8 +17,8 @@ import { Constants } from "../../src/helpers/constants"; describe("CredentialManager-Integration", function() { this.timeout(TestSettings.SuiteTimeout); //http://mochajs.org/#timeouts - let credentialManager: CredentialManager = new CredentialManager(); - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const credentialManager: CredentialManager = new CredentialManager(); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); before(function() { // @@ -50,10 +50,10 @@ describe("CredentialManager-Integration", function() { it("should verify store, get, remove credentials for Team Foundation Server", async function() { try { - let ctx: TeamServerContext = Mocks.TeamServerContext("http://java-tfs2015:8081/tfs/DefaultCollection/_git/GitJava"); - let account: string = "java-tfs2015:8081"; - let username: string = "domain\\user"; - let password: string = "password"; + const ctx: TeamServerContext = Mocks.TeamServerContext("http://java-tfs2015:8081/tfs/DefaultCollection/_git/GitJava"); + const account: string = "java-tfs2015:8081"; + const username: string = "domain\\user"; + const password: string = "password"; await credentialManager.StoreCredentials(account, username, password); let credInfo: CredentialInfo = await credentialManager.GetCredentials(ctx); diff --git a/test-integration/services/build.integration.test.ts b/test-integration/services/build.integration.test.ts index e8d4749d69..d8d6106259 100644 --- a/test-integration/services/build.integration.test.ts +++ b/test-integration/services/build.integration.test.ts @@ -18,8 +18,8 @@ import { WellKnownRepositoryTypes } from "../../src/helpers/constants"; describe("BuildService-Integration", function() { this.timeout(TestSettings.SuiteTimeout); - let credentialManager: CredentialManager = new CredentialManager(); - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const credentialManager: CredentialManager = new CredentialManager(); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); before(function() { UserAgentProvider.VSCodeVersion = "0.0.0"; @@ -36,13 +36,13 @@ describe("BuildService-Integration", function() { it("should verify BuildService.GetBuildDefinitions", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: BuildService = new BuildService(ctx); - let definitions = await svc.GetBuildDefinitions(TestSettings.TeamProject); + const svc: BuildService = new BuildService(ctx); + const definitions = await svc.GetBuildDefinitions(TestSettings.TeamProject); assert.isNotNull(definitions, "definitions was null when it shouldn't have been"); //console.log(definitions.length); expect(definitions.length).to.be.at.least(1); @@ -51,13 +51,13 @@ describe("BuildService-Integration", function() { it("should verify BuildService.GetBuildById", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: BuildService = new BuildService(ctx); - let build: Build = await svc.GetBuildById(TestSettings.BuildId); + const svc: BuildService = new BuildService(ctx); + const build: Build = await svc.GetBuildById(TestSettings.BuildId); assert.isNotNull(build, "build was null when it shouldn't have been"); //console.log(definitions.length); expect(build.buildNumber).to.equal(TestSettings.BuildId.toString()); @@ -66,13 +66,13 @@ describe("BuildService-Integration", function() { it("should verify BuildService.GetBuilds", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: BuildService = new BuildService(ctx); - let builds = await svc.GetBuilds(TestSettings.TeamProject); + const svc: BuildService = new BuildService(ctx); + const builds = await svc.GetBuilds(TestSettings.TeamProject); assert.isNotNull(builds, "builds was null when it shouldn't have been"); //console.log(builds.length); expect(builds.length).to.be.at.least(1); @@ -81,13 +81,13 @@ describe("BuildService-Integration", function() { it("should verify BuildService.GetBuildsByDefinitionId", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: BuildService = new BuildService(ctx); - let builds: Build[] = await svc.GetBuildsByDefinitionId(TestSettings.TeamProject, TestSettings.BuildDefinitionId); + const svc: BuildService = new BuildService(ctx); + const builds: Build[] = await svc.GetBuildsByDefinitionId(TestSettings.TeamProject, TestSettings.BuildDefinitionId); assert.isNotNull(builds, "builds was null when it shouldn't have been"); //console.log(definitions.length); expect(builds.length).to.equal(1); @@ -96,13 +96,13 @@ describe("BuildService-Integration", function() { it("should verify BuildService.GetBuildBadge", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: BuildService = new BuildService(ctx); - let badge: BuildBadge = await svc.GetBuildBadge(TestSettings.TeamProject, WellKnownRepositoryTypes.TfsGit, TestSettings.RepositoryId, "refs/heads/master"); + const svc: BuildService = new BuildService(ctx); + const badge: BuildBadge = await svc.GetBuildBadge(TestSettings.TeamProject, WellKnownRepositoryTypes.TfsGit, TestSettings.RepositoryId, "refs/heads/master"); assert.isNotNull(badge, "badge was null when it shouldn't have been"); }); diff --git a/test-integration/services/gitvc.integration.test.ts b/test-integration/services/gitvc.integration.test.ts index 833082fd55..a7f8e4d689 100644 --- a/test-integration/services/gitvc.integration.test.ts +++ b/test-integration/services/gitvc.integration.test.ts @@ -17,8 +17,8 @@ import { GitVcService, PullRequestScore } from "../../src/services/gitvc"; describe("GitVcService-Integration", function() { this.timeout(TestSettings.SuiteTimeout); - let credentialManager: CredentialManager = new CredentialManager(); - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const credentialManager: CredentialManager = new CredentialManager(); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); before(function() { UserAgentProvider.VSCodeVersion = "0.0.0"; @@ -35,13 +35,13 @@ describe("GitVcService-Integration", function() { it("should verify GitVcService.GetRepositories", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: GitVcService = new GitVcService(ctx); - let repos: GitRepository[] = await svc.GetRepositories(TestSettings.TeamProject); + const svc: GitVcService = new GitVcService(ctx); + const repos: GitRepository[] = await svc.GetRepositories(TestSettings.TeamProject); assert.isNotNull(repos, "repos was null when it shouldn't have been"); //console.log(repos.length); expect(repos.length).to.equal(2); @@ -50,13 +50,13 @@ describe("GitVcService-Integration", function() { it("should verify GitVcService.GetPullRequests", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: GitVcService = new GitVcService(ctx); - let requests: GitPullRequest[] = await svc.GetPullRequests(ctx.RepoInfo.RepositoryId); + const svc: GitVcService = new GitVcService(ctx); + const requests: GitPullRequest[] = await svc.GetPullRequests(ctx.RepoInfo.RepositoryId); assert.isNotNull(requests, "requests was null when it shouldn't have been"); //console.log(requests.length); expect(requests.length).to.equal(4); @@ -65,20 +65,20 @@ describe("GitVcService-Integration", function() { it("should verify GitVcService.GetPullRequestScore", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: GitVcService = new GitVcService(ctx); - let requests: GitPullRequest[] = await svc.GetPullRequests(ctx.RepoInfo.RepositoryId); - let totals = []; + const svc: GitVcService = new GitVcService(ctx); + const requests: GitPullRequest[] = await svc.GetPullRequests(ctx.RepoInfo.RepositoryId); + const totals = []; requests.forEach((request) => { totals.push({ "id" : request.pullRequestId, "score" : GitVcService.GetPullRequestScore(request) }); }); assert.equal(totals.length, 4); for (let index = 0; index < totals.length; index++) { - let element: any = totals[index]; + const element: any = totals[index]; if (element.id === 5) { assert.equal(element.score, PullRequestScore.Succeeded); continue; } if (element.id === 4) { assert.equal(element.score, PullRequestScore.Waiting); continue; } if (element.id === 3) { assert.equal(element.score, PullRequestScore.Failed); continue; } diff --git a/test/contexts/externalcontext.test.ts b/test/contexts/externalcontext.test.ts index 508e786ae0..7c929d8a0c 100644 --- a/test/contexts/externalcontext.test.ts +++ b/test/contexts/externalcontext.test.ts @@ -5,15 +5,15 @@ "use strict"; import { assert } from "chai"; -const path = require("path"); +import * as path from "path"; import { RepositoryType } from "../../src/contexts/repositorycontext"; import { ExternalContext } from "../../src/contexts/externalcontext"; import { SettingsMock } from "./contexthelper"; describe("ExternalContext", function() { - let TEST_REPOS_FOLDER: string = "testrepos"; - let DOT_GIT_FOLDER: string = "dotgit"; + const TEST_REPOS_FOLDER: string = "testrepos"; + const DOT_GIT_FOLDER: string = "dotgit"; beforeEach(function() { // console.log("__dirname: " + __dirname); @@ -21,7 +21,7 @@ describe("ExternalContext", function() { it("should verify all undefined properties for undefined rootPath", function() { //Verify an undefined path does not set any values - let ctx: ExternalContext = new ExternalContext(undefined); + const ctx: ExternalContext = new ExternalContext(undefined); assert.equal(ctx.CurrentRef, undefined); assert.equal(ctx.CurrentBranch, undefined); @@ -36,10 +36,10 @@ describe("ExternalContext", function() { }); it("should verify values for valid rootPath path", function() { - let repoName: string = "gitrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - //let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); - let ctx: ExternalContext = new ExternalContext(repoPath); + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + //const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const ctx: ExternalContext = new ExternalContext(repoPath); assert.equal(ctx.CurrentRef, undefined); assert.equal(ctx.CurrentBranch, undefined); @@ -54,13 +54,21 @@ describe("ExternalContext", function() { assert.equal(ctx.RepoFolder, repoPath); }); + it("should cover dispose", function() { + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + //const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const ctx: ExternalContext = new ExternalContext(repoPath); + ctx.dispose(); + }); + it("should verify values for valid rootPath path and settings", async function() { - let repoName: string = "gitrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let ctx: ExternalContext = new ExternalContext(repoPath); + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const ctx: ExternalContext = new ExternalContext(repoPath); - let mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, "https://xplatalm.visualstudio.com", "L2.VSCodeExtension.RC", undefined); - let initialized: Boolean = await ctx.Initialize(mock); + const mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, "https://xplatalm.visualstudio.com", "L2.VSCodeExtension.RC", undefined); + const initialized: Boolean = await ctx.Initialize(mock); assert.isTrue(initialized); assert.isTrue(ctx.IsTeamServices); @@ -71,12 +79,12 @@ describe("ExternalContext", function() { }); it("should verify initialize is false for missing RemoteUrl", async function() { - let repoName: string = "gitrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let ctx: ExternalContext = new ExternalContext(repoPath); + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const ctx: ExternalContext = new ExternalContext(repoPath); - let mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, undefined, "L2.VSCodeExtension.RC", undefined); - let initialized: Boolean = await ctx.Initialize(mock); + const mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, undefined, "L2.VSCodeExtension.RC", undefined); + const initialized: Boolean = await ctx.Initialize(mock); assert.isFalse(initialized); assert.isFalse(ctx.IsSsh); @@ -88,12 +96,12 @@ describe("ExternalContext", function() { }); it("should verify initialize is false for missing TeamProject", async function() { - let repoName: string = "gitrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let ctx: ExternalContext = new ExternalContext(repoPath); + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const ctx: ExternalContext = new ExternalContext(repoPath); - let mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, "https://xplatalm.visualstudio.com", undefined, undefined); - let initialized: Boolean = await ctx.Initialize(mock); + const mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, "https://xplatalm.visualstudio.com", undefined, undefined); + const initialized: Boolean = await ctx.Initialize(mock); assert.isFalse(initialized); assert.isFalse(ctx.IsSsh); @@ -105,12 +113,12 @@ describe("ExternalContext", function() { }); it("should verify initialize is false for missing RemoteUrl and TeamProject", async function() { - let repoName: string = "gitrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let ctx: ExternalContext = new ExternalContext(repoPath); + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const ctx: ExternalContext = new ExternalContext(repoPath); - let mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, undefined, undefined, undefined); - let initialized: Boolean = await ctx.Initialize(mock); + const mock: SettingsMock = new SettingsMock(false, undefined, undefined, 1, undefined, undefined, undefined); + const initialized: Boolean = await ctx.Initialize(mock); assert.isFalse(initialized); assert.isFalse(ctx.IsSsh); diff --git a/test/contexts/gitcontext.test.ts b/test/contexts/gitcontext.test.ts index c6540c41d9..16a62d5758 100644 --- a/test/contexts/gitcontext.test.ts +++ b/test/contexts/gitcontext.test.ts @@ -5,14 +5,14 @@ "use strict"; import { assert } from "chai"; -const path = require("path"); +import * as path from "path"; import { GitContext } from "../../src/contexts/gitcontext"; import { RepositoryType } from "../../src/contexts/repositorycontext"; describe("GitContext", function() { - let TEST_REPOS_FOLDER: string = "testrepos"; - let DOT_GIT_FOLDER: string = "dotgit"; + const TEST_REPOS_FOLDER: string = "testrepos"; + const DOT_GIT_FOLDER: string = "dotgit"; beforeEach(function() { // console.log("__dirname: " + __dirname); @@ -20,7 +20,7 @@ describe("GitContext", function() { it("should verify all undefined properties for undefined GitContext path", function() { //Verify an undefined path does not set any values - let gc: GitContext = new GitContext(undefined); + const gc: GitContext = new GitContext(undefined); assert.equal(gc.CurrentBranch, undefined); assert.equal(gc.RemoteUrl, undefined); @@ -30,7 +30,7 @@ describe("GitContext", function() { it("should verify undefined values for invalid GitContext path", function() { //Actually pass a value to constructor (instead of undefined), values should be undefined - let gc: GitContext = new GitContext(__dirname + "invalid"); + const gc: GitContext = new GitContext(__dirname + "invalid"); assert.equal(gc.CurrentBranch, undefined); assert.equal(gc.RemoteUrl, undefined); @@ -39,14 +39,19 @@ describe("GitContext", function() { }); it("should verify initialize returns true", async function() { - let gc: GitContext = new GitContext(__dirname); + const gc: GitContext = new GitContext(__dirname); assert.isTrue(await gc.Initialize()); }); + it("should cover dispose", async function() { + const gc: GitContext = new GitContext(__dirname); + gc.dispose(); + }); + it("should verify repository with an empty origin remote", function() { - let repoName: string = "emptyconfig"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const repoName: string = "emptyconfig"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); assert.equal(gc.CurrentBranch, undefined); assert.equal(gc.CurrentRef, undefined); @@ -60,9 +65,9 @@ describe("GitContext", function() { }); it("should verify GitHub origin remote", function() { - let repoName: string = "githubrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const repoName: string = "githubrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); assert.equal(gc.CurrentBranch, "master"); assert.equal(gc.CurrentRef, "refs/heads/master"); @@ -76,9 +81,9 @@ describe("GitContext", function() { }); it("should verify TeamServices origin remote", function() { - let repoName: string = "gitrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const repoName: string = "gitrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); assert.equal(gc.CurrentBranch, "jeyou/approved-pr"); assert.equal(gc.CurrentRef, "refs/heads/jeyou/approved-pr"); @@ -93,9 +98,9 @@ describe("GitContext", function() { }); it("should verify TeamServices origin remote cloned with ssh", function() { - let repoName: string = "gitrepo-ssh"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const repoName: string = "gitrepo-ssh"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); assert.equal(gc.CurrentBranch, "master"); assert.equal(gc.CurrentRef, "refs/heads/master"); @@ -110,9 +115,9 @@ describe("GitContext", function() { }); it("should verify TeamFoundationServer origin remote", function() { - let repoName: string = "tfsrepo"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const repoName: string = "tfsrepo"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); assert.equal(gc.CurrentBranch, "master"); assert.equal(gc.CurrentRef, "refs/heads/master"); @@ -126,9 +131,9 @@ describe("GitContext", function() { }); it("should verify TeamFoundationServer origin remote cloned with ssh", function() { - let repoName: string = "tfsrepo-ssh"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); - let gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); + const repoName: string = "tfsrepo-ssh"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER); + const gc: GitContext = new GitContext(repoPath, DOT_GIT_FOLDER); assert.equal(gc.CurrentBranch, "master"); assert.equal(gc.CurrentRef, "refs/heads/master"); diff --git a/test/contexts/servercontext.test.ts b/test/contexts/servercontext.test.ts index 195593050e..aa627bfd28 100644 --- a/test/contexts/servercontext.test.ts +++ b/test/contexts/servercontext.test.ts @@ -20,21 +20,21 @@ describe("TeamServerContext", function() { it("should verify context is a TeamFoundation context with Team Services account", function() { // This could be a TFVC repository - let context: TeamServerContext = new TeamServerContext("https://account.visualstudio.com/DefaultCollection/teamproject/"); + const context: TeamServerContext = new TeamServerContext("https://account.visualstudio.com/DefaultCollection/teamproject/"); assert.isTrue(context.RepoInfo.IsTeamServices); assert.isTrue(context.RepoInfo.IsTeamFoundation); assert.isFalse(context.RepoInfo.IsTeamFoundationServer); }); it("should verify context is a IsTeamServices and TeamFoundation context", function() { - let context: TeamServerContext = new TeamServerContext("https://account.visualstudio.com/DefaultCollection/teamproject/_git/repositoryName"); + const context: TeamServerContext = new TeamServerContext("https://account.visualstudio.com/DefaultCollection/teamproject/_git/repositoryName"); assert.isTrue(context.RepoInfo.IsTeamServices); assert.isTrue(context.RepoInfo.IsTeamFoundation); assert.isFalse(context.RepoInfo.IsTeamFoundationServer); }); it("should verify context is a TeamFoundation context with TFS account", function() { - let context: TeamServerContext = new TeamServerContext("http://server:8080/tfs/DefaultCollection/teamproject"); + const context: TeamServerContext = new TeamServerContext("http://server:8080/tfs/DefaultCollection/teamproject"); assert.isFalse(context.RepoInfo.IsTeamServices, "isTeamServices should be false"); //TODO: assert.isTrue(context.RepoInfo.IsTeamFoundation, "isTeamFoundation should be true"); //TODO: assert.isFalse(context.RepoInfo.IsTeamFoundationServer, "isTeamFoundationServer should be true"); diff --git a/test/helpers/logger.test.ts b/test/helpers/logger.test.ts index 602c297323..176e1bcaa8 100644 --- a/test/helpers/logger.test.ts +++ b/test/helpers/logger.test.ts @@ -46,8 +46,8 @@ describe("Logger", function() { }); it("should ensure getNow()", function() { - let now: string = Logger.Now; //calls private getNow() - let date: number = Date.parse(now); + const now: string = Logger.Now; //calls private getNow() + const date: number = Date.parse(now); assert.isDefined(date); }); diff --git a/test/helpers/utils.test.ts b/test/helpers/utils.test.ts index 05f13ebb45..ffa8c292f5 100644 --- a/test/helpers/utils.test.ts +++ b/test/helpers/utils.test.ts @@ -12,21 +12,21 @@ import { Utils } from "../../src/helpers/utils"; import { Strings } from "../../src/helpers/strings"; describe("Utils", function() { - let TEST_REPOS_FOLDER: string = "testrepos"; - let DOT_GIT_FOLDER: string = "dotgit"; + const TEST_REPOS_FOLDER: string = "testrepos"; + const DOT_GIT_FOLDER: string = "dotgit"; beforeEach(function() { // }); it("should verify IsOffline", function() { - let reason = { code: "ENOENT" }; + let reason: any = { code: "ENOENT" }; assert.isTrue(Utils.IsOffline(reason)); reason = { code: "ENOTFOUND" }; assert.isTrue(Utils.IsOffline(reason)); reason = { code: "EAI_AGAIN" }; assert.isTrue(Utils.IsOffline(reason)); - let reason2 = { statusCode: "ENOENT" }; + let reason2: any = { statusCode: "ENOENT" }; assert.isTrue(Utils.IsOffline(reason2)); reason2 = { statusCode: "ENOTFOUND" }; assert.isTrue(Utils.IsOffline(reason2)); @@ -37,98 +37,98 @@ describe("Utils", function() { }); it("should verify IsUnauthorized", function() { - let reason = { code: 401 }; + const reason = { code: 401 }; assert.isTrue(Utils.IsUnauthorized(reason)); - let reason2 = { statusCode: 401 }; + const reason2 = { statusCode: 401 }; assert.isTrue(Utils.IsUnauthorized(reason2)); //If no reason, isUnauthorized should be false assert.isFalse(Utils.IsUnauthorized(undefined)); }); it("should verify GetMessageForStatusCode with 401", function() { - let reason = { code: "401" }; - let message: string = Utils.GetMessageForStatusCode(reason); + const reason = { code: "401" }; + const message: string = Utils.GetMessageForStatusCode(reason); assert.equal(message, Strings.StatusCode401); }); it("should verify GetMessageForStatusCode for offline - ENOENT", function() { - let reason = { code: "ENOENT" }; - let message: string = Utils.GetMessageForStatusCode(reason); + const reason = { code: "ENOENT" }; + const message: string = Utils.GetMessageForStatusCode(reason); assert.equal(message, Strings.StatusCodeOffline); }); it("should verify GetMessageForStatusCode for offline - ENOTFOUND", function() { - let reason = { code: "ENOTFOUND" }; - let message: string = Utils.GetMessageForStatusCode(reason); + const reason = { code: "ENOTFOUND" }; + const message: string = Utils.GetMessageForStatusCode(reason); assert.equal(message, Strings.StatusCodeOffline); }); it("should verify GetMessageForStatusCode for offline - EAI_AGAIN", function() { - let reason = { code: "EAI_AGAIN" }; - let message: string = Utils.GetMessageForStatusCode(reason); + const reason = { code: "EAI_AGAIN" }; + const message: string = Utils.GetMessageForStatusCode(reason); assert.equal(message, Strings.StatusCodeOffline); }); it("should verify GetMessageForStatusCode for proxy - ECONNRESET", function() { - let reason = { code: "ECONNRESET" }; + const reason = { code: "ECONNRESET" }; process.env.HTTP_PROXY = "vsts-vscode unit tests"; - let message: string = Utils.GetMessageForStatusCode(reason); + const message: string = Utils.GetMessageForStatusCode(reason); process.env.HTTP_PROXY = ""; assert.equal(message, Strings.ProxyUnreachable); }); it("should verify GetMessageForStatusCode for proxy - ECONNREFUSED", function() { - let reason = { code: "ECONNREFUSED" }; + const reason = { code: "ECONNREFUSED" }; process.env.HTTP_PROXY = "vsts-vscode unit tests"; - let message: string = Utils.GetMessageForStatusCode(reason); + const message: string = Utils.GetMessageForStatusCode(reason); process.env.HTTP_PROXY = ""; assert.equal(message, Strings.ProxyUnreachable); }); it("should verify GetMessageForStatusCode for no proxy - ECONNRESET", function() { - let reason = { code: "ECONNRESET" }; + const reason = { code: "ECONNRESET" }; process.env.HTTP_PROXY = ""; - let message: string = Utils.GetMessageForStatusCode(reason, "default message"); + const message: string = Utils.GetMessageForStatusCode(reason, "default message"); assert.equal(message, "default message"); }); it("should verify GetMessageForStatusCode for no proxy - ECONNREFUSED", function() { - let reason = { code: "ECONNREFUSED" }; + const reason = { code: "ECONNREFUSED" }; process.env.HTTP_PROXY = ""; - let message: string = Utils.GetMessageForStatusCode(reason, "default message"); + const message: string = Utils.GetMessageForStatusCode(reason, "default message"); assert.equal(message, "default message"); }); it("should verify GetMessageForStatusCode for 404", function() { - let reason = { statusCode: "404" }; - let msg = "This should be the message that is returned."; + const reason = { statusCode: "404" }; + const msg = "This should be the message that is returned."; - let message: string = Utils.GetMessageForStatusCode(reason, msg); + const message: string = Utils.GetMessageForStatusCode(reason, msg); assert.equal(message, msg); }); it("should verify GetMessageForStatusCode for 401 with prefix", function() { - let reason = { statusCode: "401" }; - let msg = Strings.StatusCode401; - let prefix: string = "PREFIX:"; + const reason = { statusCode: "401" }; + const msg = Strings.StatusCode401; + const prefix: string = "PREFIX:"; - let message: string = Utils.GetMessageForStatusCode(reason, msg, prefix); + const message: string = Utils.GetMessageForStatusCode(reason, msg, prefix); assert.equal(message, prefix + " " + msg); }); it("should verify FindGitFolder with subfolder", function() { - let repoName: string = "gitreposubfolder"; - let repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, "folder", "subfolder"); + const repoName: string = "gitreposubfolder"; + const repoPath: string = path.join(__dirname, TEST_REPOS_FOLDER, repoName, "folder", "subfolder"); // Pass in DOT_GIT_FOLDER to find our test repo folder - let actualRepoPath: string = Utils.FindGitFolder(repoPath, DOT_GIT_FOLDER); + const actualRepoPath: string = Utils.FindGitFolder(repoPath, DOT_GIT_FOLDER); // Although we started with a subfolder in the repository, ensure we get the DOT_GIT_FOLDER assert.equal(actualRepoPath, path.join(__dirname, TEST_REPOS_FOLDER, repoName, DOT_GIT_FOLDER)); }); it("should verify FindGitFolder with no found .git folder", function() { - let repoPath: string = __dirname; + const repoPath: string = __dirname; //We need use DOT_GIT_FOLDER here since the test resides in a .git repository - let actualRepoPath: string = Utils.FindGitFolder(repoPath, DOT_GIT_FOLDER); + const actualRepoPath: string = Utils.FindGitFolder(repoPath, DOT_GIT_FOLDER); assert.isUndefined(actualRepoPath); }); @@ -142,8 +142,8 @@ describe("Utils", function() { }); it("should verify IsProxyEnabled", function() { - let httpProxy: string = process.env.HTTP_PROXY; - let httpsProxy: string = process.env.HTTPS_PROXY; + const httpProxy: string = process.env.HTTP_PROXY; + const httpsProxy: string = process.env.HTTPS_PROXY; try { process.env.HTTP_PROXY = "vsts-vscode unit tests"; assert.isTrue(Utils.IsProxyEnabled()); @@ -164,16 +164,16 @@ describe("Utils", function() { }); it("should verify IsProxyIssue", function() { - let httpProxy: string = process.env.HTTP_PROXY; + const httpProxy: string = process.env.HTTP_PROXY; try { process.env.HTTP_PROXY = "vsts-vscode unit tests"; - let reason = { code: "ECONNRESET" }; + let reason: any = { code: "ECONNRESET" }; assert.isTrue(Utils.IsProxyIssue(reason)); - let reason2 = { statusCode: "ECONNRESET" }; + let reason2: any = { statusCode: "ECONNRESET" }; assert.isTrue(Utils.IsProxyIssue(reason2)); - let reason3 = { code: "ECONNREFUSED" }; + let reason3: any = { code: "ECONNREFUSED" }; assert.isTrue(Utils.IsProxyIssue(reason3)); - let reason4 = { statusCode: "ECONNREFUSED" }; + let reason4: any = { statusCode: "ECONNREFUSED" }; assert.isTrue(Utils.IsProxyIssue(reason4)); //With proxy enabled, an undefined message should be false assert.isFalse(Utils.IsProxyIssue(undefined)); diff --git a/test/info/credentialinfo.test.ts b/test/info/credentialinfo.test.ts index eef490f227..416db6ef64 100644 --- a/test/info/credentialinfo.test.ts +++ b/test/info/credentialinfo.test.ts @@ -11,38 +11,48 @@ import { ExtensionRequestHandler } from "../../src/info/extensionrequesthandler" describe("CredentialInfo", function() { + it("should ensure all properties work as expected", function() { + const credentialInfo: CredentialInfo = new CredentialInfo("username", "password", "domain", "workstation"); + assert.isDefined(credentialInfo); + assert.isDefined(credentialInfo.CredentialHandler); + assert.equal(credentialInfo.Username, "username"); + assert.equal(credentialInfo.Password, "password"); + assert.equal(credentialInfo.Domain, "domain"); + assert.equal(credentialInfo.Workstation, "workstation"); + }); + it("should ensure PAT returns a BasicCredentialHandler", function() { - let credentialInfo: CredentialInfo = new CredentialInfo("pat-token"); - let basic: ExtensionRequestHandler = (credentialInfo.CredentialHandler); + const credentialInfo: CredentialInfo = new CredentialInfo("pat-token"); + const basic: ExtensionRequestHandler = (credentialInfo.CredentialHandler); assert.isDefined(basic); assert.equal(basic.Password, "pat-token"); }); it("should ensure username + password returns an NtlmCredentialHandler", function() { - let credentialInfo: CredentialInfo = new CredentialInfo("username", "password"); + const credentialInfo: CredentialInfo = new CredentialInfo("username", "password"); assert.isDefined(credentialInfo); assert.isDefined(credentialInfo.CredentialHandler); - let ntlm: ExtensionRequestHandler = (credentialInfo.CredentialHandler); + const ntlm: ExtensionRequestHandler = (credentialInfo.CredentialHandler); assert.isDefined(ntlm); assert.equal(ntlm.Username, "username"); assert.equal(ntlm.Password, "password"); }); it("should ensure username + password + domain returns an NtlmCredentialHandler", function() { - let credentialInfo: CredentialInfo = new CredentialInfo("username", "password", "domain"); + const credentialInfo: CredentialInfo = new CredentialInfo("username", "password", "domain"); assert.isDefined(credentialInfo); assert.isDefined(credentialInfo.CredentialHandler); - let ntlm: ExtensionRequestHandler = (credentialInfo.CredentialHandler); + const ntlm: ExtensionRequestHandler = (credentialInfo.CredentialHandler); assert.isDefined(ntlm); assert.equal(ntlm.Username, "username"); assert.equal(ntlm.Password, "password"); }); it("should ensure username + password + domain + workstation returns an NtlmCredentialHandler", function() { - let credentialInfo: CredentialInfo = new CredentialInfo("username", "password", "domain", "workstation"); + const credentialInfo: CredentialInfo = new CredentialInfo("username", "password", "domain", "workstation"); assert.isDefined(credentialInfo); assert.isDefined(credentialInfo.CredentialHandler); - let ntlm: ExtensionRequestHandler = (credentialInfo.CredentialHandler); + const ntlm: ExtensionRequestHandler = (credentialInfo.CredentialHandler); assert.isDefined(ntlm); assert.equal(ntlm.Username, "username"); assert.equal(ntlm.Password, "password"); @@ -51,8 +61,8 @@ describe("CredentialInfo", function() { }); it("should ensure properties work as intended", function() { - let credentialInfo: CredentialInfo = new CredentialInfo("pat-token"); - let basic: ExtensionRequestHandler = (credentialInfo.CredentialHandler); + const credentialInfo: CredentialInfo = new CredentialInfo("pat-token"); + const basic: ExtensionRequestHandler = (credentialInfo.CredentialHandler); credentialInfo.CredentialHandler = undefined; assert.isUndefined(credentialInfo.CredentialHandler); credentialInfo.CredentialHandler = basic; diff --git a/test/info/repositoryinfo.test.ts b/test/info/repositoryinfo.test.ts index 120d5e939e..3dc240df4e 100644 --- a/test/info/repositoryinfo.test.ts +++ b/test/info/repositoryinfo.test.ts @@ -12,8 +12,8 @@ describe("RepositoryInfo", function() { /* Team Server URLs */ it("should verify host, account and isTeamFoundationServer for valid remoteUrl", function() { - let url: string = "http://jeyou-dev00000:8080/tfs/DefaultCollection/_git/GitAgile"; - let repoInfo: RepositoryInfo = new RepositoryInfo(url); + const url: string = "http://jeyou-dev00000:8080/tfs/DefaultCollection/_git/GitAgile"; + const repoInfo: RepositoryInfo = new RepositoryInfo(url); assert.equal(repoInfo.Host, "jeyou-dev00000:8080"); //TODO: Should host on-prem contain the port number? assert.equal(repoInfo.Account, "jeyou-dev00000:8080"); //TODO: Should account on-prem contain the port number? assert.isUndefined(repoInfo.AccountUrl); // we only get this when we pass a JSON blob @@ -33,7 +33,7 @@ describe("RepositoryInfo", function() { }); it("should verify valid values in repositoryInfo to RepositoryInfo constructor", function() { - let repositoryInfo = { + const repositoryInfo: any = {    "serverUrl": "http://server:8080/tfs",    "collection": {       "id": "d543db53-9479-46c1-9d33-2cb9cb76f622", @@ -55,7 +55,7 @@ describe("RepositoryInfo", function() {       "remoteUrl": "http://server:8080/tfs/DefaultCollection/teamproject/_git/repositoryName"    } }; - let repoInfo = new RepositoryInfo(repositoryInfo); + const repoInfo = new RepositoryInfo(repositoryInfo); assert.equal(repoInfo.Host, "server:8080"); //TODO: Should host on-prem contain the port number? assert.equal(repoInfo.Account, "server:8080"); //TODO: Should account on-prem contain the port number? assert.equal(repoInfo.AccountUrl, "http://server:8080/tfs"); @@ -74,7 +74,7 @@ describe("RepositoryInfo", function() { /* Team Services URLs */ it("should verify host, account and isTeamServices for valid remoteUrl", function() { - let repoInfo: RepositoryInfo = new RepositoryInfo("https://account.visualstudio.com/DefaultCollection/teamproject/_git/repositoryName"); + const repoInfo: RepositoryInfo = new RepositoryInfo("https://account.visualstudio.com/DefaultCollection/teamproject/_git/repositoryName"); assert.equal(repoInfo.Host, "account.visualstudio.com"); assert.equal(repoInfo.Account, "account"); assert.isTrue(repoInfo.IsTeamServices); @@ -87,7 +87,7 @@ describe("RepositoryInfo", function() { assert.equal(repoInfo.Account, "account"); assert.isTrue(repoInfo.IsTeamServices); assert.isTrue(repoInfo.IsTeamFoundation); - let repositoryInfo = { + const repositoryInfo: any = {    "serverUrl": "https://account.visualstudio.com",    "collection": {       "id": "5e082e28-e8b2-4314-9200-629619e91098", @@ -133,7 +133,7 @@ describe("RepositoryInfo", function() { assert.isTrue(repoInfo.IsTeamServices); assert.isTrue(repoInfo.IsTeamFoundation); // To properly test 'collection in the domain' case insensitivity, ensure the collection name is a different case than the account (e.g., 'ACCOUNT' versus 'account') - let repositoryInfo = { + const repositoryInfo: any = {    "serverUrl": "https://account.visualstudio.com",    "collection": {       "id": "5e082e28-e8b2-4314-9200-629619e91098", diff --git a/test/info/userinfo.test.ts b/test/info/userinfo.test.ts index 114fe6ac9e..2212d537ce 100644 --- a/test/info/userinfo.test.ts +++ b/test/info/userinfo.test.ts @@ -11,7 +11,7 @@ import { UserInfo } from "../../src/info/userinfo"; describe("UserInfo", function() { it("should verify the constructor sets the proper values", function() { - let user: UserInfo = new UserInfo("id", "providerDisplayName", "customDisplayName"); + const user: UserInfo = new UserInfo("id", "providerDisplayName", "customDisplayName"); assert.equal(user.Id, "id"); assert.equal(user.ProviderDisplayName, "providerDisplayName"); assert.equal(user.CustomDisplayName, "customDisplayName"); diff --git a/test/services/build.test.ts b/test/services/build.test.ts index e10f6dc1da..deec270b3f 100644 --- a/test/services/build.test.ts +++ b/test/services/build.test.ts @@ -15,7 +15,7 @@ describe("BuildService", function() { }); it("should verify GetBuildDefinitionsUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; //The new definitions experience is behind a feature flag //assert.equal(BuildService.GetBuildDefinitionsUrl(url), url + "/_build/definitions"); @@ -23,21 +23,21 @@ describe("BuildService", function() { }); it("should verify GetBuildDefinitionUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let arg: string = "42"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const arg: string = "42"; assert.equal(BuildService.GetBuildDefinitionUrl(url, arg), url + "/_build#_a=completed&definitionId=" + arg); }); it("should verify GetBuildSummaryUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let arg: string = "42"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const arg: string = "42"; assert.equal(BuildService.GetBuildSummaryUrl(url, arg), url + "/_build/index?buildId=" + arg + "&_a=summary"); }); it("should verify GetBuildsUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; assert.equal(BuildService.GetBuildsUrl(url), url + "/_build"); }); diff --git a/test/services/gitvc.test.ts b/test/services/gitvc.test.ts index 8500b4ec1c..b991de1386 100644 --- a/test/services/gitvc.test.ts +++ b/test/services/gitvc.test.ts @@ -16,50 +16,50 @@ describe("GitVcService", function() { }); it("should verify GetCreatePullRequestUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let branch: string = "branch"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const branch: string = "branch"; assert.equal(GitVcService.GetCreatePullRequestUrl(url, branch), url + "/pullrequests#_a=createnew&sourceRef=" + branch); }); it("should verify GetFileBlameUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let file: string = "team-extension.ts"; - let branch: string = "branch"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const file: string = "team-extension.ts"; + const branch: string = "branch"; assert.equal(GitVcService.GetFileBlameUrl(url, file, branch), url + "#path=" + file + "&version=GB" + branch + "&annotate=true"); }); it("should verify GetFileHistoryUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let file: string = "team-extension.ts"; - let branch: string = "branch"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const file: string = "team-extension.ts"; + const branch: string = "branch"; assert.equal(GitVcService.GetFileHistoryUrl(url, file, branch), url + "#path=" + file + "&version=GB" + branch + "&_a=history"); }); it("should verify GetPullRequestDiscussionUrl", function() { - let repositoryUrl: string = "https://account.visualstudio.com/DefaultCollection/_git/project"; - let id: string = "42"; + const repositoryUrl: string = "https://account.visualstudio.com/DefaultCollection/_git/project"; + const id: string = "42"; assert.equal(GitVcService.GetPullRequestDiscussionUrl(repositoryUrl, id), repositoryUrl + "/pullrequest/" + id + "?view=discussion"); }); it("should verify GetPullRequestsUrl", function() { - let repositoryUrl: string = "https://account.visualstudio.com/DefaultCollection/_git/project"; + const repositoryUrl: string = "https://account.visualstudio.com/DefaultCollection/_git/project"; assert.equal(GitVcService.GetPullRequestsUrl(repositoryUrl), repositoryUrl + "/pullrequests"); }); it("should verify GetPullRequestDiscussionUrl", function() { - let repositoryUrl: string = "https://account.visualstudio.com/DefaultCollection/_git/project"; - let branch: string = "branch"; + const repositoryUrl: string = "https://account.visualstudio.com/DefaultCollection/_git/project"; + const branch: string = "branch"; assert.equal(GitVcService.GetRepositoryHistoryUrl(repositoryUrl, branch), repositoryUrl + "/history" + "?itemVersion=GB" + branch + "&_a=history"); }); it("should verify failed pull request score", function() { - let pullRequest: GitPullRequest = { + const pullRequest: GitPullRequest = { mergeStatus: PullRequestAsyncStatus.Conflicts, _links: undefined, closedDate: undefined, diff --git a/test/services/workitemtracking.test.ts b/test/services/workitemtracking.test.ts index add9f5ab88..01b1827488 100644 --- a/test/services/workitemtracking.test.ts +++ b/test/services/workitemtracking.test.ts @@ -15,45 +15,45 @@ describe("WorkItemTrackingService", function() { }); it("should verify GetEditWorkItemUrl", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let id: string = "42"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const id: string = "42"; assert.equal(WorkItemTrackingService.GetEditWorkItemUrl(url, id), url + "/_workitems" + "/edit/" + id); }); it("should verify GetNewWorkItemUrl with only url and issueType", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let issueType: string = "Bug"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const issueType: string = "Bug"; assert.equal(WorkItemTrackingService.GetNewWorkItemUrl(url, issueType), url + "/_workitems" + "/create/" + issueType); }); it("should verify GetNewWorkItemUrl with url, issueType and title", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let issueType: string = "Bug"; - let title: string = "Fix this bug!"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const issueType: string = "Bug"; + const title: string = "Fix this bug!"; assert.equal(WorkItemTrackingService.GetNewWorkItemUrl(url, issueType, title), url + "/_workitems" + "/create/" + issueType + "?[" + WorkItemFields.Title + "]=" + title); }); it("should verify GetNewWorkItemUrl with url, issueType, title and assignedTo", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let issueType: string = "Bug"; - let title: string = "Fix this bug!"; - let assignedTo: string = "raisap@outlook.com"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const issueType: string = "Bug"; + const title: string = "Fix this bug!"; + const assignedTo: string = "raisap@outlook.com"; assert.equal(WorkItemTrackingService.GetNewWorkItemUrl(url, issueType, title, assignedTo), url + "/_workitems" + "/create/" + issueType + "?[" + WorkItemFields.Title + "]=" + title + "&" + "[" + WorkItemFields.AssignedTo + "]=" + assignedTo); }); it("should verify GetMyQueryResultsUrl with url and queryName", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; - let queryName: string = "My Favorite Query"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const queryName: string = "My Favorite Query"; assert.equal(WorkItemTrackingService.GetMyQueryResultsUrl(url, "My Queries", queryName), url + "/_workitems" + "?path=" + encodeURIComponent("My Queries/") + encodeURIComponent(queryName) + "&_a=query"); }); it("should verify GetWorkItemsBaseUrl with url", function() { - let url: string = "https://account.visualstudio.com/DefaultCollection/project"; + const url: string = "https://account.visualstudio.com/DefaultCollection/project"; assert.equal(WorkItemTrackingService.GetWorkItemsBaseUrl(url), url + "/_workitems"); }); diff --git a/test/tfvc/commands/add.test.ts b/test/tfvc/commands/add.test.ts index eff1427fb1..a4679b7fcc 100644 --- a/test/tfvc/commands/add.test.ts +++ b/test/tfvc/commands/add.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-AddCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -43,17 +43,17 @@ describe("Tfvc-AddCommand", function() { }); it("should verify constructor - windows", function() { - let localPaths: string[] = ["c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"]; + const localPaths: string[] = ["c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"]; new Add(undefined, localPaths); }); it("should verify constructor - mac/linux", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; new Add(undefined, localPaths); }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; new Add(context, localPaths); }); @@ -62,69 +62,69 @@ describe("Tfvc-AddCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Add = new Add(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Add = new Add(undefined, localPaths); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Add = new Add(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Add = new Add(undefined, localPaths); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Add = new Add(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Add = new Add(undefined, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "add -noprompt " + localPaths[0]); }); it("should verify Exe arguments", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Add = new Add(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Add = new Add(undefined, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "add -noprompt " + localPaths[0]); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Add = new Add(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Add = new Add(context, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "add -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0]); }); it("should verify Exe arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Add = new Add(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Add = new Add(context, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "add -noprompt ******** " + localPaths[0]); }); it("should verify parse output - no files to add", async function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md"]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md"]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "No arguments matched any files to add.", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseOutput(executionResult); + const filesAdded: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesAdded.length, 0); }); it("should verify parse output - single empty folder - no errors", async function() { - let localPaths: string[] = ["empty-folder"]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["empty-folder"]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "empty-folder:\n" + "empty-folder\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseOutput(executionResult); + const filesAdded: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesAdded.length, 1); //In this case, the CLC returns: //empty-folder: @@ -134,55 +134,55 @@ describe("Tfvc-AddCommand", function() { }); it("should verify parse output - single folder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "file1.txt")]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "file1.txt")]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "folder1:\n" + "file1.txt\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseOutput(executionResult); + const filesAdded: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesAdded.length, 1); assert.equal(filesAdded[0], localPaths[0]); }); it("should verify parse output - single subfolder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "folder2") + ":\n" + "file2.txt\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseOutput(executionResult); + const filesAdded: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesAdded.length, 1); assert.equal(filesAdded[0], localPaths[0]); }); it("should verify parse output - single folder+file - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "file1.txt")]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "file1.txt")]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "fold er1:\n" + "file1.txt\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseOutput(executionResult); + const filesAdded: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesAdded.length, 1); assert.equal(filesAdded[0], localPaths[0]); }); it("should verify parse output - error exit code, stdout", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -199,10 +199,10 @@ describe("Tfvc-AddCommand", function() { }); it("should verify parse output - error exit code, stderr", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: undefined, stderr: "Something bad this way comes." @@ -220,30 +220,30 @@ describe("Tfvc-AddCommand", function() { /// Verify ParseExeOutput values (for tf.exe) it("should verify parse Exe output - no files to add", async function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md"]; - let cmd: Add = new Add(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md"]; + const cmd: Add = new Add(undefined, localPaths); //This return value is different for tf.exe than the CLC - let executionResult: IExecutionResult = { + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md: No file matches.", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseExeOutput(executionResult); + const filesAdded: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesAdded.length, 0); }); it("should verify parse Exe output - single empty folder - no errors", async function() { - let localPaths: string[] = ["empty-folder"]; - let cmd: Add = new Add(undefined, localPaths); + const localPaths: string[] = ["empty-folder"]; + const cmd: Add = new Add(undefined, localPaths); //This return value is different for tf.exe than the CLC - let executionResult: IExecutionResult = { + const executionResult: IExecutionResult = { exitCode: 0, stdout: "empty-folder\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseExeOutput(executionResult); + const filesAdded: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesAdded.length, 1); //In this case, the EXE returns (this differs from the CLC): //empty-folder @@ -251,55 +251,55 @@ describe("Tfvc-AddCommand", function() { }); it("should verify parse Exe output - single folder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "file1.txt")]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "file1.txt")]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "folder1:\n" + "file1.txt\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseExeOutput(executionResult); + const filesAdded: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesAdded.length, 1); assert.equal(filesAdded[0], localPaths[0]); }); it("should verify parse Exe output - single subfolder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "folder2") + ":\n" + "file2.txt\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseExeOutput(executionResult); + const filesAdded: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesAdded.length, 1); assert.equal(filesAdded[0], localPaths[0]); }); it("should verify parse Exe output - single folder+file - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "file1.txt")]; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "file1.txt")]; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "fold er1:\n" + "file1.txt\n", stderr: undefined }; - let filesAdded: string[] = await cmd.ParseExeOutput(executionResult); + const filesAdded: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesAdded.length, 1); assert.equal(filesAdded[0], localPaths[0]); }); it("should verify parse Exe output - error exit code, stdout", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -316,10 +316,10 @@ describe("Tfvc-AddCommand", function() { }); it("should verify parse Exe output - error exit code, stderr", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Add = new Add(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Add = new Add(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: undefined, stderr: "Something bad this way comes." diff --git a/test/tfvc/commands/argumentbuilder.test.ts b/test/tfvc/commands/argumentbuilder.test.ts index 179d41fb19..a85137ef79 100644 --- a/test/tfvc/commands/argumentbuilder.test.ts +++ b/test/tfvc/commands/argumentbuilder.test.ts @@ -14,11 +14,11 @@ import { RepositoryInfo } from "../../../src/info/repositoryinfo"; import { TfvcError } from "../../../src/tfvc/tfvcerror"; describe("Tfvc-ArgumentBuilder", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -42,20 +42,20 @@ describe("Tfvc-ArgumentBuilder", function() { }); it("should verify constructor", function() { - let cmd: string = "mycmd"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd); + const cmd: string = "mycmd"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd); assert.equal(builder.GetCommand(), cmd); - let args = builder.Build(); + const args = builder.Build(); assert.equal(args[0], cmd); assert.equal(args[1], "-noprompt"); assert.equal(args.length, 2); }); it("should verify constructor with context", function() { - let cmd: string = "mycmd"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd, context); + const cmd: string = "mycmd"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd, context); assert.equal(builder.GetCommand(), cmd); - let args = builder.Build(); + const args = builder.Build(); assert.equal(args[0], cmd); assert.equal(args[1], "-noprompt"); assert.equal(args[2], "-collection:" + collectionUrl); @@ -68,28 +68,28 @@ describe("Tfvc-ArgumentBuilder", function() { }); it("should verify ToString", function() { - let cmd: string = "mycmd"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd, context); + const cmd: string = "mycmd"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd, context); assert.equal(builder.ToString(), "mycmd -noprompt -collection:" + collectionUrl + " ********"); }); it("should verify BuildCommandLine with context", function() { - let cmd: string = "mycmd"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd, context); + const cmd: string = "mycmd"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd, context); assert.equal(builder.BuildCommandLine().trim(), "mycmd -noprompt -collection:" + collectionUrl + " -login:" + user + "," + pass); }); it("should verify BuildCommandLine", function() { - let cmd: string = "mycmd"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd); + const cmd: string = "mycmd"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd); assert.equal(builder.BuildCommandLine().trim(), "mycmd -noprompt"); }); it("should verify BuildCommandLine with spaces in options", function() { - let cmd: string = "mycmd"; - let path: string = "/path/with a space/file.txt"; - let option: string = "option with space"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd); + const cmd: string = "mycmd"; + const path: string = "/path/with a space/file.txt"; + const option: string = "option with space"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd); builder.Add(path); builder.AddSwitch(option); builder.AddSwitchWithValue(option, path, false); @@ -97,10 +97,10 @@ describe("Tfvc-ArgumentBuilder", function() { }); it("should verify BuildCommandLine with spaces in some", function() { - let cmd: string = "mycmd"; - let path: string = "/path/with a space/file.txt"; - let option: string = "option"; - let builder: ArgumentBuilder = new ArgumentBuilder(cmd); + const cmd: string = "mycmd"; + const path: string = "/path/with a space/file.txt"; + const option: string = "option"; + const builder: ArgumentBuilder = new ArgumentBuilder(cmd); builder.Add(path); builder.AddSwitch(option); builder.AddSwitchWithValue(option, path, false); @@ -108,12 +108,12 @@ describe("Tfvc-ArgumentBuilder", function() { }); it("should verify interface implemented", function() { - let cmd: string = "mycmd"; - let argProvider: IArgumentProvider = new ArgumentBuilder(cmd, context); + const cmd: string = "mycmd"; + const argProvider: IArgumentProvider = new ArgumentBuilder(cmd, context); // GetCommand assert.equal(argProvider.GetCommand(), cmd); // GetArguments - let args = argProvider.GetArguments(); + const args = argProvider.GetArguments(); assert.equal(args[0], cmd); assert.equal(args[1], "-noprompt"); assert.equal(args[2], "-collection:" + collectionUrl); diff --git a/test/tfvc/commands/checkin.test.ts b/test/tfvc/commands/checkin.test.ts index 4009b8bef8..2787984821 100644 --- a/test/tfvc/commands/checkin.test.ts +++ b/test/tfvc/commands/checkin.test.ts @@ -14,11 +14,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-CheckinCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -42,12 +42,12 @@ describe("Tfvc-CheckinCommand", function() { }); it("should verify constructor", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; + const files: string[] = ["/path/to/workspace/file.txt"]; new Checkin(undefined, files); }); it("should verify constructor with context", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; + const files: string[] = ["/path/to/workspace/file.txt"]; new Checkin(context, files); }); @@ -56,106 +56,106 @@ describe("Tfvc-CheckinCommand", function() { }); it("should verify GetOptions", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "checkin -noprompt " + files[0]); }); it("should verify Exe arguments", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "checkin -noprompt " + files[0]); }); it("should verify arguments with context", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "checkin -noprompt -collection:" + collectionUrl + " ******** " + files[0]); }); it("should verify Exe arguments with context", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "checkin -noprompt ******** " + files[0]); }); it("should verify arguments with workitems", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files, undefined, [1, 2, 3]); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files, undefined, [1, 2, 3]); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "checkin -noprompt -collection:" + collectionUrl + " ******** " + files[0] + " -associate:1,2,3"); }); it("should verify Exe arguments with workitems", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files, undefined, [1, 2, 3]); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files, undefined, [1, 2, 3]); //Note that no associate option should be here (tf.exe doesn't support it) assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "checkin -noprompt ******** " + files[0]); }); it("should verify arguments with comment", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files, "a comment\nthat has\r\nmultiple lines"); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files, "a comment\nthat has\r\nmultiple lines"); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "checkin -noprompt -collection:" + collectionUrl + " ******** " + files[0] + " -comment:a comment that has multiple lines"); }); it("should verify Exe arguments with comment", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files, "a comment\nthat has\r\nmultiple lines"); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files, "a comment\nthat has\r\nmultiple lines"); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "checkin -noprompt ******** " + files[0] + " -comment:a comment that has multiple lines"); }); it("should verify arguments with all params", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files, "a comment", [1, 2, 3]); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files, "a comment", [1, 2, 3]); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "checkin -noprompt -collection:" + collectionUrl + " ******** " + files[0] + " -comment:a comment -associate:1,2,3"); }); it("should verify Exe arguments with all params", function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(context, files, "a comment", [1, 2, 3]); + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(context, files, "a comment", [1, 2, 3]); //Note that no associate option should be here (tf.exe doesn't support it) assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "checkin -noprompt ******** " + files[0] + " -comment:a comment"); }); it("should verify parse output - no output", async function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); - let executionResult: IExecutionResult = { + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let result: string = await cmd.ParseOutput(executionResult); + const result: string = await cmd.ParseOutput(executionResult); assert.equal(result, ""); }); it("should verify parse output - no errors", async function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); - let executionResult: IExecutionResult = { + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/Users/leantk/tfvc-tfs/tfsTest_01/addFold:\n" + "Checking in edit: testHere.txt\n" + @@ -168,14 +168,14 @@ describe("Tfvc-CheckinCommand", function() { stderr: undefined }; - let result: string = await cmd.ParseOutput(executionResult); + const result: string = await cmd.ParseOutput(executionResult); assert.equal(result, "23"); }); it("should verify parse output - with error", async function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); - let executionResult: IExecutionResult = { + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "/Users/leantk/tfvc-tfs/tfsTest_01:\n" + "Checking in edit: test3.txt\n" + @@ -196,22 +196,22 @@ describe("Tfvc-CheckinCommand", function() { // // it("should verify parse Exe output - no output", async function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); - let executionResult: IExecutionResult = { + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let result: string = await cmd.ParseExeOutput(executionResult); + const result: string = await cmd.ParseExeOutput(executionResult); assert.equal(result, ""); }); it("should verify parse Exe output - no errors", async function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); - let executionResult: IExecutionResult = { + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/Users/leantk/tfvc-tfs/tfsTest_01/addFold:\n" + "Checking in edit: testHere.txt\n" + @@ -224,14 +224,14 @@ describe("Tfvc-CheckinCommand", function() { stderr: undefined }; - let result: string = await cmd.ParseExeOutput(executionResult); + const result: string = await cmd.ParseExeOutput(executionResult); assert.equal(result, "23"); }); it("should verify parse Exe output - with error", async function() { - let files: string[] = ["/path/to/workspace/file.txt"]; - let cmd: Checkin = new Checkin(undefined, files); - let executionResult: IExecutionResult = { + const files: string[] = ["/path/to/workspace/file.txt"]; + const cmd: Checkin = new Checkin(undefined, files); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "/Users/leantk/tfvc-tfs/tfsTest_01:\n" + "Checking in edit: test3.txt\n" + diff --git a/test/tfvc/commands/delete.test.ts b/test/tfvc/commands/delete.test.ts index 27dc2a2fc3..ecb1765922 100644 --- a/test/tfvc/commands/delete.test.ts +++ b/test/tfvc/commands/delete.test.ts @@ -14,11 +14,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-DeleteCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -42,17 +42,17 @@ describe("Tfvc-DeleteCommand", function() { }); it("should verify constructor - windows", function() { - let localPaths: string[] = ["c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"]; + const localPaths: string[] = ["c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"]; new Delete(undefined, localPaths); }); it("should verify constructor - mac/linux", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; new Delete(undefined, localPaths); }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; new Delete(context, localPaths); }); @@ -61,70 +61,70 @@ describe("Tfvc-DeleteCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Delete = new Delete(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Delete = new Delete(undefined, localPaths); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Delete = new Delete(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Delete = new Delete(undefined, localPaths); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Delete = new Delete(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Delete = new Delete(undefined, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "delete -noprompt " + localPaths[0]); }); it("should verify Exe arguments", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Delete = new Delete(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Delete = new Delete(undefined, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "delete -noprompt " + localPaths[0]); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Delete = new Delete(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Delete = new Delete(context, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "delete -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0]); }); it("should verify Exe arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Delete = new Delete(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Delete = new Delete(context, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "delete -noprompt ******** " + localPaths[0]); }); it("should verify parse output - single file - no errors", async function() { - let localPaths: string[] = ["README.md"]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md"]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "README.md\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], "README.md"); }); it("should verify parse output - single empty folder - no errors", async function() { - let localPaths: string[] = ["empty-folder"]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["empty-folder"]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "empty-folder:\n" + "empty-folder\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesDeleted.length, 1); //In this case, the CLC returns: //empty-folder: @@ -134,55 +134,55 @@ describe("Tfvc-DeleteCommand", function() { }); it("should verify parse output - single folder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "file1.txt")]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "file1.txt")]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "folder1:\n" + "file1.txt\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], localPaths[0]); }); it("should verify parse output - single subfolder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "folder2") + ":\n" + "file2.txt\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], localPaths[0]); }); it("should verify parse output - single folder+file - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "file1.txt")]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "file1.txt")]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "fold er1:\n" + "file1.txt\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], localPaths[0]); }); it("should verify parse output - multiple files", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "file1.txt") + ":\n" + "file1.txt\n" + @@ -191,16 +191,16 @@ describe("Tfvc-DeleteCommand", function() { stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseOutput(executionResult); assert.isDefined(filesDeleted); assert.equal(filesDeleted.length, 2); }); it("should verify parse output - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -219,10 +219,10 @@ describe("Tfvc-DeleteCommand", function() { // TF203069: $/L2.VSCodeExtension.RC/folder1/folder2 could not be deleted because that change conflicts with one or more other pending changes to that item. To delete it, undo all pending changes to that item, delete it, and then check in the change. // No arguments matched any files to delete. it("should verify parse output - deletion conflict - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "folder2")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "folder2")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "// TF203069: $/L2.VSCodeExtension.RC/folder1/folder2 could not be deleted because that change " + "conflicts with one or more other pending changes to that item. To delete it, undo all pending changes " + @@ -244,10 +244,10 @@ describe("Tfvc-DeleteCommand", function() { //The item C:\repos\Tfvc.L2VSCodeExtension.RC\folder1\folder2\foo.txt could not be found in your workspace, or you do not have permission to access it. //No arguments matched any files to delete. it("should verify parse output - delete a file that doesn't exist - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "folder2", "foo.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "folder2", "foo.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "The item C:\\repos\\Tfvc.L2VSCodeExtension.RC\\folder1\\folder2\\foo.txt could not be found in your workspace, or you do not have permission to access it.\n" + "No arguments matched any files to delete.\n", @@ -269,30 +269,30 @@ describe("Tfvc-DeleteCommand", function() { // // it("should verify parse Exe output - single file - no errors", async function() { - let localPaths: string[] = ["README.md"]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md"]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "README.md\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], "README.md"); }); it("should verify parse Exe output - single empty folder - no errors", async function() { - let localPaths: string[] = ["empty-folder"]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["empty-folder"]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "empty-folder:\n" + "empty-folder\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesDeleted.length, 1); //In this case, the CLC returns: //empty-folder: @@ -302,55 +302,55 @@ describe("Tfvc-DeleteCommand", function() { }); it("should verify parse Exe output - single folder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "file1.txt")]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "file1.txt")]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "folder1:\n" + "file1.txt\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], localPaths[0]); }); it("should verify parse Exe output - single subfolder+file - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "folder2") + ":\n" + "file2.txt\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], localPaths[0]); }); it("should verify parse Exe output - single folder+file - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "file1.txt")]; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "file1.txt")]; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "fold er1:\n" + "file1.txt\n", stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesDeleted.length, 1); assert.equal(filesDeleted[0], localPaths[0]); }); it("should verify parse Exe output - multiple files", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "file1.txt") + ":\n" + "file1.txt\n" + @@ -359,16 +359,16 @@ describe("Tfvc-DeleteCommand", function() { stderr: undefined }; - let filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); + const filesDeleted: string[] = await cmd.ParseExeOutput(executionResult); assert.isDefined(filesDeleted); assert.equal(filesDeleted.length, 2); }); it("should verify parse Exe output - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -387,10 +387,10 @@ describe("Tfvc-DeleteCommand", function() { // TF203069: $/L2.VSCodeExtension.RC/folder1/folder2 could not be deleted because that change conflicts with one or more other pending changes to that item. To delete it, undo all pending changes to that item, delete it, and then check in the change. // No arguments matched any files to delete. it("should verify parse Exe output - deletion conflict - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "folder2")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "folder2")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "// TF203069: $/L2.VSCodeExtension.RC/folder1/folder2 could not be deleted because that change " + "conflicts with one or more other pending changes to that item. To delete it, undo all pending changes " + @@ -412,10 +412,10 @@ describe("Tfvc-DeleteCommand", function() { //The item C:\repos\Tfvc.L2VSCodeExtension.RC\folder1\folder2\foo.txt could not be found in your workspace, or you do not have permission to access it. //No arguments matched any files to delete. it("should verify parse Exe output - delete a file that doesn't exist - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "folder2", "foo.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Delete = new Delete(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "folder2", "foo.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Delete = new Delete(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "The item C:\\repos\\Tfvc.L2VSCodeExtension.RC\\folder1\\folder2\\foo.txt could not be found in your workspace, or you do not have permission to access it.\n" + "No arguments matched any files to delete.\n", diff --git a/test/tfvc/commands/findconflicts.test.ts b/test/tfvc/commands/findconflicts.test.ts index 2768ca45f4..607499c2c7 100644 --- a/test/tfvc/commands/findconflicts.test.ts +++ b/test/tfvc/commands/findconflicts.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-FindConflictsCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -43,12 +43,12 @@ describe("Tfvc-FindConflictsCommand", function() { }); it("should verify constructor", function() { - let localPath: string = "/usr/alias/repo1"; + const localPath: string = "/usr/alias/repo1"; new FindConflicts(undefined, localPath); }); it("should verify constructor with context", function() { - let localPath: string = "/usr/alias/repo1"; + const localPath: string = "/usr/alias/repo1"; new FindConflicts(context, localPath); }); @@ -57,62 +57,62 @@ describe("Tfvc-FindConflictsCommand", function() { }); it("should verify GetOptions", function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "resolve -noprompt " + localPath + " -recursive -preview"); }); it("should verify Exe arguments", function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "resolve -noprompt " + localPath + " -recursive -preview"); }); it("should verify arguments with context", function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(context, localPath); + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(context, localPath); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "resolve -noprompt -collection:" + collectionUrl + " ******** " + localPath + " -recursive -preview"); }); it("should verify Exe arguments with context", function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(context, localPath); + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(context, localPath); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "resolve -noprompt ******** " + localPath + " -recursive -preview"); }); it("should verify parse output - no output", async function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: IConflict[] = await cmd.ParseOutput(executionResult); + const results: IConflict[] = await cmd.ParseOutput(executionResult); assert.equal(results.length, 0); }); it("should verify parse output - one of each type", async function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "", stderr: "contentChange.txt: The item content has changed\n" + @@ -126,7 +126,7 @@ describe("Tfvc-FindConflictsCommand", function() { "branchDelete.txt: The item has been deleted in the target branch" }; - let results: IConflict[] = await cmd.ParseOutput(executionResult); + const results: IConflict[] = await cmd.ParseOutput(executionResult); assert.equal(results.length, 9); assert.equal(results[0].localPath, "contentChange.txt"); assert.equal(results[0].type, ConflictType.CONTENT); @@ -149,9 +149,9 @@ describe("Tfvc-FindConflictsCommand", function() { }); it("should verify parse output - errors - exit code 100", async function() { - let localPath: string = "/usr/alias/repo 1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/usr/alias/repo 1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined @@ -168,29 +168,29 @@ describe("Tfvc-FindConflictsCommand", function() { }); it("should verify parse Exe output - no output", async function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: IConflict[] = await cmd.ParseExeOutput(executionResult); + const results: IConflict[] = await cmd.ParseExeOutput(executionResult); assert.equal(results.length, 0); }); it("should verify parse Exe output - one of each type", async function() { - let localPath: string = "/usr/alias/repo1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/usr/alias/repo1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "", stderr: "folder1\\anothernewfile2.txt: A newer version exists on the server.\n" + "folder1\\anothernewfile4.txt: The item has been deleted from the server.\n" }; - let results: IConflict[] = await cmd.ParseExeOutput(executionResult); + const results: IConflict[] = await cmd.ParseExeOutput(executionResult); assert.equal(results.length, 2); assert.equal(results[0].localPath, "folder1\\anothernewfile2.txt"); assert.equal(results[0].type, ConflictType.NAME_AND_CONTENT); @@ -199,9 +199,9 @@ describe("Tfvc-FindConflictsCommand", function() { }); it("should verify parse Exe output - errors - exit code 100", async function() { - let localPath: string = "/usr/alias/repo 1"; - let cmd: FindConflicts = new FindConflicts(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/usr/alias/repo 1"; + const cmd: FindConflicts = new FindConflicts(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/commands/findworkspace.test.ts b/test/tfvc/commands/findworkspace.test.ts index ba82c8e225..9899a94786 100644 --- a/test/tfvc/commands/findworkspace.test.ts +++ b/test/tfvc/commands/findworkspace.test.ts @@ -18,7 +18,7 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify constructor", function() { - let localPath: string = "/path/to/workspace"; + const localPath: string = "/path/to/workspace"; new FindWorkspace(localPath); }); @@ -27,62 +27,62 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify GetOptions", function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); assert.deepEqual(cmd.GetOptions(), { cwd: "/path/to/workspace" }); }); it("should verify GetExeOptions", function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); assert.deepEqual(cmd.GetExeOptions(), { cwd: "/path/to/workspace" }); }); it("should verify arguments", function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "workfold -noprompt ********"); }); it("should verify GetExeArguments", function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "workfold -noprompt ********"); }); it("should verify working folder", function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); assert.equal(cmd.GetOptions().cwd, localPath); }); it("should verify EXE working folder", function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); assert.equal(cmd.GetExeOptions().cwd, localPath); }); it("should verify parse output - no output", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let workspace: IWorkspace = await cmd.ParseOutput(executionResult); + const workspace: IWorkspace = await cmd.ParseOutput(executionResult); assert.equal(workspace, undefined); }); it("should verify parse output - no errors", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=====================================================================================================================================================\n" + "Workspace: MyWorkspace\n" + @@ -91,7 +91,7 @@ describe("Tfvc-FindWorkspaceCommand", function() { stderr: undefined }; - let workspace: IWorkspace = await cmd.ParseOutput(executionResult); + const workspace: IWorkspace = await cmd.ParseOutput(executionResult); assert.equal(workspace.name, "MyWorkspace"); assert.equal(workspace.server, "http://server:8080/tfs/"); assert.equal(workspace.defaultTeamProject, "project1"); @@ -102,9 +102,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse output - German - no 'workspace' and 'collection'", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=====================================================================================================================================================\n" + "Arbeitsbereich: DESKTOP-KI56MCL (Jeff Young (TFS))\n" + @@ -122,9 +122,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse output - not a tf workspace", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: "An argument error occurred: The workspace could not be determined from any argument paths or the current working directory." @@ -139,9 +139,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse output - no mappings error", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=====================================================================================================================================================\n" + "Workspace: MyWorkspace\n" + @@ -158,9 +158,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse output - no errors - restrictWorkspace", async function() { - let localPath: string = "/path/to/workspace/project2"; - let cmd: FindWorkspace = new FindWorkspace(localPath, true); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace/project2"; + const cmd: FindWorkspace = new FindWorkspace(localPath, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=====================================================================================================================================================\n" + "Workspace: MyWorkspace\n" + @@ -170,7 +170,7 @@ describe("Tfvc-FindWorkspaceCommand", function() { stderr: undefined }; - let workspace: IWorkspace = await cmd.ParseOutput(executionResult); + const workspace: IWorkspace = await cmd.ParseOutput(executionResult); assert.equal(workspace.name, "MyWorkspace"); assert.equal(workspace.server, "http://server:8080/tfs/"); //This test should find project2 as the team porject since the localPath contains project2 and we have restrictWorkspace @@ -186,22 +186,22 @@ describe("Tfvc-FindWorkspaceCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let workspace: IWorkspace = await cmd.ParseExeOutput(executionResult); + const workspace: IWorkspace = await cmd.ParseExeOutput(executionResult); assert.equal(workspace, undefined); }); it("should verify parse EXE output - no errors", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=============================================================================\n" + @@ -211,7 +211,7 @@ describe("Tfvc-FindWorkspaceCommand", function() { stderr: undefined }; - let workspace: IWorkspace = await cmd.ParseExeOutput(executionResult); + const workspace: IWorkspace = await cmd.ParseExeOutput(executionResult); assert.equal(workspace.name, "MyWorkspace"); assert.equal(workspace.server, "http://server:8080/tfs/"); assert.equal(workspace.defaultTeamProject, "project1"); @@ -222,9 +222,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse EXE output - German - no 'workspace' and 'collection'", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=====================================================================================================================================================\n" + "Arbeitsbereich: DESKTOP-KI56MCL (Jeff Young (TFS))\n" + @@ -242,9 +242,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse EXE output - not a tf workspace", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: "Unable to determine the source control server." @@ -259,9 +259,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse EXE output - no mappings error", async function() { - let localPath: string = "/path/to/workspace"; - let cmd: FindWorkspace = new FindWorkspace(localPath); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace"; + const cmd: FindWorkspace = new FindWorkspace(localPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=============================================================================\n" + @@ -279,9 +279,9 @@ describe("Tfvc-FindWorkspaceCommand", function() { }); it("should verify parse EXE output - no errors - restrictWorkspace", async function() { - let localPath: string = "/path/to/workspace/project2"; - let cmd: FindWorkspace = new FindWorkspace(localPath, true); - let executionResult: IExecutionResult = { + const localPath: string = "/path/to/workspace/project2"; + const cmd: FindWorkspace = new FindWorkspace(localPath, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "=====================================================================================================================================================\n" + "Workspace: MyWorkspace\n" + @@ -291,7 +291,7 @@ describe("Tfvc-FindWorkspaceCommand", function() { stderr: undefined }; - let workspace: IWorkspace = await cmd.ParseExeOutput(executionResult); + const workspace: IWorkspace = await cmd.ParseExeOutput(executionResult); assert.equal(workspace.name, "MyWorkspace"); assert.equal(workspace.server, "http://server:8080/tfs/"); //This test should find project2 as the team porject since the localPath contains project2 and we have restrictWorkspace diff --git a/test/tfvc/commands/getfilecontent.test.ts b/test/tfvc/commands/getfilecontent.test.ts index e831a12ad0..ea9bef65df 100644 --- a/test/tfvc/commands/getfilecontent.test.ts +++ b/test/tfvc/commands/getfilecontent.test.ts @@ -14,11 +14,11 @@ import { RepositoryInfo } from "../../../src/info/repositoryinfo"; import { Strings } from "../../../src/helpers/strings"; describe("Tfvc-GetFileContentCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -42,17 +42,17 @@ describe("Tfvc-GetFileContentCommand", function() { }); it("should verify constructor - windows", function() { - let localPath: string = "c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"; + const localPath: string = "c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"; new GetFileContent(undefined, localPath); }); it("should verify constructor - mac/linux", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; new GetFileContent(undefined, localPath); }); it("should verify constructor with context", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; new GetFileContent(context, localPath); }); @@ -61,117 +61,117 @@ describe("Tfvc-GetFileContentCommand", function() { }); it("should verify GetOptions", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetArguments", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "print -noprompt " + localPath); }); it("should verify GetArguments with context", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(context, localPath); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(context, localPath); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "print -noprompt -collection:" + collectionUrl + " ******** " + localPath); }); it("should verify GetArguments + versionSpec", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath, "42"); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath, "42"); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "print -noprompt " + localPath + " -version:42"); }); it("should verify GetArguments + versionSpec with context", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(context, localPath, "42"); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(context, localPath, "42"); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "print -noprompt -collection:" + collectionUrl + " ******** " + localPath + " -version:42"); }); it("should verify GetExeOptions", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify GetExeArguments", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "view -noprompt " + localPath); }); it("should verify GetExeArguments with context", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(context, localPath); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(context, localPath); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "view -noprompt -collection:" + collectionUrl + " ******** " + localPath); }); it("should verify GetExeArguments + versionSpec", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath, "42"); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath, "42"); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "view -noprompt " + localPath + " -version:42"); }); it("should verify GetExeArguments + versionSpec with context", function() { - let localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; - let cmd: GetFileContent = new GetFileContent(context, localPath, "42"); + const localPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"; + const cmd: GetFileContent = new GetFileContent(context, localPath, "42"); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "view -noprompt -collection:" + collectionUrl + " ******** " + localPath + " -version:42"); }); it("should verify parse output - single file - no errors", async function() { - let localPath: string = "README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); - let fileContent: string = "This is the content of the README.md file\n...and I mean that.\n"; - let executionResult: IExecutionResult = { + const localPath: string = "README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); + const fileContent: string = "This is the content of the README.md file\n...and I mean that.\n"; + const executionResult: IExecutionResult = { exitCode: 0, stdout: fileContent, stderr: undefined }; - let content: string = await cmd.ParseOutput(executionResult); + const content: string = await cmd.ParseOutput(executionResult); assert.equal(content, fileContent); }); it("should verify parse output - no file matches", async function() { - let localPath: string = "folder1/file1.txt"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath, undefined, true); //ignoring file not found - let executionResult: IExecutionResult = { + const localPath: string = "folder1/file1.txt"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath, undefined, true); //ignoring file not found + const executionResult: IExecutionResult = { exitCode: 1, stdout: undefined, stderr: "No file matches what you passed." }; - let content: string = await cmd.ParseOutput(executionResult); + const content: string = await cmd.ParseOutput(executionResult); assert.equal(content, ""); }); it("should verify parse output - file doesn't exist", async function() { - let localPath: string = "folder1/file1.txt"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath, "66", true); //ignoring file not found - let executionResult: IExecutionResult = { + const localPath: string = "folder1/file1.txt"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath, "66", true); //ignoring file not found + const executionResult: IExecutionResult = { exitCode: 1, stdout: undefined, stderr: "The specified file does not exist at the specified version or something..." }; - let content: string = await cmd.ParseOutput(executionResult); + const content: string = await cmd.ParseOutput(executionResult); assert.equal(content, ""); }); it("should verify parse output - error exit code", async function() { - let localPath: string = "folder1/file1.txt"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "folder1/file1.txt"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -188,23 +188,23 @@ describe("Tfvc-GetFileContentCommand", function() { }); it("should verify parse Exe output - single file - no errors", async function() { - let localPath: string = "README.md"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); - let fileContent: string = "This is the content of the README.md file\n...and I mean that.\n"; - let executionResult: IExecutionResult = { + const localPath: string = "README.md"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); + const fileContent: string = "This is the content of the README.md file\n...and I mean that.\n"; + const executionResult: IExecutionResult = { exitCode: 0, stdout: fileContent, stderr: undefined }; - let content: string = await cmd.ParseExeOutput(executionResult); + const content: string = await cmd.ParseExeOutput(executionResult); assert.equal(content, fileContent); }); it("should verify parse Exe output - error exit code", async function() { - let localPath: string = "folder1/file1.txt"; - let cmd: GetFileContent = new GetFileContent(undefined, localPath); - let executionResult: IExecutionResult = { + const localPath: string = "folder1/file1.txt"; + const cmd: GetFileContent = new GetFileContent(undefined, localPath); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/commands/getinfo.test.ts b/test/tfvc/commands/getinfo.test.ts index 4beda3b75c..a8b92c9422 100644 --- a/test/tfvc/commands/getinfo.test.ts +++ b/test/tfvc/commands/getinfo.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-GetInfoCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -43,12 +43,12 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify constructor", function() { - let localPaths: string[] = ["/path/to/workspace"]; + const localPaths: string[] = ["/path/to/workspace"]; new GetInfo(undefined, localPaths); }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/path/to/workspace"]; + const localPaths: string[] = ["/path/to/workspace"]; new GetInfo(context, localPaths); }); @@ -57,62 +57,62 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "info -noprompt " + localPaths[0]); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(context, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(context, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "info -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0]); }); it("should verify GetExeArguments", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "info -noprompt " + localPaths[0]); }); it("should verify GetExeArguments with context", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(context, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(context, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "info -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0]); }); it("should verify parse output - no output", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); assert.equal(itemInfos.length, 0); }); it("should verify parse output - single item", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Local information:\n" + "Local path: /path/to/file.txt\n" + @@ -133,7 +133,7 @@ describe("Tfvc-GetInfoCommand", function() { stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); assert.equal(itemInfos.length, 1); assert.equal(itemInfos[0].localItem, "/path/to/file.txt"); assert.equal(itemInfos[0].serverItem, "$/TFVC_1/file.txt"); @@ -150,9 +150,9 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify parse output - multiple items", async function() { - let localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Local information:\n" + "Local path: /path/to/file.txt\n" + @@ -190,7 +190,7 @@ describe("Tfvc-GetInfoCommand", function() { stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); assert.equal(itemInfos.length, 2); assert.equal(itemInfos[0].localItem, "/path/to/file.txt"); assert.equal(itemInfos[0].serverItem, "$/TFVC_1/file.txt"); @@ -219,9 +219,9 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify parse output - multiple items with errors", async function() { - let localPaths: string[] = ["/path/to/workspace/file.txt", "nomatch", "/path/to/workspace/file2.txt"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace/file.txt", "nomatch", "/path/to/workspace/file2.txt"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Local information:\n" + "Local path: /path/to/file.txt\n" + @@ -261,7 +261,7 @@ describe("Tfvc-GetInfoCommand", function() { stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseOutput(executionResult); assert.equal(itemInfos.length, 3); assert.equal(itemInfos[0].localItem, "/path/to/file.txt"); assert.equal(itemInfos[0].serverItem, "$/TFVC_1/file.txt"); @@ -291,9 +291,9 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify parse output - all errors", async function() { - let localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "No items match /path/to/workspace/file.txt\n" + "\n" + @@ -314,22 +314,22 @@ describe("Tfvc-GetInfoCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); assert.equal(itemInfos.length, 0); }); it("should verify parse EXE output - single item", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Local information:\n" + "Local path: /path/to/file.txt\n" + @@ -350,7 +350,7 @@ describe("Tfvc-GetInfoCommand", function() { stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); assert.equal(itemInfos.length, 1); assert.equal(itemInfos[0].localItem, "/path/to/file.txt"); assert.equal(itemInfos[0].serverItem, "$/TFVC_1/file.txt"); @@ -367,9 +367,9 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify parse EXE output - multiple items", async function() { - let localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Local information:\n" + "Local path: /path/to/file.txt\n" + @@ -406,7 +406,7 @@ describe("Tfvc-GetInfoCommand", function() { stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); assert.equal(itemInfos.length, 2); assert.equal(itemInfos[0].localItem, "/path/to/file.txt"); assert.equal(itemInfos[0].serverItem, "$/TFVC_1/file.txt"); @@ -435,9 +435,9 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify parse EXE output - multiple items with errors", async function() { - let localPaths: string[] = ["/path/to/workspace/file.txt", "nomatch", "/path/to/workspace/file2.txt"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace/file.txt", "nomatch", "/path/to/workspace/file2.txt"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Local information:\n" + "Local path: /path/to/file.txt\n" + @@ -475,7 +475,7 @@ describe("Tfvc-GetInfoCommand", function() { stderr: undefined }; - let itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); + const itemInfos: IItemInfo[] = await cmd.ParseExeOutput(executionResult); assert.equal(itemInfos.length, 3); assert.equal(itemInfos[0].localItem, "/path/to/file.txt"); assert.equal(itemInfos[0].serverItem, "$/TFVC_1/file.txt"); @@ -505,9 +505,9 @@ describe("Tfvc-GetInfoCommand", function() { }); it("should verify parse EXE output - all errors", async function() { - let localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; - let cmd: GetInfo = new GetInfo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace/file.txt", "/path/to/workspace/file2.txt"]; + const cmd: GetInfo = new GetInfo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "No items match /path/to/workspace/file.txt\n" + "No items match /path/to/workspace/file2.txt\n", diff --git a/test/tfvc/commands/getversion.test.ts b/test/tfvc/commands/getversion.test.ts index 2670aaf477..cfc2dd48a8 100644 --- a/test/tfvc/commands/getversion.test.ts +++ b/test/tfvc/commands/getversion.test.ts @@ -13,28 +13,28 @@ import { Strings } from "../../../src/helpers/strings"; describe("Tfvc-GetVersionCommand", function() { it("should verify GetOptions", function() { - let cmd: GetVersion = new GetVersion(); + const cmd: GetVersion = new GetVersion(); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let cmd: GetVersion = new GetVersion(); + const cmd: GetVersion = new GetVersion(); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let cmd: GetVersion = new GetVersion(); + const cmd: GetVersion = new GetVersion(); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "add -noprompt -?"); }); it("should verify Exe arguments", function() { - let cmd: GetVersion = new GetVersion(); + const cmd: GetVersion = new GetVersion(); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "add -noprompt -?"); }); it("should verify parse output - no version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "", stderr: undefined @@ -53,8 +53,8 @@ describe("Tfvc-GetVersionCommand", function() { }); it("should verify parse Exe output - no version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "", stderr: undefined @@ -73,32 +73,32 @@ describe("Tfvc-GetVersionCommand", function() { }); it("should verify parse output - valid version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Team Explorer Everywhere Command Line Client (version 14.0.3.201603291047)", stderr: undefined }; - let version: string = await cmd.ParseOutput(executionResult); + const version: string = await cmd.ParseOutput(executionResult); assert.equal(version, "14.0.3.201603291047"); }); it("should verify parse EXE output - valid version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Microsoft (R) TF - Team Foundation Version Control Tool, Version 14.102.25619.0", stderr: undefined }; - let version: string = await cmd.ParseExeOutput(executionResult); + const version: string = await cmd.ParseExeOutput(executionResult); assert.equal(version, "14.102.25619.0"); }); it("should verify parse output - error exit code", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -119,8 +119,8 @@ describe("Tfvc-GetVersionCommand", function() { }); it("should verify parse Exe output - error exit code", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -141,8 +141,8 @@ describe("Tfvc-GetVersionCommand", function() { }); it("should verify parse EXE output - Spanish version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Microsoft (R) TF - Herramienta Control de versiones de Team Foundation, versi�n 14.102.25619.0", stderr: undefined @@ -161,8 +161,8 @@ describe("Tfvc-GetVersionCommand", function() { }); it("should verify parse EXE output - French version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Microsoft (R) TF�- Outil Team Foundation Version Control, version�14.102.25619.0", stderr: undefined @@ -181,20 +181,20 @@ describe("Tfvc-GetVersionCommand", function() { }); it("should verify parse EXE output - German version", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Microsoft (R) TF - Team Foundation-Versionskontrolltool, Version 14.102.25619.0", stderr: undefined }; - let version: string = await cmd.ParseExeOutput(executionResult); + const version: string = await cmd.ParseExeOutput(executionResult); assert.equal(version, "14.102.25619.0"); }); it("should verify parse EXE output - version is not in the first line", async function() { - let cmd: GetVersion = new GetVersion(); - let executionResult: IExecutionResult = { + const cmd: GetVersion = new GetVersion(); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "\r\nc:\\TFS\\folder1\\folder two\\folder3\\folder4\\folder5> add -noprompt -?\r\n" + "Microsoft (R) TF - Team Foundation Version Control Tool, Version 14.98.25331.0\r\n" + @@ -208,7 +208,7 @@ describe("Tfvc-GetVersionCommand", function() { stderr: undefined }; - let version: string = await cmd.ParseExeOutput(executionResult); + const version: string = await cmd.ParseExeOutput(executionResult); assert.equal(version, "14.98.25331.0"); }); }); diff --git a/test/tfvc/commands/rename.test.ts b/test/tfvc/commands/rename.test.ts index 770846668e..819f6c61d9 100644 --- a/test/tfvc/commands/rename.test.ts +++ b/test/tfvc/commands/rename.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-RenameCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -43,123 +43,123 @@ describe("Tfvc-RenameCommand", function() { }); it("should verify constructor - windows", function() { - let startPath: string = "c:\\repos\\Tfvc.L2VSCodeExtension.RC\\"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "c:\\repos\\Tfvc.L2VSCodeExtension.RC\\"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); new Rename(undefined, sourcePath, destinationPath); }); it("should verify constructor - mac/linux", function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); new Rename(undefined, sourcePath, destinationPath); }); it("should verify constructor with context", function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); new Rename(context, sourcePath, destinationPath); }); it("should verify constructor - no destination path", function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); assert.throws(() => new Rename(undefined, sourcePath, undefined), TfvcError, /Argument is required/); }); it("should verify constructor - no source path", function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const destinationPath: string = path.join(startPath, "READU.md"); assert.throws(() => new Rename(undefined, undefined, destinationPath), TfvcError, /Argument is required/); }); it("should verify GetOptions", function() { - let cmd: Rename = new Rename(context, "sourcePath", "destinationPath"); + const cmd: Rename = new Rename(context, "sourcePath", "destinationPath"); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let cmd: Rename = new Rename(context, "sourcePath", "destinationPath"); + const cmd: Rename = new Rename(context, "sourcePath", "destinationPath"); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); + const cmd: Rename = new Rename(context, sourcePath, destinationPath); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "rename -noprompt -collection:" + collectionUrl + " ******** " + sourcePath + " " + destinationPath); }); it("should verify GetExeArguments", function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); + const cmd: Rename = new Rename(context, sourcePath, destinationPath); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "rename -noprompt ******** " + sourcePath + " " + destinationPath); }); it("should verify parse output - no output", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let result: string = await cmd.ParseOutput(executionResult); + const result: string = await cmd.ParseOutput(executionResult); assert.equal(result, ""); }); it("should verify parse output - single line", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: `READU.md`, stderr: undefined }; - let result: string = await cmd.ParseOutput(executionResult); + const result: string = await cmd.ParseOutput(executionResult); assert.equal(result, "READU.md"); }); it("should verify parse output - with path", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: `${startPath}:\nREADU.md`, stderr: undefined }; - let result: string = await cmd.ParseOutput(executionResult); + const result: string = await cmd.ParseOutput(executionResult); assert.equal(result, destinationPath); }); it("should verify parse output - source file not in workspace", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: `The item ${sourcePath} could not be found in your workspace, or you do not have permission to access it.\n` @@ -175,12 +175,12 @@ describe("Tfvc-RenameCommand", function() { }); it("should verify parse output - error exit code, stdout", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -201,60 +201,60 @@ describe("Tfvc-RenameCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let result: string = await cmd.ParseExeOutput(executionResult); + const result: string = await cmd.ParseExeOutput(executionResult); assert.equal(result, ""); }); it("should verify parse EXE output - single line", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: `READU.md`, stderr: undefined }; - let result: string = await cmd.ParseExeOutput(executionResult); + const result: string = await cmd.ParseExeOutput(executionResult); assert.equal(result, "READU.md"); }); it("should verify parse EXE output - with path", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 0, stdout: `${startPath}:\nREADU.md`, stderr: undefined }; - let result: string = await cmd.ParseExeOutput(executionResult); + const result: string = await cmd.ParseExeOutput(executionResult); assert.equal(result, destinationPath); }); it("should verify parse EXE output - source file not in workspace", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: `The item ${sourcePath} could not be found in your workspace, or you do not have permission to access it.\n` @@ -270,12 +270,12 @@ describe("Tfvc-RenameCommand", function() { }); it("should verify parse EXE output - error exit code, stdout", async function() { - let startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; - let sourcePath: string = path.join(startPath, "README.md"); - let destinationPath: string = path.join(startPath, "READU.md"); + const startPath: string = "/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/"; + const sourcePath: string = path.join(startPath, "README.md"); + const destinationPath: string = path.join(startPath, "READU.md"); - let cmd: Rename = new Rename(context, sourcePath, destinationPath); - let executionResult: IExecutionResult = { + const cmd: Rename = new Rename(context, sourcePath, destinationPath); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/commands/resolveconflicts.test.ts b/test/tfvc/commands/resolveconflicts.test.ts index 40f99ba851..3db053eb13 100644 --- a/test/tfvc/commands/resolveconflicts.test.ts +++ b/test/tfvc/commands/resolveconflicts.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-ResolveConflictsCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -43,12 +43,12 @@ describe("Tfvc-ResolveConflictsCommand", function() { }); it("should verify constructor", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; new ResolveConflicts(context, localPaths, AutoResolveType.KeepYours); }); @@ -57,83 +57,83 @@ describe("Tfvc-ResolveConflictsCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "resolve -noprompt " + localPaths[0] + " -auto:KeepYours"); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.KeepYours); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.KeepYours); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "resolve -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0] + " -auto:KeepYours"); }); it("should verify arguments with TakeTheirs", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.TakeTheirs); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.TakeTheirs); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "resolve -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0] + " -auto:TakeTheirs"); }); it("should verify GetExeArguments", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "resolve -noprompt " + localPaths[0] + " -auto:KeepYours"); }); it("should verify GetExeArguments with context", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.KeepYours); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.KeepYours); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "resolve -noprompt ******** " + localPaths[0] + " -auto:KeepYours"); }); it("should verify GetExeArguments with TakeTheirs", function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.TakeTheirs); + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(context, localPaths, AutoResolveType.TakeTheirs); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "resolve -noprompt ******** " + localPaths[0] + " -auto:TakeTheirs"); }); it("should verify parse output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: IConflict[] = await cmd.ParseOutput(executionResult); + const results: IConflict[] = await cmd.ParseOutput(executionResult); assert.equal(results.length, 0); }); it("should verify parse output - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt", "/usr/alias/repo1/file2.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt", "/usr/alias/repo1/file2.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Resolved /usr/alias/repo1/file.txt as KeepYours\n" + "Resolved /usr/alias/repo1/file2.txt as KeepYours", stderr: undefined }; - let results: IConflict[] = await cmd.ParseOutput(executionResult); + const results: IConflict[] = await cmd.ParseOutput(executionResult); assert.equal(results.length, 2); assert.equal(results[0].localPath, "/usr/alias/repo1/file.txt"); assert.equal(results[0].type, ConflictType.RESOLVED); @@ -142,9 +142,9 @@ describe("Tfvc-ResolveConflictsCommand", function() { }); it("should verify parse output - errors - exit code 100", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined @@ -165,29 +165,29 @@ describe("Tfvc-ResolveConflictsCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: IConflict[] = await cmd.ParseExeOutput(executionResult); + const results: IConflict[] = await cmd.ParseExeOutput(executionResult); assert.equal(results.length, 0); }); it("should verify parse EXE output - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt", "/usr/alias/repo1/file2.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt", "/usr/alias/repo1/file2.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Resolved /usr/alias/repo1/file.txt as KeepYours\n" + "Resolved /usr/alias/repo1/file2.txt as KeepYours", stderr: undefined }; - let results: IConflict[] = await cmd.ParseExeOutput(executionResult); + const results: IConflict[] = await cmd.ParseExeOutput(executionResult); assert.equal(results.length, 2); assert.equal(results[0].localPath, "/usr/alias/repo1/file.txt"); assert.equal(results[0].type, ConflictType.RESOLVED); @@ -196,9 +196,9 @@ describe("Tfvc-ResolveConflictsCommand", function() { }); it("should verify parse EXE output - errors - exit code 100", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined @@ -219,29 +219,29 @@ describe("Tfvc-ResolveConflictsCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: IConflict[] = await cmd.ParseExeOutput(executionResult); + const results: IConflict[] = await cmd.ParseExeOutput(executionResult); assert.equal(results.length, 0); }); it("should verify parse EXE output - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt", "/usr/alias/repo1/file2.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt", "/usr/alias/repo1/file2.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Resolved /usr/alias/repo1/file.txt as KeepYours\n" + "Resolved /usr/alias/repo1/file2.txt as KeepYours", stderr: undefined }; - let results: IConflict[] = await cmd.ParseExeOutput(executionResult); + const results: IConflict[] = await cmd.ParseExeOutput(executionResult); assert.equal(results.length, 2); assert.equal(results[0].localPath, "/usr/alias/repo1/file.txt"); assert.equal(results[0].type, ConflictType.RESOLVED); @@ -250,9 +250,9 @@ describe("Tfvc-ResolveConflictsCommand", function() { }); it("should verify parse EXE output - errors - exit code 100", async function() { - let localPaths: string[] = ["/usr/alias/repo1/file.txt"]; - let cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1/file.txt"]; + const cmd: ResolveConflicts = new ResolveConflicts(undefined, localPaths, AutoResolveType.KeepYours); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/commands/status.test.ts b/test/tfvc/commands/status.test.ts index 6e9267fd77..3bc52d4187 100644 --- a/test/tfvc/commands/status.test.ts +++ b/test/tfvc/commands/status.test.ts @@ -14,11 +14,11 @@ import { RepositoryInfo } from "../../../src/info/repositoryinfo"; import { Strings } from "../../../src/helpers/strings"; describe("Tfvc-StatusCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -42,7 +42,7 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify constructor", function() { - let localPaths: string[] = ["/path/to/workspace"]; + const localPaths: string[] = ["/path/to/workspace"]; new Status(undefined, true, localPaths); }); @@ -51,7 +51,7 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/path/to/workspace"]; + const localPaths: string[] = ["/path/to/workspace"]; new Status(context, true, localPaths); }); @@ -60,101 +60,101 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "status -noprompt -format:xml -recursive " + localPaths[0]); }); it("should verify Exe arguments", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "status -noprompt -format:detailed -recursive " + localPaths[0]); }); it("should verify arguments - no paths", function() { - let cmd: Status = new Status(undefined, true); + const cmd: Status = new Status(undefined, true); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "status -noprompt -format:xml -recursive"); }); it("should verify Exe arguments - no paths", function() { - let cmd: Status = new Status(undefined, true); + const cmd: Status = new Status(undefined, true); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "status -noprompt -format:detailed -recursive"); }); it("should verify arguments - multiple paths", function() { - let localPaths: string[] = ["/path/to/workspace", "/path/to/workspace2"]; - let cmd: Status = new Status(undefined, true, localPaths); + const localPaths: string[] = ["/path/to/workspace", "/path/to/workspace2"]; + const cmd: Status = new Status(undefined, true, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "status -noprompt -format:xml -recursive " + localPaths[0] + " " + localPaths[1]); }); it("should verify Exe arguments - multiple paths", function() { - let localPaths: string[] = ["/path/to/workspace", "/path/to/workspace2"]; - let cmd: Status = new Status(undefined, true, localPaths); + const localPaths: string[] = ["/path/to/workspace", "/path/to/workspace2"]; + const cmd: Status = new Status(undefined, true, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "status -noprompt -format:detailed -recursive " + localPaths[0] + " " + localPaths[1]); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(context, true, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(context, true, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "status -noprompt -collection:" + collectionUrl + " ******** -format:xml -recursive " + localPaths[0]); }); it("should verify Exe arguments with context", function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(context, true, localPaths); + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(context, true, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "status -noprompt -collection:" + collectionUrl + " ******** -format:detailed -recursive " + localPaths[0]); }); it("should verify parse output - no output", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseOutput(executionResult); assert.equal(changes.length, 0); }); it("should verify parse Exe output - no output", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); assert.equal(changes.length, 0); }); it("should verify parse output - valid json", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let stdout: string = ` + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const stdout: string = ` @@ -164,13 +164,13 @@ describe("Tfvc-StatusCommand", function() { `; - let executionResult: IExecutionResult = { + const executionResult: IExecutionResult = { exitCode: 0, stdout: `${stdout}`, stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseOutput(executionResult); assert.equal(changes.length, 2); assert.equal(changes[0].changeType, "rename"); assert.equal(changes[0].computer, "JPRICKET-DEV2"); @@ -198,9 +198,9 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify parse Exe output - pending changes only - no errors", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "$/jeyou/README.md;C19\n" + " User : Jeff Young (TFS)\n" + @@ -215,7 +215,7 @@ describe("Tfvc-StatusCommand", function() { stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); assert.equal(changes.length, 1); assert.equal(changes[0].changeType, "edit"); assert.equal(changes[0].computer, "JEYOU-DEV00"); @@ -231,9 +231,9 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify parse Exe output - pending and detected changes - no errors", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "$/jeyou/README.md;C19\n" + " User : Jeff Young (TFS)\n" + @@ -259,7 +259,7 @@ describe("Tfvc-StatusCommand", function() { stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); assert.equal(changes.length, 2); assert.equal(changes[0].changeType, "edit"); assert.equal(changes[0].computer, "JEYOU-DEV00"); @@ -286,9 +286,9 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify parse Exe output - detected changes only - no errors", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "-----------------\n" + "Detected Changes:\n" + @@ -305,7 +305,7 @@ describe("Tfvc-StatusCommand", function() { stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); assert.equal(changes.length, 1); assert.equal(changes[0].changeType, "add"); assert.equal(changes[0].computer, "JEYOU-DEV00"); @@ -321,9 +321,9 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify parse Exe output - multiple pending and multiple detected changes - no errors", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "$/jeyou/README.md;C19\n" + " User : Jeff Young (TFS)\n" + @@ -366,15 +366,15 @@ describe("Tfvc-StatusCommand", function() { stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); assert.equal(changes.length, 4); //Other tests verify the actual values (so skip them here) }); it("should verify parse Exe output - pending rename only - no errors", async function() { - let localPaths: string[] = ["/path/to/workspace"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/path/to/workspace"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "$/jeyou/READU.md;C19\n" + " User : Jeff Young (TFS)\n" + @@ -390,7 +390,7 @@ describe("Tfvc-StatusCommand", function() { stderr: undefined }; - let changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); + const changes: IPendingChange[] = await cmd.ParseExeOutput(executionResult); assert.equal(changes.length, 1); assert.equal(changes[0].changeType, "rename"); assert.equal(changes[0].computer, "JEYOU-DEV00"); @@ -406,9 +406,9 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify parse output - error exit code", async function() { - let localPaths: string[] = ["folder1/file1.txt", "folder2/file2.txt"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["folder1/file1.txt", "folder2/file2.txt"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -425,9 +425,9 @@ describe("Tfvc-StatusCommand", function() { }); it("should verify parse Exe output - error exit code", async function() { - let localPaths: string[] = ["folder1/file1.txt", "folder2/file2.txt"]; - let cmd: Status = new Status(undefined, true, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["folder1/file1.txt", "folder2/file2.txt"]; + const cmd: Status = new Status(undefined, true, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/commands/sync.test.ts b/test/tfvc/commands/sync.test.ts index 57fdf18b51..aed46e3c6f 100644 --- a/test/tfvc/commands/sync.test.ts +++ b/test/tfvc/commands/sync.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-SyncCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -43,12 +43,12 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify constructor", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; + const localPaths: string[] = ["/usr/alias/repo1"]; new Sync(undefined, localPaths, true); }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; + const localPaths: string[] = ["/usr/alias/repo1"]; new Sync(context, localPaths, true); }); @@ -57,100 +57,100 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, false); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, false); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, false); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, false); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, false); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, false); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "get -noprompt -nosummary " + localPaths[0]); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(context, localPaths, false); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(context, localPaths, false); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "get -noprompt -collection:" + collectionUrl + " ******** -nosummary " + localPaths[0]); }); it("should verify arguments with context and recursive", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(context, localPaths, true); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(context, localPaths, true); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "get -noprompt -collection:" + collectionUrl + " ******** -nosummary " + localPaths[0] + " -recursive"); }); it("should verify getExeArguments", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, false); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, false); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "get -noprompt -nosummary " + localPaths[0]); }); it("should verify getExeArguments with context", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(context, localPaths, false); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(context, localPaths, false); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "get -noprompt ******** -nosummary " + localPaths[0]); }); it("should verify getExeArguments with context and recursive", function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(context, localPaths, true); + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(context, localPaths, true); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "get -noprompt ******** -nosummary " + localPaths[0] + " -recursive"); }); it("should verify parse output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 0); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); }); it("should verify parse output - up to date", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "All files up to date.", stderr: undefined }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 0); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); }); it("should verify parse output - single file edit - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo1/test:\n" + "Replacing test1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -159,16 +159,16 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse output - single file add - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo1/test:\n" + "Getting test1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -177,16 +177,16 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse output - single file add - spaces - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo 1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo 1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo 1/test:\n" + "Getting test 1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -195,9 +195,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse output - multiple files - with conflict", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n" + "Getting addFold\n" + @@ -218,7 +218,7 @@ describe("Tfvc-SyncCommand", function() { stderr: "Conflict test_renamed.txt - Unable to perform the get operation because you have a conflicting rename, edit\n" }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 9); assert.equal(results.hasConflicts, true); assert.equal(results.hasErrors, false); @@ -245,9 +245,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse output - errors - exit code 1", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n", stderr: "Conflict new.txt - Unable to perform the get operation because you have a conflicting edit\n" + @@ -255,7 +255,7 @@ describe("Tfvc-SyncCommand", function() { "Warning new111.txt - Unable to perform the get operation because it is writable" }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 3); assert.equal(results.hasConflicts, true); assert.equal(results.hasErrors, true); @@ -271,9 +271,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse output - errors - no conflicts", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n", stderr: "new4.txt - Unable to perform the get operation because you have a conflicting rename (to be moved from /path/new5.txt)\n" + @@ -281,7 +281,7 @@ describe("Tfvc-SyncCommand", function() { "/usr/alias/repo1/folder cannot be deleted because it is not empty" }; - let results: ISyncResults = await cmd.ParseOutput(executionResult); + const results: ISyncResults = await cmd.ParseOutput(executionResult); assert.equal(results.itemResults.length, 3); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, true); @@ -297,9 +297,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse output - errors - exit code 100", async function() { - let localPaths: string[] = ["/usr/alias/repo 1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo 1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined @@ -320,46 +320,46 @@ describe("Tfvc-SyncCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 0); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); }); it("should verify parse EXE output - up to date", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "All files are up to date.", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 0); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); }); it("should verify parse EXE output - single file edit - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo1/test:\n" + "Replacing test1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -368,16 +368,16 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - single file add - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo1/test:\n" + "Getting test1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -386,16 +386,16 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - single file add - spaces - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo 1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo 1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo 1/test:\n" + "Getting test 1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -404,9 +404,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - multiple files - with conflict", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n" + "Getting addFold\n" + @@ -427,7 +427,7 @@ describe("Tfvc-SyncCommand", function() { stderr: "Conflict test_renamed.txt - Unable to perform the get operation because you have a conflicting rename, edit\n" }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 9); assert.equal(results.hasConflicts, true); assert.equal(results.hasErrors, false); @@ -454,9 +454,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - errors - exit code 1", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n", stderr: "Conflict new.txt - Unable to perform the get operation because you have a conflicting edit\n" + @@ -464,7 +464,7 @@ describe("Tfvc-SyncCommand", function() { "Warning new111.txt - Unable to perform the get operation because it is writable" }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 3); assert.equal(results.hasConflicts, true); assert.equal(results.hasErrors, true); @@ -480,9 +480,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - errors - no conflicts", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n", stderr: "new4.txt - Unable to perform the get operation because you have a conflicting rename (to be moved from /path/new5.txt)\n" + @@ -490,7 +490,7 @@ describe("Tfvc-SyncCommand", function() { "/usr/alias/repo1/folder cannot be deleted because it is not empty" }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 3); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, true); @@ -506,9 +506,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - errors - exit code 100", async function() { - let localPaths: string[] = ["/usr/alias/repo 1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo 1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined @@ -529,46 +529,46 @@ describe("Tfvc-SyncCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 0); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); }); it("should verify parse EXE output - up to date", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "All files are up to date.", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 0); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); }); it("should verify parse EXE output - single file edit - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo1/test:\n" + "Replacing test1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -577,16 +577,16 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - single file add - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo1/test:\n" + "Getting test1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -595,16 +595,16 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - single file add - spaces - no errors", async function() { - let localPaths: string[] = ["/usr/alias/repo 1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo 1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "/usr/alias/repo 1/test:\n" + "Getting test 1.txt\n", stderr: undefined }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 1); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, false); @@ -613,9 +613,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - multiple files - with conflict", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n" + "Getting addFold\n" + @@ -636,7 +636,7 @@ describe("Tfvc-SyncCommand", function() { stderr: "Conflict test_renamed.txt - Unable to perform the get operation because you have a conflicting rename, edit\n" }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 9); assert.equal(results.hasConflicts, true); assert.equal(results.hasErrors, false); @@ -663,9 +663,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - errors - exit code 1", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n", stderr: "Conflict new.txt - Unable to perform the get operation because you have a conflicting edit\n" + @@ -673,7 +673,7 @@ describe("Tfvc-SyncCommand", function() { "Warning new111.txt - Unable to perform the get operation because it is writable" }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 3); assert.equal(results.hasConflicts, true); assert.equal(results.hasErrors, true); @@ -689,9 +689,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - errors - no conflicts", async function() { - let localPaths: string[] = ["/usr/alias/repo1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "/usr/alias/repo1:\n", stderr: "new4.txt - Unable to perform the get operation because you have a conflicting rename (to be moved from /path/new5.txt)\n" + @@ -699,7 +699,7 @@ describe("Tfvc-SyncCommand", function() { "/usr/alias/repo1/folder cannot be deleted because it is not empty" }; - let results: ISyncResults = await cmd.ParseExeOutput(executionResult); + const results: ISyncResults = await cmd.ParseExeOutput(executionResult); assert.equal(results.itemResults.length, 3); assert.equal(results.hasConflicts, false); assert.equal(results.hasErrors, true); @@ -715,9 +715,9 @@ describe("Tfvc-SyncCommand", function() { }); it("should verify parse EXE output - errors - exit code 100", async function() { - let localPaths: string[] = ["/usr/alias/repo 1"]; - let cmd: Sync = new Sync(undefined, localPaths, true); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repo 1"]; + const cmd: Sync = new Sync(undefined, localPaths, true); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/commands/undo.test.ts b/test/tfvc/commands/undo.test.ts index e99df2b165..71d0922c65 100644 --- a/test/tfvc/commands/undo.test.ts +++ b/test/tfvc/commands/undo.test.ts @@ -15,11 +15,11 @@ import { CredentialInfo } from "../../../src/info/credentialinfo"; import { RepositoryInfo } from "../../../src/info/repositoryinfo"; describe("Tfvc-UndoCommand", function() { - let serverUrl: string = "http://server:8080/tfs"; - let repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; - let collectionUrl: string = "http://server:8080/tfs/collection1"; - let user: string = "user1"; - let pass: string = "pass1"; + const serverUrl: string = "http://server:8080/tfs"; + const repoUrl: string = "http://server:8080/tfs/collection1/_git/repo1"; + const collectionUrl: string = "http://server:8080/tfs/collection1"; + const user: string = "user1"; + const pass: string = "pass1"; let context: TeamServerContext; beforeEach(function() { @@ -45,17 +45,17 @@ describe("Tfvc-UndoCommand", function() { //new Undo(this._serverContext, itemPaths)); it("should verify constructor - windows", function() { - let localPaths: string[] = ["c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"]; + const localPaths: string[] = ["c:\\repos\\Tfvc.L2VSCodeExtension.RC\\README.md"]; new Undo(undefined, localPaths); }); it("should verify constructor - mac/linux", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; new Undo(undefined, localPaths); }); it("should verify constructor with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; new Undo(context, localPaths); }); @@ -64,186 +64,186 @@ describe("Tfvc-UndoCommand", function() { }); it("should verify GetOptions", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(context, localPaths); assert.deepEqual(cmd.GetOptions(), {}); }); it("should verify GetExeOptions", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(context, localPaths); assert.deepEqual(cmd.GetExeOptions(), {}); }); it("should verify arguments", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "undo -noprompt " + localPaths[0]); }); it("should verify arguments with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(context, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "undo -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0]); }); it("should verify UndoAll arguments", function() { - let localPaths: string[] = ["*"]; - let cmd: Undo = new Undo(undefined, localPaths); + const localPaths: string[] = ["*"]; + const cmd: Undo = new Undo(undefined, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "undo -noprompt . -recursive"); }); it("should verify UndoAll arguments with context", function() { - let localPaths: string[] = ["*"]; - let cmd: Undo = new Undo(context, localPaths); + const localPaths: string[] = ["*"]; + const cmd: Undo = new Undo(context, localPaths); assert.equal(cmd.GetArguments().GetArgumentsForDisplay(), "undo -noprompt -collection:" + collectionUrl + " ******** . -recursive"); }); it("should verify GetExeArguments", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "undo -noprompt " + localPaths[0]); }); it("should verify GetExeArguments with context", function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(context, localPaths); + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(context, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "undo -noprompt -collection:" + collectionUrl + " ******** " + localPaths[0]); }); it("should verify GetExeArguments UndoAll arguments", function() { - let localPaths: string[] = ["*"]; - let cmd: Undo = new Undo(undefined, localPaths); + const localPaths: string[] = ["*"]; + const cmd: Undo = new Undo(undefined, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "undo -noprompt . -recursive"); }); it("should verify GetExeArguments UndoAll arguments with context", function() { - let localPaths: string[] = ["*"]; - let cmd: Undo = new Undo(context, localPaths); + const localPaths: string[] = ["*"]; + const cmd: Undo = new Undo(context, localPaths); assert.equal(cmd.GetExeArguments().GetArgumentsForDisplay(), "undo -noprompt -collection:" + collectionUrl + " ******** . -recursive"); }); it("should verify parse output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 0); }); it("should verify parse output - single file edit - no errors", async function() { - let localPaths: string[] = ["README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Undoing edit: README.md\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], "README.md"); }); it("should verify parse output - single file add - no errors", async function() { - let localPaths: string[] = ["README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Undoing add: README.md\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], "README.md"); }); it("should verify parse output - multiple file add - no errors", async function() { - let localPaths: string[] = ["README.md", "README2.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md", "README2.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Undoing add: README.md\n" + "Undoing add: README2.md\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 2); assert.equal(filesUndone[0], "README.md"); assert.equal(filesUndone[1], "README2.md"); }); it("should verify parse output - single folder+file edit - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "file1.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "file1.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "folder1:\n" + "Undoing edit: file1.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); it("should verify parse output - single subfolder+file add - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "folder2") + ":\n" + "Undoing edit: file2.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); it("should verify parse output - single folder+file edit - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "file1.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "file1.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "fold er1:\n" + "Undoing edit: file1.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); it("should verify parse output - single subfolder+file add - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "fol der2", "file2.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "fol der2", "file2.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("fold er1", "fol der2") + ":\n" + "Undoing edit: file2.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); @@ -251,10 +251,10 @@ describe("Tfvc-UndoCommand", function() { //If we have at least 1 file undone but at least 1 with no pending changes, exit code is 1 //Proceed normally but ignore the files that have no pending changes. it("should verify parse output - multiple files - several no pending changes", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = ["README.md"].concat(noChangesPaths); - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = ["README.md"].concat(noChangesPaths); + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "Undoing add: README.md\n" + "No pending changes were found for " + noChangesPaths[0] + "\n" + @@ -262,17 +262,17 @@ describe("Tfvc-UndoCommand", function() { stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], "README.md"); }); //If all files have no pending changes, exit code is 100 but we don't want to fail it("should verify parse output - multiple files - all no pending changes", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "" + "No pending changes were found for " + noChangesPaths[0] + "\n" + @@ -280,16 +280,16 @@ describe("Tfvc-UndoCommand", function() { stderr: undefined }; - let filesUndone: string[] = await cmd.ParseOutput(executionResult); + const filesUndone: string[] = await cmd.ParseOutput(executionResult); assert.isDefined(filesUndone); assert.equal(filesUndone.length, 0); }); it("should verify parse output - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined @@ -310,118 +310,118 @@ describe("Tfvc-UndoCommand", function() { ***********************************************************************************************/ it("should verify parse EXE output - no output", async function() { - let localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["/usr/alias/repos/Tfvc.L2VSCodeExtension.RC/README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 0); }); it("should verify parse EXE output - single file edit - no errors", async function() { - let localPaths: string[] = ["README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Undoing edit: README.md\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], "README.md"); }); it("should verify parse EXE output - single file add - no errors", async function() { - let localPaths: string[] = ["README.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Undoing add: README.md\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], "README.md"); }); it("should verify parse EXE output - multiple file add - no errors", async function() { - let localPaths: string[] = ["README.md", "README2.md"]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = ["README.md", "README2.md"]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "Undoing add: README.md\n" + "Undoing add: README2.md\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 2); assert.equal(filesUndone[0], "README.md"); assert.equal(filesUndone[1], "README2.md"); }); it("should verify parse EXE output - single folder+file edit - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "file1.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "file1.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "folder1:\n" + "Undoing edit: file1.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); it("should verify parse EXE output - single subfolder+file add - no errors", async function() { - let localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("folder1", "folder2", "file2.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("folder1", "folder2") + ":\n" + "Undoing edit: file2.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); it("should verify parse EXE output - single folder+file edit - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "file1.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "file1.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: "fold er1:\n" + "Undoing edit: file1.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); it("should verify parse EXE output - single subfolder+file add - spaces - no errors", async function() { - let localPaths: string[] = [path.join("fold er1", "fol der2", "file2.txt")]; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const localPaths: string[] = [path.join("fold er1", "fol der2", "file2.txt")]; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 0, stdout: path.join("fold er1", "fol der2") + ":\n" + "Undoing edit: file2.txt\n", stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], localPaths[0]); }); @@ -429,10 +429,10 @@ describe("Tfvc-UndoCommand", function() { //If we have at least 1 file undone but at least 1 with no pending changes, exit code is 1 //Proceed normally but ignore the files that have no pending changes. it("should verify parse EXE output - multiple files - several no pending changes", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = ["README.md"].concat(noChangesPaths); - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = ["README.md"].concat(noChangesPaths); + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 1, stdout: "Undoing add: README.md\n" + "No pending changes were found for " + noChangesPaths[0] + ".\n" + @@ -440,17 +440,17 @@ describe("Tfvc-UndoCommand", function() { stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.equal(filesUndone.length, 1); assert.equal(filesUndone[0], "README.md"); }); //If all files have no pending changes, exit code is 100 but we don't want to fail it("should verify parse EXE output - multiple files - all no pending changes", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 100, stdout: "" + "No pending changes were found for " + noChangesPaths[0] + ".\n" + @@ -458,16 +458,16 @@ describe("Tfvc-UndoCommand", function() { stderr: undefined }; - let filesUndone: string[] = await cmd.ParseExeOutput(executionResult); + const filesUndone: string[] = await cmd.ParseExeOutput(executionResult); assert.isDefined(filesUndone); assert.equal(filesUndone.length, 0); }); it("should verify parse EXE output - error exit code", async function() { - let noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; - let localPaths: string[] = noChangesPaths; - let cmd: Undo = new Undo(undefined, localPaths); - let executionResult: IExecutionResult = { + const noChangesPaths: string[] = [path.join("folder1", "file1.txt"), path.join("folder2", "file2.txt")]; + const localPaths: string[] = noChangesPaths; + const cmd: Undo = new Undo(undefined, localPaths); + const executionResult: IExecutionResult = { exitCode: 42, stdout: "Something bad this way comes.", stderr: undefined diff --git a/test/tfvc/scm/resourcegroup.test.ts b/test/tfvc/scm/resourcegroup.test.ts index 1ad70fd9a3..8badbd3768 100644 --- a/test/tfvc/scm/resourcegroup.test.ts +++ b/test/tfvc/scm/resourcegroup.test.ts @@ -15,21 +15,21 @@ describe("Tfvc-ResourceGroups", function() { }); it("should verify ConflictsGroup - constructor", function() { - let group = new ConflictsGroup([]); + const group: ConflictsGroup = new ConflictsGroup([]); assert.equal(group.id, "conflicts"); assert.equal(group.label, Strings.ConflictsGroupName); assert.equal(group.resources.length, 0); }); it("should verify ExcludedGroup - constructor", function() { - let group = new ExcludedGroup([]); + const group: ExcludedGroup = new ExcludedGroup([]); assert.equal(group.id, "excluded"); assert.equal(group.label, Strings.ExcludedGroupName); assert.equal(group.resources.length, 0); }); it("should verify IncludedGroup - constructor", function() { - let group = new IncludedGroup([]); + const group: IncludedGroup = new IncludedGroup([]); assert.equal(group.id, "included"); assert.equal(group.label, Strings.IncludedGroupName); assert.equal(group.resources.length, 0); diff --git a/test/tfvc/tfvcerror.test.ts b/test/tfvc/tfvcerror.test.ts index 461c006e0a..e54cf4bc30 100644 --- a/test/tfvc/tfvcerror.test.ts +++ b/test/tfvc/tfvcerror.test.ts @@ -19,7 +19,7 @@ describe("Tfvc-Error", function() { }); it("should verify constructor - empty data", function() { - let error: TfvcError = new TfvcError({ + const error: TfvcError = new TfvcError({ error: undefined, exitCode: 0, message: undefined, @@ -38,7 +38,7 @@ describe("Tfvc-Error", function() { }); it("should verify constructor - error not empty", function() { - let error: TfvcError = new TfvcError({ + const error: TfvcError = new TfvcError({ error: { name: "err1", message: "error1 message" }, exitCode: 0, message: undefined, @@ -58,7 +58,7 @@ describe("Tfvc-Error", function() { }); it("should verify constructor - error.message over message", function() { - let error: TfvcError = new TfvcError({ + const error: TfvcError = new TfvcError({ error: { name: "err1", message: "error1 message" }, exitCode: 0, message: "other message", @@ -78,7 +78,7 @@ describe("Tfvc-Error", function() { }); it("should verify constructor - no error", function() { - let error: TfvcError = new TfvcError({ + const error: TfvcError = new TfvcError({ error: undefined, exitCode: 100, message: "other message", @@ -97,7 +97,7 @@ describe("Tfvc-Error", function() { }); it("should verify CreateArgumentMissingError", function() { - let error: TfvcError = TfvcError.CreateArgumentMissingError("arg1"); + const error: TfvcError = TfvcError.CreateArgumentMissingError("arg1"); assert.equal(error.error, undefined); assert.equal(error.exitCode, undefined); assert.equal(error.message, "Argument is required: arg1"); @@ -108,7 +108,7 @@ describe("Tfvc-Error", function() { }); it("should verify CreateInvalidStateError", function() { - let error: TfvcError = TfvcError.CreateInvalidStateError(); + const error: TfvcError = TfvcError.CreateInvalidStateError(); assert.equal(error.error, undefined); assert.equal(error.exitCode, undefined); assert.equal(error.message, "The TFVC SCMProvider is in an invalid state for this action."); @@ -119,7 +119,7 @@ describe("Tfvc-Error", function() { }); it("should verify CreateUnknownError", function() { - let error: TfvcError = TfvcError.CreateUnknownError({ name: "err1", message: "error1 message" }); + const error: TfvcError = TfvcError.CreateUnknownError({ name: "err1", message: "error1 message" }); assert.equal(error.error.name, "err1"); assert.equal(error.error.message, "error1 message"); assert.equal(error.exitCode, undefined); @@ -131,7 +131,7 @@ describe("Tfvc-Error", function() { }); it("should verify toString", function() { - let error: TfvcError = new TfvcError({ + const error: TfvcError = new TfvcError({ error: { name: "err1", message: "error1 message", stack: "here; then there" }, exitCode: 11, message: undefined, diff --git a/test/tfvc/tfvcversion.test.ts b/test/tfvc/tfvcversion.test.ts index 5681eb1e52..733d7fa824 100644 --- a/test/tfvc/tfvcversion.test.ts +++ b/test/tfvc/tfvcversion.test.ts @@ -14,7 +14,7 @@ describe("Tfvc-Version", function() { }); it("should verify constructor", function() { - let version: TfvcVersion = new TfvcVersion(12, 11, 10, ""); + const version: TfvcVersion = new TfvcVersion(12, 11, 10, ""); assert.equal(version.ToString(), "12.11.10"); assert.equal(version.Major, 12); assert.equal(version.Minor, 11); @@ -23,7 +23,7 @@ describe("Tfvc-Version", function() { }); it("should verify constructor - with build", function() { - let version: TfvcVersion = new TfvcVersion(12, 11, 10, "buildpart"); + const version: TfvcVersion = new TfvcVersion(12, 11, 10, "buildpart"); assert.equal(version.ToString(), "12.11.10.buildpart"); assert.equal(version.Major, 12); assert.equal(version.Minor, 11); @@ -32,7 +32,7 @@ describe("Tfvc-Version", function() { }); it("should verify constructor - with dotted build", function() { - let version: TfvcVersion = new TfvcVersion(12, 11, 10, "build.part."); + const version: TfvcVersion = new TfvcVersion(12, 11, 10, "build.part."); assert.equal(version.ToString(), "12.11.10.build.part."); assert.equal(version.Major, 12); assert.equal(version.Minor, 11); @@ -41,7 +41,7 @@ describe("Tfvc-Version", function() { }); it("should verify FromString", function() { - let version: TfvcVersion = TfvcVersion.FromString("12.11.10.build.part."); + const version: TfvcVersion = TfvcVersion.FromString("12.11.10.build.part."); assert.equal(version.ToString(), "12.11.10.build.part."); assert.equal(version.Major, 12); assert.equal(version.Minor, 11); @@ -50,7 +50,7 @@ describe("Tfvc-Version", function() { }); it("should verify FromString - missing build", function() { - let version: TfvcVersion = TfvcVersion.FromString("12.11.10"); + const version: TfvcVersion = TfvcVersion.FromString("12.11.10"); assert.equal(version.ToString(), "12.11.10"); assert.equal(version.Major, 12); assert.equal(version.Minor, 11); @@ -59,7 +59,7 @@ describe("Tfvc-Version", function() { }); it("should verify FromString - missing revision", function() { - let version: TfvcVersion = TfvcVersion.FromString("12.11"); + const version: TfvcVersion = TfvcVersion.FromString("12.11"); assert.equal(version.ToString(), "12.11.0"); assert.equal(version.Major, 12); assert.equal(version.Minor, 11); @@ -68,7 +68,7 @@ describe("Tfvc-Version", function() { }); it("should verify FromString - undefined", function() { - let version: TfvcVersion = TfvcVersion.FromString(undefined); + const version: TfvcVersion = TfvcVersion.FromString(undefined); assert.equal(version.ToString(), "0.0.0"); assert.equal(version.Major, 0); assert.equal(version.Minor, 0); @@ -77,29 +77,29 @@ describe("Tfvc-Version", function() { }); it("should verify Compare", function() { - let version1: TfvcVersion = TfvcVersion.FromString("12.11"); - let version2: TfvcVersion = TfvcVersion.FromString("12.11.10"); + const version1: TfvcVersion = TfvcVersion.FromString("12.11"); + const version2: TfvcVersion = TfvcVersion.FromString("12.11.10"); assert.isTrue(TfvcVersion.Compare(version1, version2) < 0); assert.isTrue(TfvcVersion.Compare(version2, version1) > 0); }); it("should verify Compare - major difference", function() { - let version1: TfvcVersion = TfvcVersion.FromString("12.11"); - let version2: TfvcVersion = TfvcVersion.FromString("13.1.1"); + const version1: TfvcVersion = TfvcVersion.FromString("12.11"); + const version2: TfvcVersion = TfvcVersion.FromString("13.1.1"); assert.isTrue(TfvcVersion.Compare(version1, version2) < 0); assert.isTrue(TfvcVersion.Compare(version2, version1) > 0); }); it("should verify Compare - minor difference", function() { - let version1: TfvcVersion = TfvcVersion.FromString("12.11"); - let version2: TfvcVersion = TfvcVersion.FromString("12.13.1"); + const version1: TfvcVersion = TfvcVersion.FromString("12.11"); + const version2: TfvcVersion = TfvcVersion.FromString("12.13.1"); assert.isTrue(TfvcVersion.Compare(version1, version2) < 0); assert.isTrue(TfvcVersion.Compare(version2, version1) > 0); }); it("should verify Compare - equals", function() { - let version1: TfvcVersion = TfvcVersion.FromString("12.11.10"); - let version2: TfvcVersion = TfvcVersion.FromString("12.11.10"); + const version1: TfvcVersion = TfvcVersion.FromString("12.11.10"); + const version2: TfvcVersion = TfvcVersion.FromString("12.11.10"); assert.isTrue(TfvcVersion.Compare(version1, version2) === 0); assert.isTrue(TfvcVersion.Compare(version2, version1) === 0); }); From 47ff138be64936a414f07f57b2f8746d3111ac3c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 May 2017 11:02:52 -0400 Subject: [PATCH 2/6] Remove vscodeutils.interfaces from code coverage --- gulpfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gulpfile.js b/gulpfile.js index 6388f08ee5..ab11e11566 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -109,6 +109,7 @@ gulp.task('test-coverage', function() { ,'!out/src/contexts/repocontextfactory.js' ,'!out/src/contexts/tfvccontext.js' ,'!out/src/helpers/settings.js' + ,'!out/src/helpers/vscodeutils.interfaces.js' ,'!out/src/helpers/vscodeutils.js' ,'!out/src/services/telemetry.js' ,'!out/src/services/coreapi.js' From 6d9366e529c8f6707885392af9cc7c12212ae464 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 May 2017 11:03:10 -0400 Subject: [PATCH 3/6] Cover server workspace detection --- test/tfvc/commands/commandhelper.test.ts | 114 +++++++++++++---------- 1 file changed, 66 insertions(+), 48 deletions(-) diff --git a/test/tfvc/commands/commandhelper.test.ts b/test/tfvc/commands/commandhelper.test.ts index 1e005df455..80862ccfda 100644 --- a/test/tfvc/commands/commandhelper.test.ts +++ b/test/tfvc/commands/commandhelper.test.ts @@ -15,42 +15,42 @@ import { CommandHelper } from "../../../src/tfvc/commands/commandhelper"; describe("Tfvc-CommandHelper", function() { it("should verify RequireArgument - success", function() { - let arg: any = { prop1: "prop 1" }; + const arg: any = { prop1: "prop 1" }; CommandHelper.RequireArgument(arg, "arg"); }); it("should verify RequireArgument - failure", function() { - let arg: any = undefined; + const arg: any = undefined; assert.throws(() => CommandHelper.RequireArgument(arg, "arg"), TfvcError, /Argument is required/); }); it("should verify RequireStringArgument - success", function() { - let arg: string = "myString"; + const arg: string = "myString"; CommandHelper.RequireStringArgument(arg, "arg"); }); it("should verify RequireStringArgument - failure", function() { - let arg: string = ""; + const arg: string = ""; assert.throws(() => CommandHelper.RequireStringArgument(arg, "arg"), TfvcError, /Argument is required/); }); it("should verify RequireStringArrayArgument - success", function() { - let arg: string[] = ["myString"]; + const arg: string[] = ["myString"]; CommandHelper.RequireStringArrayArgument(arg, "arg"); }); it("should verify RequireStringArrayArgument - failure - empty array", function() { - let arg: string[] = []; + const arg: string[] = []; assert.throws(() => CommandHelper.RequireStringArrayArgument(arg, "arg"), TfvcError, /Argument is required/); }); it("should verify RequireStringArrayArgument - failure - undefined", function() { - let arg: string[] = undefined; + const arg: string[] = undefined; assert.throws(() => CommandHelper.RequireStringArrayArgument(arg, "arg"), TfvcError, /Argument is required/); }); it("should verify HasError - no errors", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 123, stdout: undefined, stderr: undefined @@ -63,7 +63,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify HasError - has errors", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 123, stdout: undefined, stderr: "Something bad happened!" @@ -79,7 +79,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - no errors", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 0, stdout: undefined, stderr: undefined @@ -88,7 +88,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - bad exit code only", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: undefined @@ -104,7 +104,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - auth failed", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "Authentication failed" @@ -121,7 +121,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - auth failed", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "workspace could not be determined" @@ -138,7 +138,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - no workspace", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "workspace could not be determined" @@ -155,7 +155,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - no repo", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "Repository not found" @@ -172,7 +172,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - no collection", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "project collection URL to use could not be determined" @@ -189,7 +189,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - access denied", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "Access denied connecting: some other text: authenticating as OAuth" @@ -206,7 +206,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - no java", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "'java' is not recognized as an internal or external command" @@ -223,7 +223,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - no mapping", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "There is no working folder mapping" @@ -240,7 +240,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - not in workspace", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "could not be found in your workspace, or you do not have permission to access it." @@ -256,8 +256,27 @@ describe("Tfvc-CommandHelper", function() { } }); + it("should verify ProcessErrors - Server workspace detection (TF30063)", function() { + const result: IExecutionResult = { + exitCode: 100, + stdout: undefined, + stderr: "TF30063: You are not authorized to access anything because I said so" + }; + try { + CommandHelper.ProcessErrors("cmd", result, false); + } catch (err) { + assert.equal(err.exitCode, 100); + assert.equal(err.tfvcCommand, "cmd"); + assert.equal(err.tfvcErrorCode, TfvcErrorCodes.NotAuthorizedToAccess); + assert.isTrue(err.message.startsWith(Strings.TfServerWorkspace)); + assert.isDefined(err.messageOptions); + assert.isTrue(err.messageOptions.length === 1); + assert.equal(err.stdout, undefined); + } + }); + it("should verify ProcessErrors - showFirstError - stderr", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: undefined, stderr: "something bad" @@ -274,7 +293,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ProcessErrors - showFirstError - stdout", function() { - let result: IExecutionResult = { + const result: IExecutionResult = { exitCode: 100, stdout: "something bad", stderr: undefined @@ -291,8 +310,8 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify SplitIntoLines", function() { - let text: string = "one\ntwo\r\nthree\r\nfour\nfive\n"; - let lines: string[] = CommandHelper.SplitIntoLines(text); + const text: string = "one\ntwo\r\nthree\r\nfour\nfive\n"; + const lines: string[] = CommandHelper.SplitIntoLines(text); assert.equal(lines.length, 6); assert.equal(lines[0], "one"); assert.equal(lines[1], "two"); @@ -303,22 +322,21 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify SplitIntoLines - undefined input", function() { - let text: string; - let lines: string[] = CommandHelper.SplitIntoLines(text); + const lines: string[] = CommandHelper.SplitIntoLines(undefined); assert.isDefined(lines); assert.equal(lines.length, 0); }); it("should verify SplitIntoLines - empty input", function() { - let text: string = ""; - let lines: string[] = CommandHelper.SplitIntoLines(text); + const text: string = ""; + const lines: string[] = CommandHelper.SplitIntoLines(text); assert.isDefined(lines); assert.equal(lines.length, 0); }); it("should verify SplitIntoLines - trim WARNings", function() { - let text: string = "WARN 1\nWARN 2\nwarning\none\ntwo\r\n\n"; - let lines: string[] = CommandHelper.SplitIntoLines(text); + const text: string = "WARN 1\nWARN 2\nwarning\none\ntwo\r\n\n"; + const lines: string[] = CommandHelper.SplitIntoLines(text); assert.equal(lines.length, 5); assert.equal(lines[0], "warning"); assert.equal(lines[1], "one"); @@ -328,8 +346,8 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify SplitIntoLines - leave WARNings", function() { - let text: string = "WARN 1\nWARN 2\nwarning\none\ntwo\r\n\n"; - let lines: string[] = CommandHelper.SplitIntoLines(text, false); + const text: string = "WARN 1\nWARN 2\nwarning\none\ntwo\r\n\n"; + const lines: string[] = CommandHelper.SplitIntoLines(text, false); assert.equal(lines.length, 7); assert.equal(lines[0], "WARN 1"); assert.equal(lines[1], "WARN 2"); @@ -341,8 +359,8 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify SplitIntoLines - filter empty lines", function() { - let text: string = "zero\n \none\ntwo\r\n"; //ensure there's a line with just spaces too - let lines: string[] = CommandHelper.SplitIntoLines(text, false, true); + const text: string = "zero\n \none\ntwo\r\n"; //ensure there's a line with just spaces too + const lines: string[] = CommandHelper.SplitIntoLines(text, false, true); assert.equal(lines.length, 3); assert.equal(lines[0], "zero"); assert.equal(lines[1], "one"); @@ -350,8 +368,8 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify SplitIntoLines - leave empty lines", function() { - let text: string = "one\ntwo\n\nthree\nfour\n\n"; - let lines: string[] = CommandHelper.SplitIntoLines(text); + const text: string = "one\ntwo\n\nthree\nfour\n\n"; + const lines: string[] = CommandHelper.SplitIntoLines(text); assert.equal(lines.length, 7); assert.equal(lines[0], "one"); assert.equal(lines[1], "two"); @@ -363,8 +381,8 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify TrimToXml", async function() { - let text: string = "WARN 1\nWARN 2\nwarning\n\r\n\r\n\n\n"; - let xml: string = CommandHelper.TrimToXml(text); + const text: string = "WARN 1\nWARN 2\nwarning\n\r\n\r\n\n\n"; + const xml: string = CommandHelper.TrimToXml(text); assert.equal(xml, "\r\n\r\n"); }); @@ -374,7 +392,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ParseXml - undefined input", async function() { - let xml: any = await CommandHelper.ParseXml(undefined); + const xml: any = await CommandHelper.ParseXml(undefined); assert.isUndefined(xml); }); @@ -388,9 +406,9 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify ParseXml", async function() { - let text: string = "\r\nchild two\r\n\n\n"; - let xml: any = await CommandHelper.ParseXml(text); - let expectedJSON = { + const text: string = "\r\nchild two\r\n\n\n"; + const xml: any = await CommandHelper.ParseXml(text); + const expectedJSON = { "one": { "$": { "attr1": "35", @@ -412,7 +430,7 @@ describe("Tfvc-CommandHelper", function() { }); it("should verify GetChangesetNumber", async function() { - let text: string = "/Users/leantk/tfvc-tfs/tfsTest_01/addFold:\n" + + const text: string = "/Users/leantk/tfvc-tfs/tfsTest_01/addFold:\n" + "Checking in edit: testHere.txt\n" + "\n" + "/Users/leantk/tfvc-tfs/tfsTest_01:\n" + @@ -420,19 +438,19 @@ describe("Tfvc-CommandHelper", function() { "Checking in edit: TestAdd.txt\n" + "\n" + "Changeset #23 checked in.\n"; - let changeset: string = CommandHelper.GetChangesetNumber(text); + const changeset: string = CommandHelper.GetChangesetNumber(text); assert.equal(changeset, "23"); }); it("should verify GetChangesetNumber - exact", async function() { - let text: string = "Changeset #20 checked in."; - let changeset: string = CommandHelper.GetChangesetNumber(text); + const text: string = "Changeset #20 checked in."; + const changeset: string = CommandHelper.GetChangesetNumber(text); assert.equal(changeset, "20"); }); it("should verify GetChangesetNumber - no match", async function() { - let text: string = "WARN 1\nWARN 2\ntext\nChangeset # checked in.\n\r\ntext\r\nmore text\n\n"; - let changeset: string = CommandHelper.GetChangesetNumber(text); + const text: string = "WARN 1\nWARN 2\ntext\nChangeset # checked in.\n\r\ntext\r\nmore text\n\n"; + const changeset: string = CommandHelper.GetChangesetNumber(text); assert.equal(changeset, ""); }); From 8246a48dd6a0dc382188471209474a44c8397651 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 May 2017 11:03:38 -0400 Subject: [PATCH 4/6] Add 'zero results query' test coverage --- .../helpers-integration/testsettings.ts | 78 ++++++++-------- .../workitemtracking.integration.test.ts | 91 ++++++++++++------- 2 files changed, 100 insertions(+), 69 deletions(-) diff --git a/test-integration/helpers-integration/testsettings.ts b/test-integration/helpers-integration/testsettings.ts index e07bfd60b5..d68d9dac7d 100644 --- a/test-integration/helpers-integration/testsettings.ts +++ b/test-integration/helpers-integration/testsettings.ts @@ -5,20 +5,19 @@ "use strict"; export class TestSettings { - public static get SuiteTimeout(): number { - let timeout : string = process.env.MSVSTS_TEAM_SUITE_TIMEOUT; + const timeout: string = process.env.MSVSTS_TEAM_SUITE_TIMEOUT; return (timeout ? Number(timeout) : 30000); } public static get TestTimeout(): number { - let timeout : string = process.env.MSVSTS_TEAM_TEST_TIMEOUT; + const timeout: string = process.env.MSVSTS_TEAM_TEST_TIMEOUT; return (timeout ? Number(timeout) : 8000); } - public static get Password() : string { - let token : string = process.env.MSVSTS_TEAM_ACCESS_TOKEN; - let password: string = process.env.MSVSTS_TEAM_ACCESS_PASSWORD; + public static get Password(): string { + const token: string = process.env.MSVSTS_TEAM_ACCESS_TOKEN; + const password: string = process.env.MSVSTS_TEAM_ACCESS_PASSWORD; if (password) { return password; } @@ -28,97 +27,102 @@ export class TestSettings { } //Returns just any old token (doesn't have to be an env var) - public static get SettingsPassword() : string { + public static get SettingsPassword(): string { return "kegnf4wasx3n5nwdj5lkutvjavtbbfblygsxcggvpphpmfwvjjov"; } - public static get Account() : string { - let account : string = process.env.MSVSTS_TEAM_ACCOUNT; + public static get Account(): string { + const account: string = process.env.MSVSTS_TEAM_ACCOUNT; return (account || "undefined-account"); } - public static get AccountUrl() : string { - let accountUrl : string = process.env.MSVSTS_TEAM_ACCOUNT_URL; + public static get AccountUrl(): string { + const accountUrl: string = process.env.MSVSTS_TEAM_ACCOUNT_URL; return (accountUrl || "undefined-account-url"); } - public static get AccountUser() : string { - let accountUser : string = process.env.MSVSTS_TEAM_ACCOUNT_USER; + public static get AccountUser(): string { + const accountUser : string = process.env.MSVSTS_TEAM_ACCOUNT_USER; return (accountUser || "OAuth-integration-tests"); } - public static get BuildDefinitionId() : number { - let id : string = process.env.MSVSTS_TEAM_BUILD_DEFINITION_ID; + public static get BuildDefinitionId(): number { + const id: string = process.env.MSVSTS_TEAM_BUILD_DEFINITION_ID; return (id ? Number(id) : -1); } - public static get BuildId() : number { - let id : string = process.env.MSVSTS_TEAM_BUILD_ID; + public static get BuildId(): number { + const id: string = process.env.MSVSTS_TEAM_BUILD_ID; return (id ? Number(id) : -1); } - public static get CollectionName() : string { - let collectionName : string = process.env.MSVSTS_TEAM_COLLECTION_NAME; + public static get CollectionName(): string { + const collectionName: string = process.env.MSVSTS_TEAM_COLLECTION_NAME; return (collectionName || "undefined-collection-name"); } - public static get RemoteRepositoryUrl() : string { - let remoteRepositoryUrl : string = process.env.MSVSTS_TEAM_REMOTE_REPOSITORY_URL; + public static get RemoteRepositoryUrl(): string { + const remoteRepositoryUrl: string = process.env.MSVSTS_TEAM_REMOTE_REPOSITORY_URL; return (remoteRepositoryUrl || "undefined-remote-repository-url"); } - public static get RemoteTfvcRepositoryUrl() : string { - let remoteRepositoryUrl : string = process.env.MSVSTS_TEAM_REMOTE_TFVC_REPOSITORY_URL; + public static get RemoteTfvcRepositoryUrl(): string { + const remoteRepositoryUrl: string = process.env.MSVSTS_TEAM_REMOTE_TFVC_REPOSITORY_URL; return (remoteRepositoryUrl || "undefined-remote-tfvc-repository-url"); } public static get RepositoryId(): string { - let repositoryId : string = process.env.MSVSTS_TEAM_REPOSITORY_ID; + const repositoryId: string = process.env.MSVSTS_TEAM_REPOSITORY_ID; return (repositoryId || "undefined-repository-id"); } public static get RepositoryName(): string { - let repositoryName : string = process.env.MSVSTS_TEAM_REPOSITORY_NAME; + const repositoryName: string = process.env.MSVSTS_TEAM_REPOSITORY_NAME; return (repositoryName || "undefined-repository-name"); } public static get TeamProject(): string { - let teamProject : string = process.env.MSVSTS_TEAM_TEAM_PROJECT; + const teamProject: string = process.env.MSVSTS_TEAM_TEAM_PROJECT; return (teamProject || "undefined-team-project"); } - public static get WorkItemId() : number { - let id : string = process.env.MSVSTS_TEAM_WORK_ITEM_ID; + public static get WorkItemId(): number { + const id: string = process.env.MSVSTS_TEAM_WORK_ITEM_ID; return (id ? Number(id) : -1); } - public static get WorkItemQueryId() : string { - let workItemQueryId : string = process.env.MSVSTS_TEAM_WORK_ITEM_QUERY_ID; + public static get WorkItemQueryId(): string { + const workItemQueryId: string = process.env.MSVSTS_TEAM_WORK_ITEM_QUERY_ID; return (workItemQueryId || "undefined-workitem-query-id"); } public static get WorkItemLinkQueryPath(): string { - let workItemQueryPath : string = process.env.MSVSTS_TEAM_WORK_ITEM_LINK_QUERY_PATH; + const workItemQueryPath: string = process.env.MSVSTS_TEAM_WORK_ITEM_LINK_QUERY_PATH; return (workItemQueryPath || "undefined-workitem-link-query-id"); } public static get WorkItemQueryPath(): string { - let workItemQueryPath : string = process.env.MSVSTS_TEAM_WORK_ITEM_QUERY_PATH; + const workItemQueryPath: string = process.env.MSVSTS_TEAM_WORK_ITEM_QUERY_PATH; return (workItemQueryPath || "undefined-workitem-query-path"); } public static get WorkItemTwoHundredTasksQueryPath(): string { - let workItemQueryPath : string = process.env.MSVSTS_TEAM_WORK_ITEM_TWO_HUNDRED_QUERY_PATH; + const workItemQueryPath: string = process.env.MSVSTS_TEAM_WORK_ITEM_TWO_HUNDRED_QUERY_PATH; return (workItemQueryPath || "undefined-workitem-twohundredtasks-query-path"); } - public static get ProjectGuid() : string { - let remoteRepositoryUrl : string = process.env.MSVSTS_TEAM_PROJECT_GUID; + public static get WorkItemZeroResultsQueryPath(): string { + const workItemQueryPath: string = process.env.MSVSTS_TEAM_WORK_ITEM_ZERO_RESULTS_QUERY_PATH; + return (workItemQueryPath || "undefined-workitem-query-path"); + } + + public static get ProjectGuid(): string { + const remoteRepositoryUrl: string = process.env.MSVSTS_TEAM_PROJECT_GUID; return (remoteRepositoryUrl || "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); } - public static get CollectionGuid() : string { - let remoteRepositoryUrl : string = process.env.MSVSTS_TEAM_COLLECTION_GUID; + public static get CollectionGuid(): string { + const remoteRepositoryUrl: string = process.env.MSVSTS_TEAM_COLLECTION_GUID; return (remoteRepositoryUrl || "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); } } diff --git a/test-integration/services/workitemtracking.integration.test.ts b/test-integration/services/workitemtracking.integration.test.ts index 56fbcb16f0..33bd8b46a0 100644 --- a/test-integration/services/workitemtracking.integration.test.ts +++ b/test-integration/services/workitemtracking.integration.test.ts @@ -18,8 +18,8 @@ import { SimpleWorkItem, WorkItemTrackingService } from "../../src/services/work describe("WorkItemTrackingService-Integration", function() { this.timeout(TestSettings.SuiteTimeout); - let credentialManager: CredentialManager = new CredentialManager(); - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const credentialManager: CredentialManager = new CredentialManager(); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); before(function() { UserAgentProvider.VSCodeVersion = "0.0.0"; @@ -38,29 +38,29 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.CreateWorkItem", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let itemType : string = "Bug"; - let today: Date = new Date(); - let title: string = "Work item created by integration test (" + today.toLocaleString() + ")"; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let item: WorkItem = await svc.CreateWorkItem(ctx, itemType, title); + const itemType : string = "Bug"; + const today: Date = new Date(); + const title: string = "Work item created by integration test (" + today.toLocaleString() + ")"; + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const item: WorkItem = await svc.CreateWorkItem(ctx, itemType, title); assert.isNotNull(item, "item was null when it shouldn't have been"); }); it("should verify WorkItemTrackingService.GetWorkItems", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let items: SimpleWorkItem[] = await svc.GetWorkItems(TestSettings.TeamProject, WitQueries.MyWorkItems); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const items: SimpleWorkItem[] = await svc.GetWorkItems(TestSettings.TeamProject, WitQueries.MyWorkItems); assert.isNotNull(items, "items was null when it shouldn't have been"); //console.log(items); }); @@ -68,17 +68,17 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.GetQueryResultCount", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let query: QueryHierarchyItem = await svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemQueryPath); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const query: QueryHierarchyItem = await svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemQueryPath); assert.isNotNull(query); //console.log(query); expect(query.id).to.equal(TestSettings.WorkItemQueryId); - let count: number = await svc.GetQueryResultCount(TestSettings.TeamProject, query.wiql); + const count: number = await svc.GetQueryResultCount(TestSettings.TeamProject, query.wiql); //console.log("count = " + count); expect(count).to.be.at.least(2); }); @@ -86,13 +86,13 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.GetWorkItemHierarchyItems", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let items: QueryHierarchyItem[] = await svc.GetWorkItemHierarchyItems(TestSettings.TeamProject); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const items: QueryHierarchyItem[] = await svc.GetWorkItemHierarchyItems(TestSettings.TeamProject); assert.isNotNull(items); //console.log(items.length); expect(items.length).to.equal(2); @@ -101,30 +101,30 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.GetWorkItemQuery", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let query: QueryHierarchyItem = await svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemQueryPath); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const query: QueryHierarchyItem = await svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemQueryPath); assert.isNotNull(query); //console.log(query); expect(query.id).to.equal(TestSettings.WorkItemQueryId); - let items: SimpleWorkItem[] = await svc.GetWorkItems(TestSettings.TeamProject, query.wiql); + const items: SimpleWorkItem[] = await svc.GetWorkItems(TestSettings.TeamProject, query.wiql); assert.isTrue(items.length > 0); }); it("should verify WorkItemTrackingService.GetWorkItemTypes", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let items: WorkItemType[] = await svc.GetWorkItemTypes(TestSettings.TeamProject); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const items: WorkItemType[] = await svc.GetWorkItemTypes(TestSettings.TeamProject); assert.isNotNull(items); //console.log(items.length); expect(items.length).to.equal(7); @@ -133,13 +133,13 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.GetWorkItemById", async function() { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); - let item: SimpleWorkItem = await svc.GetWorkItemById(TestSettings.WorkItemId.toString()); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const item: SimpleWorkItem = await svc.GetWorkItemById(TestSettings.WorkItemId.toString()); assert.isNotNull(item); //console.log(items.length); expect(item.id).to.equal(TestSettings.WorkItemId.toString()); @@ -148,12 +148,12 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.GetWorkItemQuery with a Link query", function(done) { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemLinkQueryPath).then( function (query) { assert.isNotNull(query); @@ -175,12 +175,12 @@ describe("WorkItemTrackingService-Integration", function() { it("should verify WorkItemTrackingService.GetWorkItemQuery with maximum 200 results", function(done) { this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts - let ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); ctx.RepoInfo = Mocks.RepositoryInfo(); ctx.UserInfo = undefined; - let svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemTwoHundredTasksQueryPath).then( function (query) { assert.isNotNull(query); @@ -200,4 +200,31 @@ describe("WorkItemTrackingService-Integration", function() { ); }); + it("should verify WorkItemTrackingService.GetWorkItemQuery which returns zero results", function(done) { + this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts + + const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl); + ctx.CredentialHandler = CredentialManager.GetCredentialHandler(); + ctx.RepoInfo = Mocks.RepositoryInfo(); + ctx.UserInfo = undefined; + + const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx); + svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemZeroResultsQueryPath).then( + function (query) { + assert.isNotNull(query); + //console.log(query); + svc.GetWorkItems(TestSettings.TeamProject, query.wiql).then((items) => { + assert.isTrue(items.length === 0, "Expected zero results but actually got some."); + //assert.isTrue(items.length === 200, "Expected the maximum of 200 work items but didn't get that amount."); // current maximum work items returned + done(); + }).catch((err) => { + done(err); + }); + }, + function (err) { + done(err); + } + ); + }); + }); From 8c6fa6779f4a40766e16afc1956c12207eea3c4a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 May 2017 13:18:11 -0400 Subject: [PATCH 5/6] Enable `prefer-const` in tslint.json --- src/clients/baseclient.ts | 8 ++-- src/clients/buildclient.ts | 16 +++---- src/clients/coreapiclient.ts | 8 ++-- src/clients/feedbackclient.ts | 18 +++---- src/clients/gitclient.ts | 34 ++++++------- src/clients/repositoryinfoclient.ts | 26 +++++----- src/clients/teamservicesclient.ts | 4 +- src/clients/tfscatalogsoapclient.ts | 12 ++--- src/clients/witclient.ts | 48 +++++++++---------- src/contexts/gitcontext.ts | 6 +-- src/contexts/repocontextfactory.ts | 2 +- src/credentialstore/credentialstore.ts | 2 +- .../linux/file-token-storage.ts | 12 ++--- src/credentialstore/linux/linux-file-api.ts | 28 +++++------ src/credentialstore/osx/osx-keychain-api.ts | 30 ++++++------ .../win32/win-credstore-api.ts | 34 ++++++------- src/extensionmanager.ts | 28 +++++------ src/helpers/credentialmanager.ts | 10 ++-- src/helpers/logger.ts | 6 +-- src/helpers/settings.ts | 12 ++--- src/helpers/urlbuilder.ts | 4 +- src/helpers/useragentprovider.ts | 2 +- src/helpers/vscodeutils.ts | 8 ++-- src/info/extensionrequesthandler.ts | 2 +- src/info/repositoryinfo.ts | 4 +- src/services/gitvc.ts | 8 ++-- src/services/telemetry.ts | 6 +-- src/services/workitemtracking.ts | 40 ++++++++-------- src/team-extension.ts | 30 ++++++------ src/tfvc/commands/add.ts | 6 +-- src/tfvc/commands/commandhelper.ts | 6 +-- src/tfvc/commands/delete.ts | 8 ++-- src/tfvc/commands/findconflicts.ts | 2 +- src/tfvc/commands/findworkspace.ts | 4 +- src/tfvc/commands/getfilecontent.ts | 4 +- src/tfvc/commands/getinfo.ts | 2 +- src/tfvc/commands/rename.ts | 6 +-- src/tfvc/commands/resolveconflicts.ts | 2 +- src/tfvc/commands/status.ts | 16 +++---- src/tfvc/commands/sync.ts | 16 +++---- src/tfvc/commands/undo.ts | 12 ++--- src/tfvc/scm/model.ts | 8 ++-- src/tfvc/scm/status.ts | 2 +- src/tfvc/tfcommandlinerunner.ts | 10 ++-- src/tfvc/tfvc-extension.ts | 32 ++++++------- src/tfvc/tfvcscmprovider.ts | 8 ++-- src/tfvc/tfvcversion.ts | 8 ++-- src/tfvc/uihelper.ts | 18 +++---- test/helpers/urlbuilder.test.ts | 2 +- tslint.json | 2 +- 50 files changed, 311 insertions(+), 311 deletions(-) diff --git a/src/clients/baseclient.ts b/src/clients/baseclient.ts index 58d88f71cc..5c4e5066fb 100644 --- a/src/clients/baseclient.ts +++ b/src/clients/baseclient.ts @@ -23,9 +23,9 @@ export abstract class BaseClient { } protected handleError(err: Error, offlineText: string, polling: boolean, infoMessage?: string) : void { - let offline: boolean = Utils.IsOffline(err); - let msg: string = Utils.GetMessageForStatusCode(err, err.message); - let logPrefix: string = (infoMessage === undefined) ? "" : infoMessage + " "; + const offline: boolean = Utils.IsOffline(err); + const msg: string = Utils.GetMessageForStatusCode(err, err.message); + const logPrefix: string = (infoMessage === undefined) ? "" : infoMessage + " "; //When polling, we never display an error, we only log it (no telemetry either) if (polling === true) { @@ -45,7 +45,7 @@ export abstract class BaseClient { } //If we aren't polling, we always log an error and, optionally, send telemetry } else { - let logMessage: string = logPrefix + msg; + const logMessage: string = logPrefix + msg; if (offline === true) { Logger.LogError(logMessage); } else { diff --git a/src/clients/buildclient.ts b/src/clients/buildclient.ts index a6b5d577ec..052d152c5e 100644 --- a/src/clients/buildclient.ts +++ b/src/clients/buildclient.ts @@ -26,7 +26,7 @@ export class BuildClient extends BaseClient { //Gets any available build status information and adds it to the status bar public async DisplayCurrentBuildStatus(context: IRepositoryContext, polling: boolean, definitionId?: number): Promise { try { - let svc: BuildService = new BuildService(this._serverContext); + const svc: BuildService = new BuildService(this._serverContext); Logger.LogInfo("Getting current build from badge..."); let buildBadge: BuildBadge; if (context.Type === RepositoryType.GIT) { @@ -36,7 +36,7 @@ export class BuildClient extends BaseClient { buildBadge = await this.getTfvcBuildBadge(svc, this._serverContext.RepoInfo.TeamProject); } else if (definitionId) { //TODO: Allow definitionId to override Git and TFVC defaults (above)? - let builds: Build[] = await svc.GetBuildsByDefinitionId(this._serverContext.RepoInfo.TeamProject, definitionId); + const builds: Build[] = await svc.GetBuildsByDefinitionId(this._serverContext.RepoInfo.TeamProject, definitionId); if (builds.length > 0) { buildBadge = { buildId: builds[0].id, imageUrl: undefined }; } else { @@ -45,13 +45,13 @@ export class BuildClient extends BaseClient { } if (buildBadge && buildBadge.buildId !== undefined) { Logger.LogInfo("Found build id " + buildBadge.buildId.toString() + ". Getting build details..."); - let build: Build = await svc.GetBuildById(buildBadge.buildId); + const build: Build = await svc.GetBuildById(buildBadge.buildId); this._buildSummaryUrl = BuildService.GetBuildSummaryUrl(this._serverContext.RepoInfo.TeamProjectUrl, build.id.toString()); Logger.LogInfo("Build summary info: " + build.id.toString() + " " + BuildStatus[build.status] + " " + BuildResult[build.result] + " " + this._buildSummaryUrl); if (this._statusBarItem !== undefined) { - let icon: string = Utils.GetBuildResultIcon(build.result); + const icon: string = Utils.GetBuildResultIcon(build.result); this._statusBarItem.command = CommandNames.OpenBuildSummaryPage; this._statusBarItem.text = `$(icon octicon-package) ` + `$(icon ${icon})`; this._statusBarItem.tooltip = "(" + BuildResult[build.result] + ") " + Strings.NavigateToBuildSummary + " " + build.buildNumber; @@ -73,16 +73,16 @@ export class BuildClient extends BaseClient { //Gets the appropriate build for TFVC repositories and returns a 'BuildBadge' for it private async getTfvcBuildBadge(svc: BuildService, teamProjectId: string): Promise { //Create an build that doesn't exist and use as the default - let emptyBuild: BuildBadge = { buildId: undefined, imageUrl: undefined }; + const emptyBuild: BuildBadge = { buildId: undefined, imageUrl: undefined }; - let builds: Build[] = await svc.GetBuilds(teamProjectId); + const builds: Build[] = await svc.GetBuilds(teamProjectId); if (builds.length === 0) { return emptyBuild; } let matchingBuild: Build; - for (let idx = 0; idx < builds.length; idx++) { - let b: Build = builds[idx]; + for (let idx: number = 0; idx < builds.length; idx++) { + const b: Build = builds[idx]; // Ignore canceled builds if (b.result === BuildResult.Canceled) { continue; diff --git a/src/clients/coreapiclient.ts b/src/clients/coreapiclient.ts index 7e4122ea96..63353d7515 100644 --- a/src/clients/coreapiclient.ts +++ b/src/clients/coreapiclient.ts @@ -14,14 +14,14 @@ export class CoreApiClient { /* tslint:enable:no-empty */ public async GetTeamProject(remoteUrl: string, teamProjectName: string): Promise { - let svc: CoreApiService = new CoreApiService(remoteUrl); - let teamProject:TeamProject = await svc.GetTeamProject(teamProjectName); + const svc: CoreApiService = new CoreApiService(remoteUrl); + const teamProject:TeamProject = await svc.GetTeamProject(teamProjectName); return teamProject; } public async GetProjectCollection(remoteUrl: string, collectionName: string): Promise { - let svc: CoreApiService = new CoreApiService(remoteUrl); - let collection:TeamProjectCollection = await svc.GetProjectCollection(collectionName); + const svc: CoreApiService = new CoreApiService(remoteUrl); + const collection:TeamProjectCollection = await svc.GetProjectCollection(collectionName); return collection; } diff --git a/src/clients/feedbackclient.ts b/src/clients/feedbackclient.ts index 2b2582e4f3..6b66bc18ca 100644 --- a/src/clients/feedbackclient.ts +++ b/src/clients/feedbackclient.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ "use strict"; -import { window } from "vscode"; +import { Disposable, window } from "vscode"; import { Logger } from "../helpers/logger"; import { TelemetryEvents } from "../helpers/constants"; import { Strings } from "../helpers/strings"; @@ -21,24 +21,24 @@ export class FeedbackClient { //This feedback will go no matter whether Application Insights is enabled or not. public async SendFeedback(): Promise { try { - let choices: BaseQuickPickItem[] = []; + const choices: BaseQuickPickItem[] = []; choices.push({ label: Strings.SendASmile, description: undefined, id: TelemetryEvents.SendASmile }); choices.push({ label: Strings.SendAFrown, description: undefined, id: TelemetryEvents.SendAFrown }); - let choice: BaseQuickPickItem = await window.showQuickPick(choices, { matchOnDescription: false, placeHolder: Strings.SendFeedback }); + const choice: BaseQuickPickItem = await window.showQuickPick(choices, { matchOnDescription: false, placeHolder: Strings.SendFeedback }); if (choice) { - let value: string = await window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false }); + const value: string = await window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false }); if (value === undefined) { - let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent); + const disposable = window.setStatusBarMessage(Strings.NoFeedbackSent); setInterval(() => disposable.dispose(), 1000 * 5); return; } //User does not need to provide any feedback text let providedEmail: string = ""; - let email: string = await window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false }); + const email: string = await window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false }); if (email === undefined) { - let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent); + const disposable = window.setStatusBarMessage(Strings.NoFeedbackSent); setInterval(() => disposable.dispose(), 1000 * 5); return; } @@ -48,11 +48,11 @@ export class FeedbackClient { //This feedback will go no matter whether Application Insights is enabled or not. Telemetry.SendFeedback(choice.id, { "VSCode.Feedback.Comment" : value, "VSCode.Feedback.Email" : providedEmail} ); - let disposable = window.setStatusBarMessage(Strings.ThanksForFeedback); + const disposable: Disposable = window.setStatusBarMessage(Strings.ThanksForFeedback); setInterval(() => disposable.dispose(), 1000 * 5); } } catch (err) { - let message: string = Utils.GetMessageForStatusCode(0, err.message, "Failed getting SendFeedback selection"); + const message: string = Utils.GetMessageForStatusCode(0, err.message, "Failed getting SendFeedback selection"); Logger.LogError(message); Telemetry.SendException(err); } diff --git a/src/clients/gitclient.ts b/src/clients/gitclient.ts index 2655a86eed..34868da9c0 100644 --- a/src/clients/gitclient.ts +++ b/src/clients/gitclient.ts @@ -30,7 +30,7 @@ export class GitClient extends BaseClient { Telemetry.SendEvent(TelemetryEvents.ViewPullRequests); try { - let request: BaseQuickPickItem = await window.showQuickPick(this.getMyPullRequests(), { matchOnDescription: true, placeHolder: Strings.ChoosePullRequest }); + const request: BaseQuickPickItem = await window.showQuickPick(this.getMyPullRequests(), { matchOnDescription: true, placeHolder: Strings.ChoosePullRequest }); if (request) { Telemetry.SendEvent(TelemetryEvents.ViewPullRequest); let discUrl: string = undefined; @@ -52,7 +52,7 @@ export class GitClient extends BaseClient { this.ensureGitContext(context); let url: string = undefined; - let editor = window.activeTextEditor; + const editor = window.activeTextEditor; if (editor) { Telemetry.SendEvent(TelemetryEvents.OpenBlamePage); @@ -65,7 +65,7 @@ export class GitClient extends BaseClient { Logger.LogInfo("OpenBlame: " + url); Utils.OpenUrl(url); } else { - let msg: string = Utils.GetMessageForStatusCode(0, Strings.NoSourceFileForBlame); + const msg: string = Utils.GetMessageForStatusCode(0, Strings.NoSourceFileForBlame); Logger.LogError(msg); VsCodeUtils.ShowErrorMessage(msg); } @@ -76,7 +76,7 @@ export class GitClient extends BaseClient { this.ensureGitContext(context); let historyUrl: string = undefined; - let editor = window.activeTextEditor; + const editor = window.activeTextEditor; if (!editor) { Telemetry.SendEvent(TelemetryEvents.OpenRepositoryHistory); @@ -100,7 +100,7 @@ export class GitClient extends BaseClient { public OpenNewPullRequest(remoteUrl: string, currentBranch: string): void { Telemetry.SendEvent(TelemetryEvents.OpenNewPullRequest); - let url: string = GitVcService.GetCreatePullRequestUrl(remoteUrl, currentBranch); + const url: string = GitVcService.GetCreatePullRequestUrl(remoteUrl, currentBranch); Logger.LogInfo("CreatePullRequestPage: " + url); Utils.OpenUrl(url); } @@ -108,14 +108,14 @@ export class GitClient extends BaseClient { public OpenPullRequestsPage(): void { Telemetry.SendEvent(TelemetryEvents.OpenPullRequestsPage); - let url: string = GitVcService.GetPullRequestsUrl(this._serverContext.RepoInfo.RepositoryUrl); + const url: string = GitVcService.GetPullRequestsUrl(this._serverContext.RepoInfo.RepositoryUrl); Logger.LogInfo("OpenPullRequestsPage: " + url); Utils.OpenUrl(url); } public async PollMyPullRequests(): Promise { try { - let requests: BaseQuickPickItem[] = await this.getMyPullRequests(); + const requests: BaseQuickPickItem[] = await this.getMyPullRequests(); this._statusBarItem.tooltip = Strings.BrowseYourPullRequests; //Remove the default Strings.BrowseYourPullRequests item from the calculation this._statusBarItem.text = GitClient.GetPullRequestStatusText((requests.length - 1).toString()); @@ -125,18 +125,18 @@ export class GitClient extends BaseClient { } private async getMyPullRequests(): Promise { - let requestItems: BaseQuickPickItem[] = []; - let requestIds: number[] = []; + const requestItems: BaseQuickPickItem[] = []; + const requestIds: number[] = []; Logger.LogInfo("Getting pull requests that I requested..."); - let svc: GitVcService = new GitVcService(this._serverContext); - let myPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, this._serverContext.UserInfo.Id, undefined, PullRequestStatus.Active); - let icon: string = "octicon-search"; - let label: string = `$(icon ${icon}) `; + const svc: GitVcService = new GitVcService(this._serverContext); + const myPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, this._serverContext.UserInfo.Id, undefined, PullRequestStatus.Active); + const icon: string = "octicon-search"; + const label: string = `$(icon ${icon}) `; requestItems.push({ label: label + Strings.BrowseYourPullRequests, description: undefined, id: undefined }); myPullRequests.forEach((pr) => { - let score: PullRequestScore = GitVcService.GetPullRequestScore(pr); + const score: PullRequestScore = GitVcService.GetPullRequestScore(pr); requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score)); requestIds.push(pr.pullRequestId); }); @@ -144,9 +144,9 @@ export class GitClient extends BaseClient { Logger.LogInfo("Getting pull requests for which I'm a reviewer..."); //Go get the active pull requests that I'm a reviewer for - let myReviewPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active); + const myReviewPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active); myReviewPullRequests.forEach((pr) => { - let score: PullRequestScore = GitVcService.GetPullRequestScore(pr); + const score: PullRequestScore = GitVcService.GetPullRequestScore(pr); if (requestIds.indexOf(pr.pullRequestId) < 0) { requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score)); } @@ -172,7 +172,7 @@ export class GitClient extends BaseClient { } else if (score === PullRequestScore.NoResponse) { scoreIcon = "octicon-git-pull-request"; } - let scoreLabel: string = `$(icon ${scoreIcon}) `; + const scoreLabel: string = `$(icon ${scoreIcon}) `; return { label: scoreLabel + " (" + displayName + ") " + title, description: description, id: id }; } diff --git a/src/clients/repositoryinfoclient.ts b/src/clients/repositoryinfoclient.ts index d9c6ceeea8..69f536976d 100644 --- a/src/clients/repositoryinfoclient.ts +++ b/src/clients/repositoryinfoclient.ts @@ -41,12 +41,12 @@ export class RepositoryInfoClient { } else if (this._repoContext.Type === RepositoryType.TFVC || this._repoContext.Type === RepositoryType.EXTERNAL) { Logger.LogDebug(`Getting repository information for a TFVC repository at ${this._repoContext.RemoteUrl}`); //For TFVC, the teamProjectName is retrieved by tf.cmd and set on the context - let teamProjectName: string = this._repoContext.TeamProjectName; + const teamProjectName: string = this._repoContext.TeamProjectName; repositoryInfo = new RepositoryInfo(this._repoContext.RemoteUrl); let serverUrl: string; let collectionName: string; - let isTeamServices: boolean = RepoUtils.IsTeamFoundationServicesRepo(this._repoContext.RemoteUrl); + const isTeamServices: boolean = RepoUtils.IsTeamFoundationServicesRepo(this._repoContext.RemoteUrl); if (isTeamServices) { // The Team Services collection is ALWAYS defaultCollection, and both the url with defaultcollection // and the url without defaultCollection will validate just fine. However, it expects you to refer to @@ -55,9 +55,9 @@ export class RepositoryInfoClient { // If validation fails, we return false. collectionName = repositoryInfo.Account; serverUrl = `https://${repositoryInfo.Account}.visualstudio.com/`; - let valid: boolean = await this.validateTfvcCollectionUrl(serverUrl); + const valid: boolean = await this.validateTfvcCollectionUrl(serverUrl); if (!valid) { - let error: string = `Unable to validate the Team Services TFVC repository. Collection name: '${collectionName}', Url: '${serverUrl}'`; + const error: string = `Unable to validate the Team Services TFVC repository. Collection name: '${collectionName}', Url: '${serverUrl}'`; Logger.LogDebug(error); throw new Error(`${Strings.UnableToValidateTeamServicesTfvcRepository} Collection name: '${collectionName}', Url: '${serverUrl}'`); } @@ -70,7 +70,7 @@ export class RepositoryInfoClient { Logger.LogDebug(`Starting the validation of the TFS TFVC repository collection Url ('${serverUrl}')`); let valid: boolean = await this.validateTfvcCollectionUrl(serverUrl); if (valid) { - let parts: string[] = this.splitTfvcCollectionUrl(serverUrl); + const parts: string[] = this.splitTfvcCollectionUrl(serverUrl); serverUrl = parts[0]; collectionName = parts[1]; Logger.LogDebug(`Validated the TFS TFVC repository. Collection name: '${collectionName}', Url: '${serverUrl}'`); @@ -92,7 +92,7 @@ export class RepositoryInfoClient { } } - let coreApiClient: CoreApiClient = new CoreApiClient(); + const coreApiClient: CoreApiClient = new CoreApiClient(); let collection: TeamProjectCollection; Logger.LogDebug(`Getting project collection... url: '${serverUrl}', and collection name: '${collectionName}'`); if (isTeamServices) { @@ -102,7 +102,7 @@ export class RepositoryInfoClient { } else { Logger.LogDebug(`Using SOAP to get the project collection information`); // When called on-prem without admin privileges: Error: Failed Request: Forbidden(403) - Access Denied: Jeff Young (TFS) needs the following permission(s) to perform this action: Edit instance-level information - let tfsClient: TfsCatalogSoapClient = new TfsCatalogSoapClient(serverUrl, [this._handler]); + const tfsClient: TfsCatalogSoapClient = new TfsCatalogSoapClient(serverUrl, [this._handler]); collection = await tfsClient.GetProjectCollection(collectionName); if (!collection) { const error: string = `Using SOAP, could not find a project collection object for ${collectionName} at ${serverUrl}`; @@ -114,11 +114,11 @@ export class RepositoryInfoClient { Logger.LogDebug(`Getting team project... Url: '${serverUrl}', collection name: '${collection.name}', and project: '${teamProjectName}'`); //For a Team Services collection, ignore the collectionName - let resolvedRemoteUrl: string = url.resolve(serverUrl, isTeamServices ? "" : collection.name); + const resolvedRemoteUrl: string = url.resolve(serverUrl, isTeamServices ? "" : collection.name); //Delay the check for a teamProjectName (don't fail here). If we don't have one, that's OK for TFVC //functionality. We need to disable Team Services functionality if we can't find a team project later. - let project: TeamProject = await this.getProjectFromServer(coreApiClient, resolvedRemoteUrl, teamProjectName); + const project: TeamProject = await this.getProjectFromServer(coreApiClient, resolvedRemoteUrl, teamProjectName); Logger.LogDebug(`Found a team project for url: '${serverUrl}', collection name: '${collection.name}', and project id: '${project.id}'`); //Now, create the JSON blob to send to new RepositoryInfo(repoInfo); @@ -133,14 +133,14 @@ export class RepositoryInfoClient { } private splitTfvcCollectionUrl(collectionUrl: string): string[] { - let result: string[] = [ , ]; + const result: string[] = [ , ]; if (!collectionUrl) { return result; } // Now find the TRUE last separator (before the collection name) - let trimmedUrl: string = this.trimTrailingSeparators(collectionUrl); - let index: number = trimmedUrl.lastIndexOf("/"); + const trimmedUrl: string = this.trimTrailingSeparators(collectionUrl); + const index: number = trimmedUrl.lastIndexOf("/"); if (index >= 0) { // result0 is the server url without the collection name result[0] = trimmedUrl.substring(0, index + 1); @@ -202,7 +202,7 @@ export class RepositoryInfoClient { private async validateTfvcCollectionUrl(serverUrl: string): Promise { try { - let repositoryClient: TeamServicesApi = new TeamServicesApi(serverUrl, [this._handler]); + const repositoryClient: TeamServicesApi = new TeamServicesApi(serverUrl, [this._handler]); await repositoryClient.validateTfvcCollectionUrl(); return true; } catch (err) { diff --git a/src/clients/teamservicesclient.ts b/src/clients/teamservicesclient.ts index 7f463f9df0..8ea0525924 100644 --- a/src/clients/teamservicesclient.ts +++ b/src/clients/teamservicesclient.ts @@ -14,7 +14,7 @@ export class TeamServicesApi extends basem.ClientApiBase { //This calls the vsts/info endpoint (which only exists for Git) public async getVstsInfo(): Promise { //Create an instance of Promise since we're calling a function with the callback pattern but want to return a Promise - let promise: Promise = new Promise((resolve, reject) => { + const promise: Promise = new Promise((resolve, reject) => { /* tslint:disable:no-null-keyword */ this.restClient.getJson(this.vsoClient.resolveUrl("/vsts/info"), "", null, null, (err: any, statusCode: number, obj: any) => { /* tslint:enable:no-null-keyword */ @@ -32,7 +32,7 @@ export class TeamServicesApi extends basem.ClientApiBase { //Used to determine if the baseUrl points to a valid TFVC repository public async validateTfvcCollectionUrl(): Promise { //Create an instance of Promise since we're calling a function with the callback pattern but want to return a Promise - let promise: Promise = new Promise((resolve, reject) => { + const promise: Promise = new Promise((resolve, reject) => { /* tslint:disable:no-null-keyword */ this.restClient.getJson(this.vsoClient.resolveUrl("_apis/tfvc/branches"), "", null, null, (err: any, statusCode: number, obj: any) => { /* tslint:enable:no-null-keyword */ diff --git a/src/clients/tfscatalogsoapclient.ts b/src/clients/tfscatalogsoapclient.ts index 7775145fbd..5425fc1cdd 100644 --- a/src/clients/tfscatalogsoapclient.ts +++ b/src/clients/tfscatalogsoapclient.ts @@ -497,7 +497,7 @@ export class TfsCatalogSoapClient { if (!catalogResources) { throw new Error(`No CatalogResources were received for ProjectCollections from ${this.endpointUrl}`); } - let collectionNodes: any[] = []; + const collectionNodes: any[] = []; catalogResources.eachChild(function(catalogResource) { if (catalogResource.attr.ResourceTypeIdentifier.toLowerCase() === TfsCatalogSoapClient.ProjectCollection) { collectionNodes.push(catalogResource); @@ -523,11 +523,11 @@ export class TfsCatalogSoapClient { //Get the project collections, foundationServerRootPath looks something like 3eYRYkJOok6GHrKam0AcAA==GJQSi7i010yMVKSDvyLgHQ== this.getCatalogDataFromServer(foundationServerRootPath + TfsCatalogSoapClient.SingleRecurseStar, TfsCatalogSoapClient.QueryOptionsExpandDependencies).then((catalogDataXml:any) => { - let collectionNodes: any[] = this.parseProjectCollections(catalogDataXml); + const collectionNodes: any[] = this.parseProjectCollections(catalogDataXml); //Now go and find the project collection we're looking for let foundTeamProject: any; - for (let idx = 0; idx < collectionNodes.length; idx++) { + for (let idx: number = 0; idx < collectionNodes.length; idx++) { if (collectionNodes[idx].attr.DisplayName.toLowerCase() === collectionName.toLowerCase()) { foundTeamProject = collectionNodes[idx]; break; @@ -553,9 +553,9 @@ export class TfsCatalogSoapClient { } private getCatalogDataFromServer(pathSpecs: string, queryOptions: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); - let onResult = (err: any, statusCode: number, responseEnvelope: any) => { + const onResult = (err: any, statusCode: number, responseEnvelope: any) => { if (err) { err.statusCode = statusCode; deferred.reject(err); @@ -564,7 +564,7 @@ export class TfsCatalogSoapClient { } }; - let envelope: string = "" + const envelope: string = "" + "" + "" diff --git a/src/clients/witclient.ts b/src/clients/witclient.ts index 656e6f1fe4..a0aeaf1132 100644 --- a/src/clients/witclient.ts +++ b/src/clients/witclient.ts @@ -30,7 +30,7 @@ export class WitClient extends BaseClient { public CreateNewItem(itemType: string, taskTitle: string): void { this.logTelemetryForWorkItem(itemType); Logger.LogInfo("Work item type is " + itemType); - let newItemUrl: string = WorkItemTrackingService.GetNewWorkItemUrl(this._serverContext.RepoInfo.TeamProjectUrl, itemType, taskTitle, this.getUserName(this._serverContext)); + const newItemUrl: string = WorkItemTrackingService.GetNewWorkItemUrl(this._serverContext.RepoInfo.TeamProjectUrl, itemType, taskTitle, this.getUserName(this._serverContext)); Logger.LogInfo("New Work Item Url: " + newItemUrl); Utils.OpenUrl(newItemUrl); } @@ -39,12 +39,12 @@ export class WitClient extends BaseClient { public async CreateNewWorkItem(taskTitle: string): Promise { try { Telemetry.SendEvent(TelemetryEvents.OpenNewWorkItem); - let selectedType: BaseQuickPickItem = await window.showQuickPick(await this.getWorkItemTypes(), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItemType }); + const selectedType: BaseQuickPickItem = await window.showQuickPick(await this.getWorkItemTypes(), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItemType }); if (selectedType) { Telemetry.SendEvent(TelemetryEvents.OpenNewWorkItem); Logger.LogInfo("Selected work item type is " + selectedType.label); - let newItemUrl: string = WorkItemTrackingService.GetNewWorkItemUrl(this._serverContext.RepoInfo.TeamProjectUrl, selectedType.label, taskTitle, this.getUserName(this._serverContext)); + const newItemUrl: string = WorkItemTrackingService.GetNewWorkItemUrl(this._serverContext.RepoInfo.TeamProjectUrl, selectedType.label, taskTitle, this.getUserName(this._serverContext)); Logger.LogInfo("New Work Item Url: " + newItemUrl); Utils.OpenUrl(newItemUrl); } @@ -59,13 +59,13 @@ export class WitClient extends BaseClient { public async ShowMyWorkItemQueries(): Promise { try { Telemetry.SendEvent(TelemetryEvents.ShowMyWorkItemQueries); - let query: WorkItemQueryQuickPickItem = await window.showQuickPick(await this.getMyWorkItemQueries(), { matchOnDescription: false, placeHolder: Strings.ChooseWorkItemQuery }); + const query: WorkItemQueryQuickPickItem = await window.showQuickPick(await this.getMyWorkItemQueries(), { matchOnDescription: false, placeHolder: Strings.ChooseWorkItemQuery }); if (query) { Telemetry.SendEvent(TelemetryEvents.ViewWorkItems); Logger.LogInfo("Selected query is " + query.label); Logger.LogInfo("Getting work items for query..."); - let workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, query.wiql), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); + const workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, query.wiql), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); if (workItem) { let url: string = undefined; if (workItem.id === undefined) { @@ -88,7 +88,7 @@ export class WitClient extends BaseClient { Telemetry.SendEvent(TelemetryEvents.ViewPinnedQueryWorkItems); try { - let queryText: string = await this.getPinnedQueryText(); + const queryText: string = await this.getPinnedQueryText(); await this.showWorkItems(queryText); } catch (err) { this.handleError(err, WitClient.GetOfflinePinnedQueryStatusText(), false, "Error showing pinned query work items"); @@ -107,9 +107,9 @@ export class WitClient extends BaseClient { public async ChooseWorkItems(): Promise { Logger.LogInfo("Getting work items to choose from..."); - let query: string = await this.getPinnedQueryText(); //gets either MyWorkItems, queryText or wiql of queryPath of PinnedQuery + const query: string = await this.getPinnedQueryText(); //gets either MyWorkItems, queryText or wiql of queryPath of PinnedQuery // TODO: There isn't a way to do a multi select pick list right now, but when there is we should change this to use it. - let workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, query), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); + const workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, query), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); if (workItem) { return ["#" + workItem.id + " - " + workItem.description]; } else { @@ -119,7 +119,7 @@ export class WitClient extends BaseClient { private async showWorkItems(wiql: string): Promise { Logger.LogInfo("Getting work items..."); - let workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, wiql), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); + const workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, wiql), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); if (workItem) { let url: string = undefined; if (workItem.id === undefined) { @@ -137,9 +137,9 @@ export class WitClient extends BaseClient { public async GetPinnedQueryResultCount() : Promise { try { Logger.LogInfo("Running pinned work item query to get count (" + this._serverContext.RepoInfo.TeamProject + ")..."); - let queryText: string = await this.getPinnedQueryText(); + const queryText: string = await this.getPinnedQueryText(); - let svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); + const svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); return svc.GetQueryResultCount(this._serverContext.RepoInfo.TeamProject, queryText); } catch (err) { this.handleError(err, WitClient.GetOfflinePinnedQueryStatusText(), false, "Error getting pinned query result count"); @@ -147,16 +147,16 @@ export class WitClient extends BaseClient { } private async getPinnedQueryText(): Promise { - let promise: Promise = new Promise(async (resolve, reject) => { + const promise: Promise = new Promise(async (resolve, reject) => { try { if (this._pinnedQuery.queryText && this._pinnedQuery.queryText.length > 0) { resolve(this._pinnedQuery.queryText); } else if (this._pinnedQuery.queryPath && this._pinnedQuery.queryPath.length > 0) { Logger.LogInfo("Getting my work item query (" + this._serverContext.RepoInfo.TeamProject + ")..."); Logger.LogInfo("QueryPath: " + this._pinnedQuery.queryPath); - let svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); + const svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); - let queryItem: QueryHierarchyItem = await svc.GetWorkItemQuery(this._serverContext.RepoInfo.TeamProject, this._pinnedQuery.queryPath); + const queryItem: QueryHierarchyItem = await svc.GetWorkItemQuery(this._serverContext.RepoInfo.TeamProject, this._pinnedQuery.queryPath); resolve(queryItem.wiql); } } catch (err) { @@ -167,10 +167,10 @@ export class WitClient extends BaseClient { } private async getMyWorkItemQueries(): Promise { - let queries: WorkItemQueryQuickPickItem[] = []; - let svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); + const queries: WorkItemQueryQuickPickItem[] = []; + const svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); Logger.LogInfo("Getting my work item queries (" + this._serverContext.RepoInfo.TeamProject + ")..."); - let hierarchyItems: QueryHierarchyItem[] = await svc.GetWorkItemHierarchyItems(this._serverContext.RepoInfo.TeamProject); + const hierarchyItems: QueryHierarchyItem[] = await svc.GetWorkItemHierarchyItems(this._serverContext.RepoInfo.TeamProject); Logger.LogInfo("Retrieved " + hierarchyItems.length + " hierarchyItems"); hierarchyItems.forEach((folder) => { if (folder && folder.isFolder === true && folder.isPublic === false) { @@ -179,7 +179,7 @@ export class WitClient extends BaseClient { this._myQueriesFolder = folder.name; if (folder.hasChildren === true) { //Gets all of the queries under "My Queries" and gets their name and wiql - for (let index = 0; index < folder.children.length; index++) { + for (let index: number = 0; index < folder.children.length; index++) { queries.push({ id: folder.children[index].id, label: folder.children[index].name, @@ -194,10 +194,10 @@ export class WitClient extends BaseClient { } private async getMyWorkItems(teamProject: string, wiql: string): Promise { - let workItems: BaseQuickPickItem[] = []; - let svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); + const workItems: BaseQuickPickItem[] = []; + const svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); Logger.LogInfo("Getting my work items (" + this._serverContext.RepoInfo.TeamProject + ")..."); - let simpleWorkItems: SimpleWorkItem[] = await svc.GetWorkItems(teamProject, wiql); + const simpleWorkItems: SimpleWorkItem[] = await svc.GetWorkItems(teamProject, wiql); Logger.LogInfo("Retrieved " + simpleWorkItems.length + " work items"); simpleWorkItems.forEach((wi) => { workItems.push({ label: wi.label, description: wi.description, id: wi.id}); @@ -226,9 +226,9 @@ export class WitClient extends BaseClient { } private async getWorkItemTypes(): Promise { - let svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); - let types: WorkItemType[] = await svc.GetWorkItemTypes(this._serverContext.RepoInfo.TeamProject); - let workItemTypes: BaseQuickPickItem[] = []; + const svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext); + const types: WorkItemType[] = await svc.GetWorkItemTypes(this._serverContext.RepoInfo.TeamProject); + const workItemTypes: BaseQuickPickItem[] = []; types.forEach((type) => { workItemTypes.push({ label: type.name, description: type.description, id: undefined }); }); diff --git a/src/contexts/gitcontext.ts b/src/contexts/gitcontext.ts index 538ed7e5b8..e980f253ac 100644 --- a/src/contexts/gitcontext.ts +++ b/src/contexts/gitcontext.ts @@ -49,7 +49,7 @@ export class GitContext implements IRepositoryContext { this._gitConfig = pgc.sync(syncObj); /* tslint:disable:quotemark */ - let remote: any = this._gitConfig['remote "origin"']; + const remote: any = this._gitConfig['remote "origin"']; /* tslint:enable:quotemark */ if (remote === undefined) { return; @@ -67,11 +67,11 @@ export class GitContext implements IRepositoryContext { //All Team Services and TFS Git remote urls contain /_git/ if (RepoUtils.IsTeamFoundationGitRepo(this._gitOriginalRemoteUrl)) { - let purl = url.parse(this._gitOriginalRemoteUrl); + const purl = url.parse(this._gitOriginalRemoteUrl); if (purl) { if (RepoUtils.IsTeamFoundationServicesRepo(this._gitOriginalRemoteUrl)) { this._isTeamServicesUrl = true; - let splitHref = purl.href.split("@"); + const splitHref = purl.href.split("@"); if (splitHref.length === 2) { //RemoteUrl is SSH //For Team Services, default to https:// as the protocol this._gitRemoteUrl = "https://" + purl.hostname + purl.pathname; diff --git a/src/contexts/repocontextfactory.ts b/src/contexts/repocontextfactory.ts index 8dc1d0a293..81768b1329 100644 --- a/src/contexts/repocontextfactory.ts +++ b/src/contexts/repocontextfactory.ts @@ -50,7 +50,7 @@ export class RepositoryContextFactory { */ public static UpdateRepositoryContext(currentRepo: IRepositoryContext, serverContext: TeamServerContext): IRepositoryContext { if (currentRepo && currentRepo instanceof TfvcContext) { - let context: TfvcContext = currentRepo; + const context: TfvcContext = currentRepo; context.TfvcRepository = TfCommandLineRunner.CreateRepository(serverContext, context.RepoFolder); } return currentRepo; diff --git a/src/credentialstore/credentialstore.ts b/src/credentialstore/credentialstore.ts index fa9e77e66e..2a26b9dff2 100644 --- a/src/credentialstore/credentialstore.ts +++ b/src/credentialstore/credentialstore.ts @@ -72,7 +72,7 @@ export class CredentialStore implements ICredentialStore { } public SetCredential(service: string, username: string, password: any) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); // First, look to see if we have a credential for this service already. If so, remove it // since we don't know if the user is changing the username or the password (or both) for diff --git a/src/credentialstore/linux/file-token-storage.ts b/src/credentialstore/linux/file-token-storage.ts index 974835a146..b152934bb7 100644 --- a/src/credentialstore/linux/file-token-storage.ts +++ b/src/credentialstore/linux/file-token-storage.ts @@ -22,7 +22,7 @@ export class FileTokenStorage { } public AddEntries(newEntries: Array, existingEntries: Array) : Q.Promise { - let entries: Array = existingEntries.concat(newEntries); + const entries: Array = existingEntries.concat(newEntries); return this.saveEntries(entries); } @@ -31,12 +31,12 @@ export class FileTokenStorage { } public LoadEntries() : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); let entries: Array = []; let err: any; try { - let content: string = fs.readFileSync(this._filename, {encoding: "utf8", flag: "r"}); + const content: string = fs.readFileSync(this._filename, {encoding: "utf8", flag: "r"}); entries = JSON.parse(content); deferred.resolve(entries); } catch (ex) { @@ -57,16 +57,16 @@ export class FileTokenStorage { } private saveEntries(entries: Array) : Q.Promise { - let defer: Q.Deferred = Q.defer(); + const defer: Q.Deferred = Q.defer(); - let writeOptions = { + const writeOptions = { encoding: "utf8", mode: 384, // Permission 0600 - owner read/write, nobody else has access flag: "w" }; // If the path we want to store in doesn't exist, create it - let folder: string = path.dirname(this._filename); + const folder: string = path.dirname(this._filename); if (!fs.existsSync(folder)) { fs.mkdirSync(folder); } diff --git a/src/credentialstore/linux/linux-file-api.ts b/src/credentialstore/linux/linux-file-api.ts index d35154c04f..e4186c16ce 100644 --- a/src/credentialstore/linux/linux-file-api.ts +++ b/src/credentialstore/linux/linux-file-api.ts @@ -32,13 +32,13 @@ export class LinuxFileApi implements ICredentialStore { } public GetCredential(service: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.loadCredentials().then((entries) => { // Find the entry I want based on service - let entryArray: Array = _.where(entries, { service: service }); + const entryArray: Array = _.where(entries, { service: service }); if (entryArray !== undefined && entryArray.length > 0) { - let credential: Credential = this.createCredential(entryArray[0]); + const credential: Credential = this.createCredential(entryArray[0]); deferred.resolve(credential); } else { deferred.resolve(undefined); @@ -51,14 +51,14 @@ export class LinuxFileApi implements ICredentialStore { } public SetCredential(service: string, username: string, password: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.loadCredentials().then((entries) => { // Remove any entries that are the same as the one I'm about to add - let existingEntries = _.reject(entries, function(elem) { + const existingEntries = _.reject(entries, function(elem) { return elem.username === username && elem.service === service; }); - let newEntry = { + const newEntry = { username: username, password: password, service: service @@ -76,11 +76,11 @@ export class LinuxFileApi implements ICredentialStore { } public RemoveCredential(service: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.loadCredentials().then((entries) => { // Find the entry being asked to be removed; if found, remove it, save the remaining list - let existingEntries = _.reject(entries, function(elem) { + const existingEntries = _.reject(entries, function(elem) { return elem.service === service; }); // TODO: RemoveEntries doesn't do anything with second arg. For now, do nothing to @@ -98,13 +98,13 @@ export class LinuxFileApi implements ICredentialStore { } public getCredentialByName(service: string, username: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.loadCredentials().then((entries) => { // Find the entry I want based on service and username - let entryArray: Array = _.where(entries, { service: service, username: username }); + const entryArray: Array = _.where(entries, { service: service, username: username }); if (entryArray !== undefined && entryArray.length > 0) { - let credential: Credential = this.createCredential(entryArray[0]); + const credential: Credential = this.createCredential(entryArray[0]); deferred.resolve(credential); } else { deferred.resolve(undefined); @@ -117,11 +117,11 @@ export class LinuxFileApi implements ICredentialStore { } public removeCredentialByName(service: string, username: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.loadCredentials().then((entries) => { // Find the entry being asked to be removed; if found, remove it, save the remaining list - let existingEntries = _.reject(entries, function(elem) { + const existingEntries = _.reject(entries, function(elem) { if (username === "*") { return elem.service === service; } else { @@ -147,7 +147,7 @@ export class LinuxFileApi implements ICredentialStore { } private loadCredentials() : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this._fts.LoadEntries().then((entries) => { deferred.resolve(entries); diff --git a/src/credentialstore/osx/osx-keychain-api.ts b/src/credentialstore/osx/osx-keychain-api.ts index 9fe4c00afc..d0227c6957 100644 --- a/src/credentialstore/osx/osx-keychain-api.ts +++ b/src/credentialstore/osx/osx-keychain-api.ts @@ -29,7 +29,7 @@ export class OsxKeychainApi implements ICredentialStore { } public GetCredential(service: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); let credential: Credential; // To get the credential, I must first list all of the credentials we previously @@ -37,7 +37,7 @@ export class OsxKeychainApi implements ICredentialStore { this.listCredentials().then((credentials) => { // Spin through the returned credentials to ensure I got the one I want // based on passed in 'service' - for (let index = 0; index < credentials.length; index++) { + for (let index: number = 0; index < credentials.length; index++) { if (credentials[index].Service === service) { credential = credentials[index]; break; @@ -64,7 +64,7 @@ export class OsxKeychainApi implements ICredentialStore { } public SetCredential(service: string, username: string, password: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); // I'm not supporting a description so pass "" for that parameter osxkeychain.set(username, service, "" /*description*/, password, function(err) { @@ -78,7 +78,7 @@ export class OsxKeychainApi implements ICredentialStore { } public RemoveCredential(service: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.removeCredentials(service).then(() => { deferred.resolve(undefined); @@ -90,7 +90,7 @@ export class OsxKeychainApi implements ICredentialStore { } public getCredentialByName(service: string, username: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); let credential: Credential; // To get the credential, I must first list all of the credentials we previously @@ -98,7 +98,7 @@ export class OsxKeychainApi implements ICredentialStore { this.listCredentials().then((credentials) => { // Spin through the returned credentials to ensure I got the one I want // based on passed in 'service' - for (let index = 0; index < credentials.length; index++) { + for (let index: number = 0; index < credentials.length; index++) { if (credentials[index].Service === service && credentials[index].Username === username) { credential = credentials[index]; break; @@ -125,7 +125,7 @@ export class OsxKeychainApi implements ICredentialStore { } public removeCredentialByName(service: string, username: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); // if username === "*", we need to remove all credentials for this service. if (username === "*") { @@ -153,13 +153,13 @@ export class OsxKeychainApi implements ICredentialStore { } private removeCredentials(service: string): Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); // listCredentials will return all of the credentials for this prefix and service this.listCredentials(service).then((creds) => { if (creds !== undefined && creds.length > 0) { // Remove all of these credentials - let promises: Q.Promise[] = []; + const promises: Q.Promise[] = []; creds.forEach((cred) => { promises.push(this.removeCredentialByName(cred.Service, cred.Username)); }); @@ -174,19 +174,19 @@ export class OsxKeychainApi implements ICredentialStore { } private listCredentials(service? : string) : Q.Promise> { - let deferred: Q.Deferred> = Q.defer>(); - let credentials: Array = []; + const deferred: Q.Deferred> = Q.defer>(); + const credentials: Array = []; - let stream = osxkeychain.list(); + const stream = osxkeychain.list(); stream.on("data", (cred) => { // Don't return all credentials, just ones that start // with our prefix and optional service if (cred.svce !== undefined) { if (cred.svce.indexOf(this._prefix) === 0) { - let svc: string = cred.svce.substring(this._prefix.length); - let username: string = cred.acct; + const svc: string = cred.svce.substring(this._prefix.length); + const username: string = cred.acct; //password is undefined because we don't have it yet - let credential: Credential = new Credential(svc, username, undefined); + const credential: Credential = new Credential(svc, username, undefined); // Only add the credential if we want them all or it's a match on service if (service === undefined || service === svc) { diff --git a/src/credentialstore/win32/win-credstore-api.ts b/src/credentialstore/win32/win-credstore-api.ts index 4ef431e79d..9b6914e765 100644 --- a/src/credentialstore/win32/win-credstore-api.ts +++ b/src/credentialstore/win32/win-credstore-api.ts @@ -27,13 +27,13 @@ export class WindowsCredentialStoreApi implements ICredentialStore { } public GetCredential(service: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); let credential: Credential; //TODO: Why not just have listCredentials send back the ones I want based on (optional) service? this.listCredentials().then((credentials) => { //Spin through the returned credentials to ensure I got the one I want based on passed in 'service' - for (let index = 0; index < credentials.length; index++) { + for (let index: number = 0; index < credentials.length; index++) { credential = this.createCredential(credentials[index]); if (credential.Service === service) { break; @@ -50,8 +50,8 @@ export class WindowsCredentialStoreApi implements ICredentialStore { } public SetCredential(service: string, username: string, password: any) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); - let targetName: string = this.createTargetName(service, username); + const deferred: Q.Deferred = Q.defer(); + const targetName: string = this.createTargetName(service, username); // Here, `password` is either the password or pat wincredstore.set(targetName, password, function(err) { @@ -65,8 +65,8 @@ export class WindowsCredentialStoreApi implements ICredentialStore { } public RemoveCredential(service: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); - let targetName: string = this.createTargetName(service, "*"); + const deferred: Q.Deferred = Q.defer(); + const targetName: string = this.createTargetName(service, "*"); wincredstore.remove(targetName, function(err) { if (err) { @@ -86,12 +86,12 @@ export class WindowsCredentialStoreApi implements ICredentialStore { // Adding for test purposes (to ensure a particular credential doesn't exist) public getCredentialByName(service: string, username: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); let credential: Credential; this.listCredentials().then((credentials) => { //Spin through the returned credentials to ensure I got the one I want based on passed in 'service' - for (let index = 0; index < credentials.length; index++) { + for (let index: number = 0; index < credentials.length; index++) { credential = this.createCredential(credentials[index]); if (credential.Service === service && credential.Username === username) { break; @@ -108,8 +108,8 @@ export class WindowsCredentialStoreApi implements ICredentialStore { } public removeCredentialByName(service: string, username: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); - let targetName: string = this.createTargetName(service, username); + const deferred: Q.Deferred = Q.defer(); + const targetName: string = this.createTargetName(service, username); wincredstore.remove(targetName, function(err) { if (err) { @@ -128,11 +128,11 @@ export class WindowsCredentialStoreApi implements ICredentialStore { } private createCredential(cred: any) : Credential { - let password: string = new Buffer(cred.credential, "hex").toString("utf8"); + const password: string = new Buffer(cred.credential, "hex").toString("utf8"); // http://servername:port|\\domain\username - let segments: Array = cred.targetName.split(WindowsCredentialStoreApi.separator); - let username: string = segments[segments.length - 1]; - let service: string = segments[0]; + const segments: Array = cred.targetName.split(WindowsCredentialStoreApi.separator); + const username: string = segments[segments.length - 1]; + const service: string = segments[0]; return new Credential(service, username, password); } @@ -141,10 +141,10 @@ export class WindowsCredentialStoreApi implements ICredentialStore { } private listCredentials() : Q.Promise> { - let deferred: Q.Deferred> = Q.defer>(); - let credentials: Array = []; + const deferred: Q.Deferred> = Q.defer>(); + const credentials: Array = []; - let stream = wincredstore.list(); + const stream = wincredstore.list(); stream.on("data", (cred) => { credentials.push(cred); }); diff --git a/src/extensionmanager.ts b/src/extensionmanager.ts index 6cde29ffbb..bfceaacdee 100644 --- a/src/extensionmanager.ts +++ b/src/extensionmanager.ts @@ -155,7 +155,7 @@ export class ExtensionManager implements Disposable { //Return value indicates whether a message was displayed public DisplayErrorMessage(message?: string): boolean { - let msg: string = message ? message : this._errorMessage; + const msg: string = message ? message : this._errorMessage; if (msg) { VsCodeUtils.ShowErrorMessage(msg); return true; @@ -169,7 +169,7 @@ export class ExtensionManager implements Disposable { //Logs an error to the logger and sends an exception to telemetry service public ReportError(err: Error, message: string, showToUser: boolean = false): void { - let fullMessage = err ? message + " " + err : message; + const fullMessage = err ? message + " " + err : message; // Log the message Logger.LogError(fullMessage); @@ -254,7 +254,7 @@ export class ExtensionManager implements Disposable { Logger.LogDebug("Started ApplicationInsights telemetry"); //Set up the client we need to talk to the server for more repository information - let repositoryInfoClient: RepositoryInfoClient = new RepositoryInfoClient(this._repoContext, CredentialManager.GetCredentialHandler()); + const repositoryInfoClient: RepositoryInfoClient = new RepositoryInfoClient(this._repoContext, CredentialManager.GetCredentialHandler()); Logger.LogInfo("Getting repository information with repositoryInfoClient"); Logger.LogDebug("RemoteUrl = " + this._repoContext.RemoteUrl); @@ -265,12 +265,12 @@ export class ExtensionManager implements Disposable { this._serverContext.RepoInfo = await repositoryInfoClient.GetRepositoryInfo(); //Now we need to go and get the authorized user information - let connectionUrl: string = (this._serverContext.RepoInfo.IsTeamServices === true ? this._serverContext.RepoInfo.AccountUrl : this._serverContext.RepoInfo.CollectionUrl); - let accountClient: TeamServicesApi = new TeamServicesApi(connectionUrl, [CredentialManager.GetCredentialHandler()]); + const connectionUrl: string = (this._serverContext.RepoInfo.IsTeamServices === true ? this._serverContext.RepoInfo.AccountUrl : this._serverContext.RepoInfo.CollectionUrl); + const accountClient: TeamServicesApi = new TeamServicesApi(connectionUrl, [CredentialManager.GetCredentialHandler()]); Logger.LogInfo("Getting connectionData with accountClient"); Logger.LogDebug("connectionUrl = " + connectionUrl); try { - let settings: any = await accountClient.connect(); + const settings: any = await accountClient.connect(); Logger.LogInfo("Retrieved connectionData with accountClient"); this.resetErrorStatus(); @@ -327,7 +327,7 @@ export class ExtensionManager implements Disposable { }).fail((err) => { this.setErrorStatus(Utils.GetMessageForStatusCode(err, err.message), (err.statusCode === 401 ? CommandNames.Signin : undefined), false); //If we can't get a requestHandler, report the error via the feedbackclient - let message: string = Utils.GetMessageForStatusCode(err, err.message, "Failed to get a credential handler"); + const message: string = Utils.GetMessageForStatusCode(err, err.message, "Failed to get a credential handler"); Logger.LogError(message); Telemetry.SendException(err); }); @@ -447,7 +447,7 @@ export class ExtensionManager implements Disposable { //TODO: Should the default command be to do nothing? Or perhaps to display the message? this._teamServicesStatusBarItem.command = commandOnClick === undefined ? CommandNames.Reinitialize : commandOnClick; this._teamServicesStatusBarItem.text = "Team " + `$(icon octicon-stop)`; - let message: string = this._errorMessage + (showRetryMessage !== undefined && showRetryMessage === true ? " " + Strings.ClickToRetryConnection : "") ; + const message: string = this._errorMessage + (showRetryMessage !== undefined && showRetryMessage === true ? " " + Strings.ClickToRetryConnection : "") ; this._teamServicesStatusBarItem.tooltip = message; this._teamServicesStatusBarItem.show(); } @@ -456,8 +456,8 @@ export class ExtensionManager implements Disposable { //Sets up a file system watcher on HEAD so we can know when the current branch has changed private async setupFileSystemWatcherOnHead(): Promise { if (this._repoContext && this._repoContext.Type === RepositoryType.GIT) { - let pattern: string = this._repoContext.RepoFolder + "/HEAD"; - let fsw:FileSystemWatcher = workspace.createFileSystemWatcher(pattern, true, false, true); + const pattern: string = this._repoContext.RepoFolder + "/HEAD"; + const fsw:FileSystemWatcher = workspace.createFileSystemWatcher(pattern, true, false, true); fsw.onDidChange(async (/*uri*/) => { Logger.LogInfo("HEAD has changed, re-parsing RepoContext object"); this._repoContext = await RepositoryContextFactory.CreateRepositoryContext(workspace.rootPath, this._settings); @@ -480,9 +480,9 @@ export class ExtensionManager implements Disposable { } if (this._repoContext && this._repoContext.Type === RepositoryType.GIT) { - let pattern: string = path.join(workspace.rootPath, ".git", "config"); + const pattern: string = path.join(workspace.rootPath, ".git", "config"); //We want to listen to file creation, change and delete events - let fsw:FileSystemWatcher = workspace.createFileSystemWatcher(pattern, false, false, false); + const fsw:FileSystemWatcher = workspace.createFileSystemWatcher(pattern, false, false, false); fsw.onDidCreate((/*uri*/) => { //When a new local repo is initialized (e.g., git init), re-initialize the extension Logger.LogInfo("config has been created, re-initializing the extension"); @@ -490,8 +490,8 @@ export class ExtensionManager implements Disposable { }); fsw.onDidChange(async (uri) => { Logger.LogInfo("config has changed, checking if 'remote origin' changed"); - let context: IRepositoryContext = await RepositoryContextFactory.CreateRepositoryContext(uri.fsPath, this._settings); - let remote: string = context.RemoteUrl; + const context: IRepositoryContext = await RepositoryContextFactory.CreateRepositoryContext(uri.fsPath, this._settings); + const remote: string = context.RemoteUrl; if (remote === undefined) { //There is either no remote defined yet or it isn't a Team Services repo if (this._repoContext.RemoteUrl !== undefined) { diff --git a/src/helpers/credentialmanager.ts b/src/helpers/credentialmanager.ts index b6fdd471fd..886e90a43b 100644 --- a/src/helpers/credentialmanager.ts +++ b/src/helpers/credentialmanager.ts @@ -26,7 +26,7 @@ export class CredentialManager { } public GetCredentials(context: TeamServerContext) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this.getCredentials(context).then((credInfo: CredentialInfo) => { if (credInfo !== undefined) { @@ -42,7 +42,7 @@ export class CredentialManager { } public RemoveCredentials(account: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this._credentialStore.RemoveCredential(account).then(() => { deferred.resolve(undefined); @@ -53,7 +53,7 @@ export class CredentialManager { } public StoreCredentials(account: string, username: string, password: string) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this._credentialStore.SetCredential(account, username, password).then(() => { deferred.resolve(undefined); @@ -64,7 +64,7 @@ export class CredentialManager { } private getCredentials(context:TeamServerContext) : Q.Promise { - let deferred: Q.Deferred = Q.defer(); + const deferred: Q.Deferred = Q.defer(); this._credentialStore.GetCredential(context.RepoInfo.Host).then((cred) => { if (cred !== undefined) { @@ -73,7 +73,7 @@ export class CredentialManager { } else if (context.RepoInfo.IsTeamFoundationServer) { let domain: string; let user: string = cred.Username; - let pair = user.split("\\"); + const pair: string[] = user.split("\\"); if (pair.length > 1) { domain = pair[0]; user = pair[pair.length - 1]; diff --git a/src/helpers/logger.ts b/src/helpers/logger.ts index 5c39910519..a9b9e337e9 100644 --- a/src/helpers/logger.ts +++ b/src/helpers/logger.ts @@ -17,7 +17,7 @@ export class Logger { private static initalize() { //Only initialize the logger if a logging level is set (in settings) and we haven't initialized it yet if (Logger.loggingLevel !== undefined && Logger.initialized === false) { - let fileOpt:winston.FileTransportOptions = { json: false, filename: path.join(Logger.logPath, Constants.ExtensionName + "-extension.log"), + const fileOpt:winston.FileTransportOptions = { json: false, filename: path.join(Logger.logPath, Constants.ExtensionName + "-extension.log"), level: LoggingLevel[Logger.loggingLevel].toLowerCase(), maxsize: 4000000, maxFiles: 5, tailable: false }; winston.add(winston.transports.File, fileOpt); @@ -122,8 +122,8 @@ export class Logger { return Logger.getNow(); } private static getNow(): string { - let now: Date = new Date(); - let strDateTime: string = [[Logger.addZero(now.getHours()), Logger.addZero(now.getMinutes()), Logger.addZero(now.getSeconds())].join(":"), + const now: Date = new Date(); + const strDateTime: string = [[Logger.addZero(now.getHours()), Logger.addZero(now.getMinutes()), Logger.addZero(now.getSeconds())].join(":"), Logger.addZero(now.getMilliseconds(), 100)].join("."); return strDateTime + " "; diff --git a/src/helpers/settings.ts b/src/helpers/settings.ts index e5ae08eaeb..1ae658ad0d 100644 --- a/src/helpers/settings.ts +++ b/src/helpers/settings.ts @@ -10,8 +10,8 @@ import { Logger } from "../helpers/logger"; export abstract class BaseSettings { protected readSetting(name: string, defaultValue:T): T { - let configuration = workspace.getConfiguration(); - let value = configuration.get(name, undefined); + const configuration = workspace.getConfiguration(); + const value = configuration.get(name, undefined); // If user specified a value, use it if (value) { @@ -38,12 +38,12 @@ export class PinnedQuerySettings extends BaseSettings { } private getPinnedQuery(account: string) : IPinnedQuery { - let pinnedQueries = this.readSetting(SettingNames.PinnedQueries, undefined); + const pinnedQueries = this.readSetting(SettingNames.PinnedQueries, undefined); if (pinnedQueries !== undefined) { Logger.LogDebug("Found pinned queries in user configuration settings."); let global: IPinnedQuery = undefined; for (let index: number = 0; index < pinnedQueries.length; index++) { - let element = pinnedQueries[index]; + const element = pinnedQueries[index]; if (element.account === account || element.account === account + ".visualstudio.com") { return element; @@ -87,10 +87,10 @@ export class Settings extends BaseSettings implements ISettings { constructor() { super(); - let loggingLevel = SettingNames.LoggingLevel; + const loggingLevel = SettingNames.LoggingLevel; this._loggingLevel = this.readSetting(loggingLevel, undefined); - let pollingInterval = SettingNames.PollingInterval; + const pollingInterval = SettingNames.PollingInterval; this._pollingInterval = this.readSetting(pollingInterval, 5); Logger.LogDebug("Polling interval value (minutes): " + this._pollingInterval.toString()); // Ensure a minimum value when an invalid value is set diff --git a/src/helpers/urlbuilder.ts b/src/helpers/urlbuilder.ts index 16ee893cff..1ccb163c44 100644 --- a/src/helpers/urlbuilder.ts +++ b/src/helpers/urlbuilder.ts @@ -41,7 +41,7 @@ export class UrlBuilder { finalUrl = finalUrl.substring(0, finalUrl.length - 1); } for (let idx: number = 0; idx < args.length; idx++) { - let prefix: string = (idx === 0 ? "?" : "&"); + const prefix: string = (idx === 0 ? "?" : "&"); let arg: string = args[idx]; if (arg.startsWith("?") || arg.startsWith("&")) { @@ -65,7 +65,7 @@ export class UrlBuilder { finalUrl = finalUrl.substring(0, finalUrl.length - 1); } for (let idx: number = 0; idx < args.length; idx++) { - let prefix: string = (idx === 0 ? "#" : "&"); + const prefix: string = (idx === 0 ? "#" : "&"); let arg: string = args[idx]; if (arg.startsWith("#") || arg.startsWith("&")) { diff --git a/src/helpers/useragentprovider.ts b/src/helpers/useragentprovider.ts index 9b4c37ef13..a7633dd888 100644 --- a/src/helpers/useragentprovider.ts +++ b/src/helpers/useragentprovider.ts @@ -12,7 +12,7 @@ export class UserAgentProvider { public static get UserAgent() : string { // Example: VSTSVSCode/1.115.1 (VSCode/10.1.0; Windows_NT/10.0.10586; Node/6.5.0) - let userAgent: string = `${Constants.ExtensionUserAgentName}/${Constants.ExtensionVersion} (VSCode ${UserAgentProvider._vsCodeVersion}; ${os.type()} ${os.release()}; Node ${process.versions["node"]})`; + const userAgent: string = `${Constants.ExtensionUserAgentName}/${Constants.ExtensionVersion} (VSCode ${UserAgentProvider._vsCodeVersion}; ${os.type()} ${os.release()}; Node ${process.versions["node"]})`; return userAgent; } diff --git a/src/helpers/vscodeutils.ts b/src/helpers/vscodeutils.ts index aea97e168a..3f85296fcc 100644 --- a/src/helpers/vscodeutils.ts +++ b/src/helpers/vscodeutils.ts @@ -31,19 +31,19 @@ export class ButtonMessageItem implements MessageItem, IButtonMessageItem { export class VsCodeUtils { //Returns the trimmed value if there's an activeTextEditor and a selection public static GetActiveSelection(): string { - let editor = window.activeTextEditor; + const editor = window.activeTextEditor; if (!editor) { return undefined; } // Make sure that the selection is not empty and it is a single line - let selection = editor.selection; + const selection = editor.selection; if (selection.isEmpty || !selection.isSingleLine) { return undefined; } - let range = new Range(selection.start.line, selection.start.character, selection.end.line, selection.end.character); - let value = editor.document.getText(range).trim(); + const range = new Range(selection.start.line, selection.start.character, selection.end.line, selection.end.character); + const value = editor.document.getText(range).trim(); return value; } diff --git a/src/info/extensionrequesthandler.ts b/src/info/extensionrequesthandler.ts index 35e6aca4f9..70daf02cff 100644 --- a/src/info/extensionrequesthandler.ts +++ b/src/info/extensionrequesthandler.ts @@ -58,7 +58,7 @@ export class ExtensionRequestHandler implements IRequestHandler { this._credentialHandler.prepareRequest(options); // Get user agent string from the UserAgentProvider (Example: VSTSVSCode/1.115.1 (VSCode/10.1.0; Windows_NT/10.0.10586; Node/6.5.0)) - let userAgent: string = UserAgentProvider.UserAgent; + const userAgent: string = UserAgentProvider.UserAgent; options.headers["User-Agent"] = userAgent; } diff --git a/src/info/repositoryinfo.ts b/src/info/repositoryinfo.ts index d9b52996dc..1be7fc6699 100644 --- a/src/info/repositoryinfo.ts +++ b/src/info/repositoryinfo.ts @@ -48,7 +48,7 @@ export class RepositoryInfo { repositoryUrl = repositoryInfo; } - let purl = url.parse(repositoryUrl); + const purl: url.Url = url.parse(repositoryUrl); if (purl) { this._host = purl.host; this._hostName = purl.hostname; @@ -60,7 +60,7 @@ export class RepositoryInfo { this._repositoryUrl = repositoryUrl; if (RepoUtils.IsTeamFoundationServicesRepo(repositoryUrl)) { - let splitHost = this._host.split("."); + const splitHost = this._host.split("."); this._account = splitHost[0]; this._isTeamServicesUrl = true; Logger.LogDebug("_isTeamServicesUrl: true"); diff --git a/src/services/gitvc.ts b/src/services/gitvc.ts index f29e73e0f1..09f4c83182 100644 --- a/src/services/gitvc.ts +++ b/src/services/gitvc.ts @@ -28,7 +28,7 @@ export class GitVcService { //Returns a Promise containing an array of GitPullRequest objectss for the creator and repository //If creatorId is undefined, all pull requests will be returned public async GetPullRequests(repositoryId: string, creatorId?: string, reviewerId?: string, status?: PullRequestStatus): Promise { - let criteria: GitPullRequestSearchCriteria = { creatorId: creatorId, includeLinks: false, repositoryId: repositoryId, reviewerId: reviewerId, + const criteria: GitPullRequestSearchCriteria = { creatorId: creatorId, includeLinks: false, repositoryId: repositoryId, reviewerId: reviewerId, sourceRefName: undefined, status: status, targetRefName: undefined }; return await this._gitApi.getPullRequests(repositoryId, criteria); } @@ -58,7 +58,7 @@ export class GitVcService { //https://account.visualstudio.com/project/_git/VSCode.Extension/history?itemVersion=GBmaster&_a=history public static GetRepositoryHistoryUrl(remoteUrl: string, currentBranch: string): string { const branch: string = encodeURIComponent(currentBranch); - let repoHistoryUrl: string = UrlBuilder.Join(remoteUrl, "history"); + const repoHistoryUrl: string = UrlBuilder.Join(remoteUrl, "history"); return UrlBuilder.AddQueryParams(repoHistoryUrl, `itemVersion=GB${branch}`, `_a=history`); } @@ -86,7 +86,7 @@ export class GitVcService { //Returns the 'score' of the pull request so the client knows if the PR failed, //didn't receive any reponses, succeeded or is waiting for the author. public static GetPullRequestScore(pullRequest: GitPullRequest): PullRequestScore { - let mergeStatus: PullRequestAsyncStatus = pullRequest.mergeStatus; + const mergeStatus: PullRequestAsyncStatus = pullRequest.mergeStatus; if (mergeStatus === PullRequestAsyncStatus.Conflicts || mergeStatus === PullRequestAsyncStatus.Failure || mergeStatus === PullRequestAsyncStatus.RejectedByPolicy) { @@ -97,7 +97,7 @@ export class GitVcService { let highestVote: number = 0; if (pullRequest.reviewers !== undefined && pullRequest.reviewers.length > 0) { pullRequest.reviewers.forEach((reviewer) => { - let vote: number = reviewer.vote; + const vote: number = reviewer.vote; if (vote < lowestVote) { lowestVote = vote; } diff --git a/src/services/telemetry.ts b/src/services/telemetry.ts index 1e2b4021cf..22eba39dd0 100644 --- a/src/services/telemetry.ts +++ b/src/services/telemetry.ts @@ -32,7 +32,7 @@ export class Telemetry { Telemetry._telemetryEnabled = settings.AppInsightsEnabled; // Always initialize Application Insights - let insightsKey = Telemetry._productionKey; + let insightsKey: string = Telemetry._productionKey; if (settings.AppInsightsKey !== undefined) { insightsKey = settings.AppInsightsKey; } @@ -111,10 +111,10 @@ export class Telemetry { }; //Set the userid on the AI context so that we can get user counts in the telemetry - let aiUserId = Telemetry._appInsightsClient.context.keys.userId; + const aiUserId = Telemetry._appInsightsClient.context.keys.userId; Telemetry._appInsightsClient.context.tags[aiUserId] = Telemetry._userId; - let aiSessionId = Telemetry._appInsightsClient.context.keys.sessionId; + const aiSessionId = Telemetry._appInsightsClient.context.keys.sessionId; Telemetry._appInsightsClient.context.tags[aiSessionId] = Telemetry._sessionId; } } diff --git a/src/services/workitemtracking.ts b/src/services/workitemtracking.ts index f70f1dae9a..43da1b8bf9 100644 --- a/src/services/workitemtracking.ts +++ b/src/services/workitemtracking.ts @@ -23,7 +23,7 @@ export class WorkItemTrackingService { //Returns a Promise containing the WorkItem that was created public async CreateWorkItem(context: TeamServerContext, itemType: string, taskTitle: string): Promise { - let newWorkItem = [{ op: "add", path: "/fields/" + WorkItemFields.Title, value: taskTitle }]; + const newWorkItem = [{ op: "add", path: "/fields/" + WorkItemFields.Title, value: taskTitle }]; /* tslint:disable:no-null-keyword */ return await this._witApi.createWorkItem(null, newWorkItem, context.RepoInfo.TeamProject, itemType, false, false); /* tslint:enable:no-null-keyword */ @@ -46,18 +46,18 @@ export class WorkItemTrackingService { //Returns a Promise containing the array of work item types available for the team project public async GetWorkItemTypes(teamProject: string): Promise { - let types: WorkItemType[] = await this._witApi.getWorkItemTypes(teamProject); - let workItemTypes: WorkItemType[] = []; - let hiddenTypes: WorkItemTypeReference[] = []; + const types: WorkItemType[] = await this._witApi.getWorkItemTypes(teamProject); + const workItemTypes: WorkItemType[] = []; + const hiddenTypes: WorkItemTypeReference[] = []; types.forEach((type) => { workItemTypes.push(type); }); - let category: WorkItemTypeCategory = await this._witApi.getWorkItemTypeCategory(teamProject, "Microsoft.HiddenCategory"); + const category: WorkItemTypeCategory = await this._witApi.getWorkItemTypeCategory(teamProject, "Microsoft.HiddenCategory"); category.workItemTypes.forEach((hiddenType) => { hiddenTypes.push(hiddenType); }); - let filteredTypes: WorkItemType[] = workItemTypes.filter(function (el) { - for (let index = 0; index < hiddenTypes.length; index++) { + const filteredTypes: WorkItemType[] = workItemTypes.filter(function (el) { + for (let index: number = 0; index < hiddenTypes.length; index++) { if (el.name === hiddenTypes[index].name) { return false; } @@ -69,8 +69,8 @@ export class WorkItemTrackingService { //Returns a Promise containing a SimpleWorkItem representing the work item specified by id public async GetWorkItemById(id: string): Promise { - let workItem: WorkItem = await this._witApi.getWorkItem(parseInt(id), [WorkItemFields.Id, WorkItemFields.Title]); - let result: SimpleWorkItem = new SimpleWorkItem(); + const workItem: WorkItem = await this._witApi.getWorkItem(parseInt(id), [WorkItemFields.Id, WorkItemFields.Title]); + const result: SimpleWorkItem = new SimpleWorkItem(); result.id = workItem.id.toString(); result.label = workItem.fields[WorkItemFields.Title]; return result; @@ -79,7 +79,7 @@ export class WorkItemTrackingService { //Returns a Promise containing an array of SimpleWorkItems that are the results of the passed in wiql private async execWorkItemQuery(teamProject: string, wiql: Wiql): Promise { //Querying WIT requires a TeamContext - let teamContext: TeamContext = { + const teamContext: TeamContext = { projectId: undefined, project: teamProject, teamId: undefined, @@ -87,8 +87,8 @@ export class WorkItemTrackingService { }; // Execute the wiql and get the work item ids - let queryResult: WorkItemQueryResult = await this._witApi.queryByWiql(wiql, teamContext); - let results: SimpleWorkItem[] = []; + const queryResult: WorkItemQueryResult = await this._witApi.queryByWiql(wiql, teamContext); + const results: SimpleWorkItem[] = []; let workItemIds: number[] = []; if (queryResult.queryResultType === QueryResultType.WorkItem) { workItemIds = queryResult.workItems.map(function(w) {return w.id; }); @@ -104,15 +104,15 @@ export class WorkItemTrackingService { } /* tslint:disable:no-null-keyword */ - let workItems: WorkItem[] = await this._witApi.getWorkItems(workItemIds, - [WorkItemFields.Id, WorkItemFields.Title, WorkItemFields.WorkItemType], - null, - WorkItemExpand.None); + const workItems: WorkItem[] = await this._witApi.getWorkItems(workItemIds, + [WorkItemFields.Id, WorkItemFields.Title, WorkItemFields.WorkItemType], + null, + WorkItemExpand.None); /* tslint:enable:no-null-keyword */ //Keep original sort order that wiql specified - for (let index = 0; index < workItemIds.length; index++) { - let item: WorkItem = workItems.find((i) => i.id === workItemIds[index]); + for (let index: number = 0; index < workItemIds.length; index++) { + const item: WorkItem = workItems.find((i) => i.id === workItemIds[index]); results.push({ id: item.fields[WorkItemFields.Id], label: item.fields[WorkItemFields.Id] + " [" + item.fields[WorkItemFields.WorkItemType] + "]", @@ -125,7 +125,7 @@ export class WorkItemTrackingService { public async GetQueryResultCount(teamProject: string, wiql: string): Promise { //Querying WIT requires a TeamContext - let teamContext: TeamContext = { + const teamContext: TeamContext = { projectId: undefined, project: teamProject, teamId: undefined, @@ -133,7 +133,7 @@ export class WorkItemTrackingService { }; // Execute the wiql and get count of results - let queryResult: WorkItemQueryResult = await this._witApi.queryByWiql({ query: wiql}, teamContext); + const queryResult: WorkItemQueryResult = await this._witApi.queryByWiql({ query: wiql}, teamContext); //If a Promise is returned here, then() will return that Promise //If not, it will wrap the value within a Promise and return that return queryResult.workItems.length; diff --git a/src/team-extension.ts b/src/team-extension.ts index 86ea47629b..43b8961a20 100644 --- a/src/team-extension.ts +++ b/src/team-extension.ts @@ -68,10 +68,10 @@ export class TeamExtension { if (this._manager.ServerContext !== undefined && this._manager.ServerContext.RepoInfo !== undefined && this._manager.ServerContext.RepoInfo.IsTeamFoundation === true) { this._signedOut = false; if (this._manager.ServerContext.RepoInfo.IsTeamFoundationServer === true) { - let defaultUsername : string = this.getDefaultUsername(); - let username: string = await window.showInputBox({ value: defaultUsername || "", prompt: Strings.ProvideUsername + " (" + this._manager.ServerContext.RepoInfo.Account + ")", placeHolder: "", password: false }); + const defaultUsername : string = this.getDefaultUsername(); + const username: string = await window.showInputBox({ value: defaultUsername || "", prompt: Strings.ProvideUsername + " (" + this._manager.ServerContext.RepoInfo.Account + ")", placeHolder: "", password: false }); if (username !== undefined && username.length > 0) { - let password: string = await window.showInputBox({ value: "", prompt: Strings.ProvidePassword + " (" + username + ")", placeHolder: "", password: true }); + const password: string = await window.showInputBox({ value: "", prompt: Strings.ProvidePassword + " (" + username + ")", placeHolder: "", password: true }); if (password !== undefined) { Logger.LogInfo("Signin: Username and Password provided as authentication."); this._manager.CredentialManager.StoreCredentials(this._manager.ServerContext.RepoInfo.Host, username, password).then(() => { @@ -79,30 +79,30 @@ export class TeamExtension { this._manager.Reinitialize(); }).catch((err) => { // TODO: Should the message direct the user to open an issue? send feedback? - let msg: string = Strings.UnableToStoreCredentials + this._manager.ServerContext.RepoInfo.Host; + const msg: string = Strings.UnableToStoreCredentials + this._manager.ServerContext.RepoInfo.Host; this._manager.ReportError(err, msg, true); }); } } } else if (this._manager.ServerContext.RepoInfo.IsTeamServices === true) { // Until Device Flow, we can prompt for the PAT for Team Services - let token: string = await window.showInputBox({ value: "", prompt: Strings.ProvideAccessToken + " (" + this._manager.ServerContext.RepoInfo.Account + ")", placeHolder: "", password: true }); + const token: string = await window.showInputBox({ value: "", prompt: Strings.ProvideAccessToken + " (" + this._manager.ServerContext.RepoInfo.Account + ")", placeHolder: "", password: true }); if (token !== undefined) { Logger.LogInfo("Signin: Personal Access Token provided as authentication."); this._manager.CredentialManager.StoreCredentials(this._manager.ServerContext.RepoInfo.Host, Constants.OAuth, token.trim()).then(() => { this._manager.Reinitialize(); }).catch((err) => { // TODO: Should the message direct the user to open an issue? send feedback? - let msg: string = Strings.UnableToStoreCredentials + this._manager.ServerContext.RepoInfo.Host; + const msg: string = Strings.UnableToStoreCredentials + this._manager.ServerContext.RepoInfo.Host; this._manager.ReportError(err, msg, true); }); } } } else { //If _manager has an error to display, display it and forgo the other. Otherwise, show the default error message. - let displayed: boolean = this._manager.DisplayErrorMessage(); + const displayed: boolean = this._manager.DisplayErrorMessage(); if (!displayed) { - let messageItem : ButtonMessageItem = { title : Strings.LearnMore, + const messageItem : ButtonMessageItem = { title : Strings.LearnMore, url : Constants.ReadmeLearnMoreUrl, telemetryId: TelemetryEvents.ReadmeLearnMoreClick }; VsCodeUtils.ShowErrorMessage(Strings.NoRepoInformation, messageItem); @@ -116,7 +116,7 @@ export class TeamExtension { this._manager.CredentialManager.RemoveCredentials(this._manager.ServerContext.RepoInfo.Host).then(() => { Logger.LogInfo(`Signout: Removed credentials for host '${this._manager.ServerContext.RepoInfo.Host}'`); }).catch((err) => { - let msg: string = Strings.UnableToRemoveCredentials + this._manager.ServerContext.RepoInfo.Host; + const msg: string = Strings.UnableToRemoveCredentials + this._manager.ServerContext.RepoInfo.Host; this._manager.ReportError(err, msg, true); }).finally(() => { this._signedOut = true; //keep track of our status so we can display helpful info later @@ -167,7 +167,7 @@ export class TeamExtension { public OpenNewBug(): void { if (this._manager.EnsureInitialized(RepositoryType.ANY)) { //Bug is in all three templates - let taskTitle = VsCodeUtils.GetActiveSelection(); + const taskTitle = VsCodeUtils.GetActiveSelection(); this._witClient.CreateNewItem(WitTypes.Bug, taskTitle); } else { this._manager.DisplayErrorMessage(); @@ -190,7 +190,7 @@ export class TeamExtension { if (this._manager.EnsureInitialized(RepositoryType.ANY)) { //Issue is only in Agile and CMMI templates (not Scrum) //Task is in all three templates (Agile, CMMI, Scrum) - let taskTitle = VsCodeUtils.GetActiveSelection(); + const taskTitle = VsCodeUtils.GetActiveSelection(); this._witClient.CreateNewItem(WitTypes.Task, taskTitle); } else { this._manager.DisplayErrorMessage(); @@ -200,7 +200,7 @@ export class TeamExtension { //Opens a browser to a new work item (based on the work item type selected) public OpenNewWorkItem(): void { if (this._manager.EnsureInitialized(RepositoryType.ANY)) { - let taskTitle = VsCodeUtils.GetActiveSelection(); + const taskTitle = VsCodeUtils.GetActiveSelection(); this._witClient.CreateNewWorkItem(taskTitle); } else { this._manager.DisplayErrorMessage(); @@ -276,7 +276,7 @@ export class TeamExtension { public async AssociateWorkItems(): Promise { if (this._manager.EnsureInitialized(RepositoryType.ANY)) { Telemetry.SendEvent(TelemetryEvents.AssociateWorkItems); - let workitems: string[] = await this.chooseWorkItems(); + const workitems: string[] = await this.chooseWorkItems(); for (let i: number = 0; i < workitems.length; i++) { // Append the string to end of the message // Note: we are prefixing the message with a space so that the # char is not in the first column @@ -300,8 +300,8 @@ export class TeamExtension { private getDefaultUsername() : string { if (os.platform() === "win32") { let defaultUsername: string; - let domain: string = process.env.USERDOMAIN || ""; - let username: string = process.env.USERNAME || ""; + const domain: string = process.env.USERDOMAIN || ""; + const username: string = process.env.USERNAME || ""; if (domain !== undefined) { defaultUsername = domain; } diff --git a/src/tfvc/commands/add.ts b/src/tfvc/commands/add.ts index 49593caaa7..7613205d87 100644 --- a/src/tfvc/commands/add.ts +++ b/src/tfvc/commands/add.ts @@ -52,14 +52,14 @@ export class Add implements ITfvcCommand { //Ex. /usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md: No file matches. lines = lines.filter((e) => !e.endsWith(" No file matches.")); //tf.exe - let filesAdded: string[] = []; + const filesAdded: string[] = []; let path: string = ""; for (let index: number = 0; index < lines.length; index++) { - let line: string = lines[index]; + const line: string = lines[index]; if (CommandHelper.IsFilePath(line)) { path = line; } else { - let file: string = this.getFileFromLine(line); + const file: string = this.getFileFromLine(line); filesAdded.push(CommandHelper.GetFilePath(path, file)); } } diff --git a/src/tfvc/commands/commandhelper.ts b/src/tfvc/commands/commandhelper.ts index 5550a0b767..16a8999d49 100644 --- a/src/tfvc/commands/commandhelper.ts +++ b/src/tfvc/commands/commandhelper.ts @@ -98,10 +98,10 @@ export class CommandHelper { public static GetChangesetNumber(stdout: string): string { // parse output for changeset number if (stdout) { - let prefix: string = "Changeset #"; - let start: number = stdout.indexOf(prefix) + prefix.length; + const prefix: string = "Changeset #"; + const start: number = stdout.indexOf(prefix) + prefix.length; if (start >= 0) { - let end: number = stdout.indexOf(" ", start); + const end: number = stdout.indexOf(" ", start); if (end > start) { return stdout.slice(start, end); } diff --git a/src/tfvc/commands/delete.ts b/src/tfvc/commands/delete.ts index babef878cb..bcb7ad8394 100644 --- a/src/tfvc/commands/delete.ts +++ b/src/tfvc/commands/delete.ts @@ -63,16 +63,16 @@ export class Delete implements ITfvcCommand { public async ParseOutput(executionResult: IExecutionResult): Promise { CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult, true); - let lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, false, true /*filterEmptyLines*/); + const lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, false, true /*filterEmptyLines*/); - let filesUndone: string[] = []; + const filesUndone: string[] = []; let path: string = ""; for (let index: number = 0; index < lines.length; index++) { - let line: string = lines[index]; + const line: string = lines[index]; if (CommandHelper.IsFilePath(line)) { path = line; } else if (line) { - let file: string = this.getFileFromLine(line); + const file: string = this.getFileFromLine(line); filesUndone.push(CommandHelper.GetFilePath(path, file)); } } diff --git a/src/tfvc/commands/findconflicts.ts b/src/tfvc/commands/findconflicts.ts index 3728672c27..e18a9ea078 100644 --- a/src/tfvc/commands/findconflicts.ts +++ b/src/tfvc/commands/findconflicts.ts @@ -51,7 +51,7 @@ export class FindConflicts implements ITfvcCommand { CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); } - let conflicts: IConflict[] = []; + const conflicts: IConflict[] = []; const lines: string[] = CommandHelper.SplitIntoLines(executionResult.stderr, false, true); for (let i: number = 0; i < lines.length; i++) { const line: string = lines[i]; diff --git a/src/tfvc/commands/findworkspace.ts b/src/tfvc/commands/findworkspace.ts index dfa93c09e8..a46a7ffff8 100644 --- a/src/tfvc/commands/findworkspace.ts +++ b/src/tfvc/commands/findworkspace.ts @@ -68,7 +68,7 @@ export class FindWorkspace implements ITfvcCommand { let workspaceName: string = ""; let collectionUrl: string = ""; let equalsLineFound: boolean = false; - let mappings: IWorkspaceMapping[] = []; + const mappings: IWorkspaceMapping[] = []; let teamProject: string = undefined; for (let i: number = 0; i <= lines.length; i++) { @@ -162,7 +162,7 @@ export class FindWorkspace implements ITfvcCommand { * $/tfsTest_01: D:\tmp\test */ public async ParseExeOutput(executionResult: IExecutionResult): Promise { - let workspace: IWorkspace = await this.ParseOutput(executionResult); + const workspace: IWorkspace = await this.ParseOutput(executionResult); if (workspace && workspace.name) { // The workspace name includes the user name, so let's fix that const lastOpenParenIndex: number = workspace.name.lastIndexOf(" ("); diff --git a/src/tfvc/commands/getfilecontent.ts b/src/tfvc/commands/getfilecontent.ts index fb31d1feaa..35987bf3ad 100644 --- a/src/tfvc/commands/getfilecontent.ts +++ b/src/tfvc/commands/getfilecontent.ts @@ -32,7 +32,7 @@ export class GetFileContent implements ITfvcCommand { } public GetArguments(): IArgumentProvider { - let builder: ArgumentBuilder = new ArgumentBuilder("print", this._serverContext) + const builder: ArgumentBuilder = new ArgumentBuilder("print", this._serverContext) .Add(this._localPath); if (this._versionSpec) { builder.AddSwitchWithValue("version", this._versionSpec, false); @@ -63,7 +63,7 @@ export class GetFileContent implements ITfvcCommand { } public GetExeArguments(): IArgumentProvider { - let builder: ArgumentBuilder = new ArgumentBuilder("view", this._serverContext) + const builder: ArgumentBuilder = new ArgumentBuilder("view", this._serverContext) .Add(this._localPath); if (this._versionSpec) { builder.AddSwitchWithValue("version", this._versionSpec, false); diff --git a/src/tfvc/commands/getinfo.ts b/src/tfvc/commands/getinfo.ts index 87695bdaf4..37a30d44fd 100644 --- a/src/tfvc/commands/getinfo.ts +++ b/src/tfvc/commands/getinfo.ts @@ -58,7 +58,7 @@ export class GetInfo implements ITfvcCommand { // Throw if any errors are found in stderr or if exitcode is not 0 CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); - let itemInfos: IItemInfo[] = []; + const itemInfos: IItemInfo[] = []; if (!executionResult.stdout) { return itemInfos; } diff --git a/src/tfvc/commands/rename.ts b/src/tfvc/commands/rename.ts index da72e9d086..3138bc021e 100644 --- a/src/tfvc/commands/rename.ts +++ b/src/tfvc/commands/rename.ts @@ -60,15 +60,15 @@ export class Rename implements ITfvcCommand { //Throw if any errors are found in stderr or if exitcode is not 0 CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); - let lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, false, true /*filterEmptyLines*/); + const lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, false, true /*filterEmptyLines*/); let path: string = ""; for (let index: number = 0; index < lines.length; index++) { - let line: string = lines[index]; + const line: string = lines[index]; if (CommandHelper.IsFilePath(line)) { path = line; } else { - let file: string = this.getFileFromLine(line); + const file: string = this.getFileFromLine(line); return CommandHelper.GetFilePath(path, file); } } diff --git a/src/tfvc/commands/resolveconflicts.ts b/src/tfvc/commands/resolveconflicts.ts index 2c4f1305d4..a23a873908 100644 --- a/src/tfvc/commands/resolveconflicts.ts +++ b/src/tfvc/commands/resolveconflicts.ts @@ -50,7 +50,7 @@ export class ResolveConflicts implements ITfvcCommand { public async ParseOutput(executionResult: IExecutionResult): Promise { CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); - let conflicts: IConflict[] = []; + const conflicts: IConflict[] = []; const lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, true, true); for (let i: number = 0; i < lines.length; i++) { const line: string = lines[i]; diff --git a/src/tfvc/commands/status.ts b/src/tfvc/commands/status.ts index cd51ceaa07..02191fd5e1 100644 --- a/src/tfvc/commands/status.ts +++ b/src/tfvc/commands/status.ts @@ -34,7 +34,7 @@ export class Status implements ITfvcCommand { .AddSwitch("recursive"); if (this._localPaths && this._localPaths.length > 0) { - for (let i = 0; i < this._localPaths.length; i++) { + for (let i: number = 0; i < this._localPaths.length; i++) { builder.Add(this._localPaths[i]); } } @@ -63,7 +63,7 @@ export class Status implements ITfvcCommand { // Throw if any errors are found in stderr or if exitcode is not 0 CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); - let changes: IPendingChange[] = []; + const changes: IPendingChange[] = []; const xml: string = CommandHelper.TrimToXml(executionResult.stdout); // Parse the xml using xml2js const json: any = await CommandHelper.ParseXml(xml); @@ -71,14 +71,14 @@ export class Status implements ITfvcCommand { // get all the pending changes first const pending: any = json.status.pendingchanges[0].pendingchange; if (pending) { - for (let i = 0; i < pending.length; i++) { + for (let i: number = 0; i < pending.length; i++) { this.add(changes, this.convert(pending[i].$, false), this._ignoreFolders); } } // next, get all the candidate pending changes const candidate: any = json.status.candidatependingchanges[0].pendingchange; if (candidate) { - for (let i = 0; i < candidate.length; i++) { + for (let i: number = 0; i < candidate.length; i++) { this.add(changes, this.convert(candidate[i].$, true), this._ignoreFolders); } } @@ -93,7 +93,7 @@ export class Status implements ITfvcCommand { .AddSwitch("recursive"); if (this._localPaths && this._localPaths.length > 0) { - for (let i = 0; i < this._localPaths.length; i++) { + for (let i: number = 0; i < this._localPaths.length; i++) { builder.Add(this._localPaths[i]); } } @@ -134,7 +134,7 @@ export class Status implements ITfvcCommand { // Throw if any errors are found in stderr or if exitcode is not 0 CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); - let changes: IPendingChange[] = []; + const changes: IPendingChange[] = []; if (!executionResult.stdout) { return changes; } @@ -167,7 +167,7 @@ export class Status implements ITfvcCommand { if (line.startsWith("$/")) { //$/jeyou/README.md;C19 //versioned //$/jeyou/README.md //isCandidate - let parts: string[] = line.split(";C"); + const parts: string[] = line.split(";C"); curChange = { changeType: undefined, computer: undefined, date: undefined, localItem: undefined, sourceItem: undefined, lock: undefined, owner: undefined, @@ -183,7 +183,7 @@ export class Status implements ITfvcCommand { let propertyValue: string = colonPos + 1 < line.length ? line.slice(colonPos + 1).trim() : ""; if (propertyName.toLowerCase() === "localitem") { //Local item : [JEYOU-DEV00] C:\repos\TfExe.Tfvc.L2VSCodeExtension.RC.TFS\README.md - let parts: string[] = propertyValue.split("] "); + const parts: string[] = propertyValue.split("] "); curChange["computer"] = parts[0].substr(1); //pop off the beginning [ propertyValue = parts[1]; } diff --git a/src/tfvc/commands/sync.ts b/src/tfvc/commands/sync.ts index 7cf8d23356..74140a6b62 100644 --- a/src/tfvc/commands/sync.ts +++ b/src/tfvc/commands/sync.ts @@ -112,15 +112,15 @@ export class Sync implements ITfvcCommand { } private getItemResults(stdout: string): ISyncItemResult[] { - let itemResults: ISyncItemResult[] = []; + const itemResults: ISyncItemResult[] = []; let folderPath: string = ""; const lines: string[] = CommandHelper.SplitIntoLines(stdout, true, true); - for (let i = 0; i < lines.length; i++) { + for (let i: number = 0; i < lines.length; i++) { const line = lines[i]; if (CommandHelper.IsFilePath(line)) { folderPath = line; } else if (line) { - let sr: ISyncItemResult = this.getSyncResultFromLine(folderPath, line); + const sr: ISyncItemResult = this.getSyncResultFromLine(folderPath, line); if (sr) { itemResults.push(sr); } @@ -151,14 +151,14 @@ export class Sync implements ITfvcCommand { itemPath: CommandHelper.GetFilePath(folderPath, line.slice("Deleting ".length).trim()) }; } else if (line.startsWith("Conflict ")) { - let dashIndex = line.lastIndexOf("-"); + const dashIndex = line.lastIndexOf("-"); newResult = { syncType: SyncType.Conflict, itemPath: CommandHelper.GetFilePath(folderPath, line.slice("Conflict ".length, dashIndex).trim()), message: line.slice(dashIndex + 1).trim() }; } else if (line.startsWith("Warning ")) { - let dashIndex = line.lastIndexOf("-"); + const dashIndex = line.lastIndexOf("-"); newResult = { syncType: SyncType.Warning, itemPath: CommandHelper.GetFilePath(folderPath, line.slice("Warning ".length, dashIndex).trim()), @@ -166,7 +166,7 @@ export class Sync implements ITfvcCommand { }; } else { // This must be an error. Usually of the form "filename - message" or "filename cannot be deleted reason" - let index = line.lastIndexOf("-"); + let index: number = line.lastIndexOf("-"); if (index >= 0) { newResult = { syncType: SyncType.Error, @@ -197,9 +197,9 @@ export class Sync implements ITfvcCommand { * D:\tmp\vscodeBugBash\folder1 cannot be deleted because it is not empty. */ private getErrorMessages(stderr: string): ISyncItemResult[] { - let errorMessages: ISyncItemResult[] = []; + const errorMessages: ISyncItemResult[] = []; const lines: string[] = CommandHelper.SplitIntoLines(stderr, false, true); - for (let i = 0; i < lines.length; i++) { + for (let i: number = 0; i < lines.length; i++) { // stderr doesn't get any file path lines, so the files will all be just the filenames errorMessages.push(this.getSyncResultFromLine("", lines[i])); } diff --git a/src/tfvc/commands/undo.ts b/src/tfvc/commands/undo.ts index 5d543c4140..dd20201a26 100644 --- a/src/tfvc/commands/undo.ts +++ b/src/tfvc/commands/undo.ts @@ -53,7 +53,7 @@ export class Undo implements ITfvcCommand { // * All of the files have no pending changes (exitCode === 100) //If some of the files have no pending changes, we want to process the ones that did. //If all of the files have no pending changes, return [] - //Otherwise, we assume some error occurred so let that be thrown. + //Otherwise, we assume some error occurred so const that be thrown. if (executionResult.exitCode !== 0) { //Remove any entries for which there were no pending changes lines = lines.filter((e) => !e.startsWith("No pending changes ")); @@ -61,19 +61,19 @@ export class Undo implements ITfvcCommand { //All of the files had no pending changes, return [] return []; } else if (executionResult.exitCode !== 1) { - //Otherwise, some other error occurred, let that be thrown. + //Otherwise, some other error occurred, const that be thrown. CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); } } - let filesUndone: string[] = []; + const filesUndone: string[] = []; let path: string = ""; for (let index: number = 0; index < lines.length; index++) { - let line: string = lines[index]; + const line: string = lines[index]; if (CommandHelper.IsFilePath(line)) { path = line; } else if (line) { - let file: string = this.getFileFromLine(line); + const file: string = this.getFileFromLine(line); filesUndone.push(CommandHelper.GetFilePath(path, file)); } } @@ -95,7 +95,7 @@ export class Undo implements ITfvcCommand { //line could be 'Undoing edit: file1.txt', 'Undoing add: file1.txt' private getFileFromLine(line: string): string { const prefix: string = ": "; //"Undoing edit: ", "Undoing add: ", etc. - let idx: number = line.indexOf(prefix); + const idx: number = line.indexOf(prefix); if (idx > 0) { return line.substring(idx + prefix.length); } diff --git a/src/tfvc/scm/model.ts b/src/tfvc/scm/model.ts index 01d459b9b9..6911686524 100644 --- a/src/tfvc/scm/model.ts +++ b/src/tfvc/scm/model.ts @@ -105,7 +105,7 @@ export class Model implements Disposable { public async Exclude(paths: string[]): Promise { if (paths && paths.length > 0) { paths.forEach((path) => { - let normalizedPath: string = path.toLowerCase(); + const normalizedPath: string = path.toLowerCase(); if (!_.contains(this._explicitlyExcluded, normalizedPath)) { this._explicitlyExcluded.push(normalizedPath); } @@ -118,7 +118,7 @@ export class Model implements Disposable { public async Unexclude(paths: string[]): Promise { if (paths && paths.length > 0) { paths.forEach((path) => { - let normalizedPath: string = path.toLowerCase(); + const normalizedPath: string = path.toLowerCase(); if (_.contains(this._explicitlyExcluded, normalizedPath)) { this._explicitlyExcluded = _.without(this._explicitlyExcluded, normalizedPath); } @@ -214,9 +214,9 @@ export class Model implements Disposable { //When files are deleted in the VS Code Explorer, they are marked as Deleted but as candidate changes //So we are looking for those and then running the Delete command on each. private async processDeletes(changes: IPendingChange[]): Promise { - let deleteCandidatePaths: string[] = []; + const deleteCandidatePaths: string[] = []; for (let index: number = 0; index < changes.length; index++) { - let change: IPendingChange = changes[index]; + const change: IPendingChange = changes[index]; if (change.isCandidate && GetStatuses(change.changeType).find((e) => e === Status.DELETE)) { deleteCandidatePaths.push(change.localItem); } diff --git a/src/tfvc/scm/status.ts b/src/tfvc/scm/status.ts index 7bccb23e38..84f85c777b 100644 --- a/src/tfvc/scm/status.ts +++ b/src/tfvc/scm/status.ts @@ -5,7 +5,7 @@ "use strict"; export function GetStatuses(statusText: string): Status[] { - let result: Status[] = []; + const result: Status[] = []; if (!statusText) { return result; } diff --git a/src/tfvc/tfcommandlinerunner.ts b/src/tfvc/tfcommandlinerunner.ts index abbd65ff33..37b9e25c84 100644 --- a/src/tfvc/tfcommandlinerunner.ts +++ b/src/tfvc/tfcommandlinerunner.ts @@ -38,11 +38,11 @@ export class TfCommandLineRunner { public static GetCommandLine(localPath?: string): ITfCommandLine { Logger.LogDebug(`TFVC Creating Tfvc object with localPath='${localPath}'`); // Get Proxy from settings - const settings = new TfvcSettings(); - const proxy = settings.Proxy; + const settings: TfvcSettings = new TfvcSettings(); + const proxy: string = settings.Proxy; Logger.LogDebug(`Using TFS proxy: ${proxy}`); - let tfvcPath = localPath; + let tfvcPath: string = localPath; if (!tfvcPath) { // get the location from settings tfvcPath = settings.Location; @@ -57,7 +57,7 @@ export class TfCommandLineRunner { } // check to make sure that the file exists in that location - let exists: boolean = fs.existsSync(tfvcPath); + const exists: boolean = fs.existsSync(tfvcPath); if (exists) { // if it exists, check to ensure that it's a file and not a folder const stats: fs.Stats = fs.lstatSync(tfvcPath); @@ -250,7 +250,7 @@ export class TfCommandLineRunner { let stdout: string = buffers.join(""); if (isExe) { // TF.exe repeats the command line as part of the standard out when using the @ response file options - // So, we look for the noprompt option to let us know where that line is so we can strip it off + // So, we look for the noprompt option to const us know where that line is so we can strip it off const start: number = stdout.indexOf("-noprompt"); if (start >= 0) { const end: number = stdout.indexOf("\n", start); diff --git a/src/tfvc/tfvc-extension.ts b/src/tfvc/tfvc-extension.ts index c2966ec7b2..9ba81d7b5b 100644 --- a/src/tfvc/tfvc-extension.ts +++ b/src/tfvc/tfvc-extension.ts @@ -57,7 +57,7 @@ export class TfvcExtension { async () => { if (resources && resources.length > 0) { //Keep an in-memory list of items that were explicitly excluded. The list is not persisted at this time. - let paths: string[] = []; + const paths: string[] = []; resources.forEach((resource) => { paths.push(resource.resourceUri.fsPath); }); @@ -71,10 +71,10 @@ export class TfvcExtension { this.displayErrors( async () => { if (resources && resources.length > 0) { - let pathsToUnexclude: string[] = []; - let pathsToAdd: string[] = []; + const pathsToUnexclude: string[] = []; + const pathsToAdd: string[] = []; resources.forEach((resource) => { - let path: string = resource.resourceUri.fsPath; + const path: string = resource.resourceUri.fsPath; //Unexclude each file passed in pathsToUnexclude.push(path); //At this point, an unversioned file could be a candidate file, so call Add. @@ -162,11 +162,11 @@ export class TfvcExtension { this.displayErrors( async () => { if (uri) { - let basename: string = path.basename(uri.fsPath); - let newFilename: string = await window.showInputBox({ value: basename, prompt: Strings.RenamePrompt, placeHolder: undefined, password: false }); + const basename: string = path.basename(uri.fsPath); + const newFilename: string = await window.showInputBox({ value: basename, prompt: Strings.RenamePrompt, placeHolder: undefined, password: false }); if (newFilename && newFilename !== basename) { - let dirName: string = path.dirname(uri.fsPath); - let destination: string = path.join(dirName, newFilename); + const dirName: string = path.dirname(uri.fsPath); + const destination: string = path.join(dirName, newFilename); try { //We decided not to send telemetry on file operations @@ -191,7 +191,7 @@ export class TfvcExtension { this.displayErrors( async () => { if (resource) { - let localPath: string = resource.resourceUri.fsPath; + const localPath: string = resource.resourceUri.fsPath; const resolveTypeString: string = UIHelper.GetDisplayTextForAutoResolveType(autoResolveType); const basename: string = path.basename(localPath); const message: string = `Are you sure you want to resolve changes in ${basename} as ${resolveTypeString}?`; @@ -250,7 +250,7 @@ export class TfvcExtension { this.displayErrors( async () => { if (resources) { - let pathsToUndo: string[] = []; + const pathsToUndo: string[] = []; resources.forEach((resource) => { pathsToUndo.push(resource.resourceUri.fsPath); }); @@ -280,7 +280,7 @@ export class TfvcExtension { this.displayErrors( async () => { if (TfvcSCMProvider.HasItems()) { - let message: string = `Are you sure you want to undo all changes?`; + const message: string = `Are you sure you want to undo all changes?`; if (await UIHelper.PromptForConfirmation(message, Strings.UndoChanges)) { //We decided not to send telemetry on file operations await this._repo.Undo(["*"]); @@ -307,7 +307,7 @@ export class TfvcExtension { try { let itemPath: string; - let editor = window.activeTextEditor; + const editor = window.activeTextEditor; //Get the path to the file open in the VSCode editor (if any) if (editor) { itemPath = editor.document.fileName; @@ -318,12 +318,12 @@ export class TfvcExtension { return; } - let itemInfos: IItemInfo[] = await this._repo.GetInfo([itemPath]); + const itemInfos: IItemInfo[] = await this._repo.GetInfo([itemPath]); //With a single file, show that file's history if (itemInfos && itemInfos.length === 1) { Telemetry.SendEvent(TfvcTelemetryEvents.OpenFileHistory); - let serverPath: string = itemInfos[0].serverItem; - let file: string = encodeURIComponent(serverPath); + const serverPath: string = itemInfos[0].serverItem; + const file: string = encodeURIComponent(serverPath); let historyUrl: string = UrlBuilder.Join(this._manager.RepoContext.RemoteUrl, "_versionControl"); historyUrl = UrlBuilder.AddQueryParams(historyUrl, `path=${file}`, `_a=history`); Utils.OpenUrl(historyUrl); @@ -362,7 +362,7 @@ export class TfvcExtension { if (err.stdout) { //TODO: perhaps just for 'Checkin'? Or the CLC? TfvcOutput.AppendLine(VsCodeUtils.FormatMessage(`[${prefix}] ${err.stdout}`)); } - let messageItem: IButtonMessageItem = { title : Strings.ShowTfvcOutput, command: TfvcCommandNames.ShowOutput }; + const messageItem: IButtonMessageItem = { title : Strings.ShowTfvcOutput, command: TfvcCommandNames.ShowOutput }; VsCodeUtils.ShowErrorMessage(err.message, messageItem); } } diff --git a/src/tfvc/tfvcscmprovider.ts b/src/tfvc/tfvcscmprovider.ts index a9ac89f0e4..4d010e646d 100644 --- a/src/tfvc/tfvcscmprovider.ts +++ b/src/tfvc/tfvcscmprovider.ts @@ -74,7 +74,7 @@ export class TfvcSCMProvider { } private static getWorkItemIdsFromMessage(message: string) { - let ids: number[] = []; + const ids: number[] = []; try { // Find all the work item mentions in the string. // This returns an array like: ["#1", "#12", "#33"] @@ -166,7 +166,7 @@ export class TfvcSCMProvider { return; } - let repoContext: TfvcContext = this._extensionManager.RepoContext; + const repoContext: TfvcContext = this._extensionManager.RepoContext; const fsWatcher = workspace.createFileSystemWatcher("**"); const onWorkspaceChange = anyEvent(fsWatcher.onDidChange, fsWatcher.onDidCreate, fsWatcher.onDidDelete); const onTfvcChange = filterEvent(onWorkspaceChange, (uri) => /^\$tf\//.test(workspace.asRelativePath(uri))); @@ -182,8 +182,8 @@ export class TfvcSCMProvider { } TfvcOutput.AppendLine("Using TFVC command line: " + repoContext.TfvcRepository.TfvcLocation + " (" + version + ")"); - const commitHoverProvider = new CommitHoverProvider(); - const contentProvider = new TfvcContentProvider(repoContext.TfvcRepository, rootPath, onTfvcChange); + const commitHoverProvider: CommitHoverProvider = new CommitHoverProvider(); + const contentProvider: TfvcContentProvider = new TfvcContentProvider(repoContext.TfvcRepository, rootPath, onTfvcChange); //const checkoutStatusBar = new CheckoutStatusBar(model); //const syncStatusBar = new SyncStatusBar(model); //const autoFetcher = new AutoFetcher(model); diff --git a/src/tfvc/tfvcversion.ts b/src/tfvc/tfvcversion.ts index 682fd9ccdf..6ed09462b4 100644 --- a/src/tfvc/tfvcversion.ts +++ b/src/tfvc/tfvcversion.ts @@ -17,10 +17,10 @@ export class TfvcVersion { public static FromString(version: string): TfvcVersion { const parts: string[] = version ? version.split(TfvcVersion.separator) : []; - let major = parts.length >= 1 ? Number(parts[0]) : 0; - let minor = parts.length >= 2 ? Number(parts[1]) : 0; - let revision = parts.length >= 3 ? Number(parts[2]) : 0; - let build = parts.length >= 4 ? parts.slice(3).join(TfvcVersion.separator) : ""; + const major: number = parts.length >= 1 ? Number(parts[0]) : 0; + const minor: number = parts.length >= 2 ? Number(parts[1]) : 0; + const revision: number = parts.length >= 3 ? Number(parts[2]) : 0; + const build: string = parts.length >= 4 ? parts.slice(3).join(TfvcVersion.separator) : ""; return new TfvcVersion(major, minor, revision, build); } diff --git a/src/tfvc/uihelper.ts b/src/tfvc/uihelper.ts index 3c79f92bc0..b7f1457949 100644 --- a/src/tfvc/uihelper.ts +++ b/src/tfvc/uihelper.ts @@ -15,8 +15,8 @@ export class UIHelper { public static async ChoosePendingChange(changes: IPendingChange[]): Promise { if (changes && changes.length > 0) { // First, create an array of quick pick items from the changes - let items: QuickPickItem[] = []; - for (let i = 0; i < changes.length; i++) { + const items: QuickPickItem[] = []; + for (let i: number = 0; i < changes.length; i++) { items.push({ label: UIHelper.GetFileName(changes[i]), description: changes[i].changeType, @@ -24,19 +24,19 @@ export class UIHelper { }); } // Then, show the quick pick window and get back the one they chose - let item: QuickPickItem = await window.showQuickPick( + const item: QuickPickItem = await window.showQuickPick( items, { matchOnDescription: true, placeHolder: Strings.ChooseItemQuickPickPlaceHolder }); // Finally, find the matching pending change and return it if (item) { - for (let i = 0; i < changes.length; i++) { + for (let i: number = 0; i < changes.length; i++) { if (UIHelper.GetRelativePath(changes[i]) === item.detail) { return changes[i]; } } } } else if (changes && changes.length === 0) { - let items: QuickPickItem[] = []; + const items: QuickPickItem[] = []; items.push({ label: Strings.TfNoPendingChanges, description: undefined, @@ -51,7 +51,7 @@ export class UIHelper { * This method displays the results of the sync command in the output window and optionally in the QuickPick window as well. */ public static async ShowSyncResults(syncResults: ISyncResults, showPopup: boolean, onlyShowErrors): Promise { - let items: QuickPickItem[] = []; + const items: QuickPickItem[] = []; if (syncResults.itemResults.length === 0) { TfvcOutput.AppendLine(Strings.AllFilesUpToDate); items.push({ @@ -61,11 +61,11 @@ export class UIHelper { }); } else { for (let i: number = 0; i < syncResults.itemResults.length; i++) { - let item: ISyncItemResult = syncResults.itemResults[i]; + const item: ISyncItemResult = syncResults.itemResults[i]; if (onlyShowErrors && !UIHelper.isSyncError(item.syncType)) { continue; } - let type: string = this.GetDisplayTextForSyncType(item.syncType); + const type: string = this.GetDisplayTextForSyncType(item.syncType); TfvcOutput.AppendLine(type + ": " + item.itemPath + " : " + item.message); items.push({ label: type, @@ -120,7 +120,7 @@ export class UIHelper { public static GetFileName(change: IPendingChange): string { if (change && change.localItem) { - let filename: string = path.parse(change.localItem).base; + const filename: string = path.parse(change.localItem).base; return filename; } diff --git a/test/helpers/urlbuilder.test.ts b/test/helpers/urlbuilder.test.ts index b36707dd44..3220275317 100644 --- a/test/helpers/urlbuilder.test.ts +++ b/test/helpers/urlbuilder.test.ts @@ -168,7 +168,7 @@ describe("UrlBuilder", function() { const url: string = "http://xplatalm.visualstudio.com/"; const arg: string = "#path"; - let result: string = UrlBuilder.AddHashes(url, arg); + const result: string = UrlBuilder.AddHashes(url, arg); assert.equal(`http://xplatalm.visualstudio.com${arg}`, result); }); diff --git a/tslint.json b/tslint.json index e2fa4c1f05..f06b14a4ef 100644 --- a/tslint.json +++ b/tslint.json @@ -42,7 +42,7 @@ "check-whitespace" ], "one-variable-per-declaration": true, - "prefer-const": false, + "prefer-const": true, "prefer-method-signature": true, "quotemark": [true, "double"], "radix": false, From 3a6e30d75c3663c7e3142893f5e71cb659d9084b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 May 2017 14:27:00 -0400 Subject: [PATCH 6/6] Fix aggressiveness on replacing 'let' with 'const' --- src/tfvc/commands/undo.ts | 2 +- src/tfvc/tfcommandlinerunner.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tfvc/commands/undo.ts b/src/tfvc/commands/undo.ts index dd20201a26..4dfba20f75 100644 --- a/src/tfvc/commands/undo.ts +++ b/src/tfvc/commands/undo.ts @@ -53,7 +53,7 @@ export class Undo implements ITfvcCommand { // * All of the files have no pending changes (exitCode === 100) //If some of the files have no pending changes, we want to process the ones that did. //If all of the files have no pending changes, return [] - //Otherwise, we assume some error occurred so const that be thrown. + //Otherwise, we assume some error occurred so allow that to be thrown. if (executionResult.exitCode !== 0) { //Remove any entries for which there were no pending changes lines = lines.filter((e) => !e.startsWith("No pending changes ")); diff --git a/src/tfvc/tfcommandlinerunner.ts b/src/tfvc/tfcommandlinerunner.ts index 37b9e25c84..f25d74b05f 100644 --- a/src/tfvc/tfcommandlinerunner.ts +++ b/src/tfvc/tfcommandlinerunner.ts @@ -250,7 +250,7 @@ export class TfCommandLineRunner { let stdout: string = buffers.join(""); if (isExe) { // TF.exe repeats the command line as part of the standard out when using the @ response file options - // So, we look for the noprompt option to const us know where that line is so we can strip it off + // So, we look for the noprompt option to allow us to know where that line is so we can strip it off const start: number = stdout.indexOf("-noprompt"); if (start >= 0) { const end: number = stdout.indexOf("\n", start);