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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/client/testing/explorer/testTreeViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
'use strict';

import { inject, injectable } from 'inversify';
import * as path from 'path';
import { Event, EventEmitter, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { ICommandManager, IWorkspaceService } from '../../common/application/types';
import { Commands } from '../../common/constants';
import { IFileSystem } from '../../common/platform/types';
import { IDisposable, IDisposableRegistry } from '../../common/types';
import { sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
Expand All @@ -32,7 +30,6 @@ export class TestTreeViewProvider implements ITestTreeViewProvider, ITestDataIte
@inject(ITestManagementService) private testService: ITestManagementService,
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
@inject(ICommandManager) private readonly commandManager: ICommandManager,
@inject(IFileSystem) private readonly fs: IFileSystem,
@inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry
) {
this.onDidChangeTreeData = this._onDidChangeTreeData.event;
Expand Down Expand Up @@ -145,9 +142,7 @@ export class TestTreeViewProvider implements ITestTreeViewProvider, ITestDataIte
*/
public getRootNodes(tests?: Tests) {
if (tests && tests.rootTestFolders && tests.rootTestFolders.length === 1) {
const rootFolder = tests.rootTestFolders[0].name;
const testFiles = tests.testFiles.filter(file => this.fs.arePathsSame(path.dirname(file.fullPath), rootFolder));
return [...testFiles, ...tests.rootTestFolders[0].folders];
return [...tests.rootTestFolders[0].testFiles, ...tests.rootTestFolders[0].folders];
}
return tests ? tests.rootTestFolders : [];
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/testing/explorer/explorerTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { CommandManager } from '../../../client/common/application/commandManage
import {
IApplicationShell, ICommandManager, IWorkspaceService
} from '../../../client/common/application/types';
import { FileSystem } from '../../../client/common/platform/fileSystem';
import {
IDisposable, IDisposableRegistry
} from '../../../client/common/types';
Expand Down Expand Up @@ -257,6 +256,6 @@ export function createMockTestExplorer(

return new TestTreeViewProvider(
testStore, unitTestMgmtService, workspaceService, commandManager,
tsmockito.instance(tsmockito.mock(FileSystem)), dispRegMoq.object
dispRegMoq.object
);
}
19 changes: 7 additions & 12 deletions src/test/testing/explorer/testTreeViewProvider.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

import { expect } from 'chai';
import * as path from 'path';
import { anything, instance, mock, verify, when } from 'ts-mockito';
import { instance, mock, verify, when } from 'ts-mockito';
import * as typemoq from 'typemoq';
import { TreeItemCollapsibleState, Uri } from 'vscode';
import { CommandManager } from '../../../client/common/application/commandManager';
import { WorkspaceService } from '../../../client/common/application/workspace';
import { Commands } from '../../../client/common/constants';
import { FileSystem } from '../../../client/common/platform/fileSystem';
import { IFileSystem } from '../../../client/common/platform/types';
import { IDisposable } from '../../../client/common/types';
import { CommandSource } from '../../../client/testing/common/constants';
import { TestCollectionStorageService } from '../../../client/testing/common/services/storageService';
Expand Down Expand Up @@ -708,23 +706,20 @@ suite('Unit Tests Test Explorer TestTreeViewProvider', () => {
});
suite('Root Nodes', () => {
let treeProvider: TestTreeViewProvider;
let fs: IFileSystem;
setup(() => {
const store = mock(TestCollectionStorageService);
const managementService = mock(UnitTestManagementService);
when(managementService.onDidStatusChange).thenReturn(noop as any);
when(store.onDidChange).thenReturn(noop as any);
const workspace = mock(WorkspaceService);
when(workspace.onDidChangeWorkspaceFolders).thenReturn(noop as any);
fs = mock(FileSystem);
when(fs.arePathsSame(anything(), anything())).thenCall((path1: string, path2: string) => path1 === path2);
const commandManager = mock(CommandManager);
treeProvider = new TestTreeViewProvider(instance(store), instance(managementService),
instance(workspace), instance(commandManager), instance(fs), []);
instance(workspace), instance(commandManager), []);

});
test('The root folder will not be displayed if there are no tests', async () => {
const children = await treeProvider.getRootNodes();
const children = treeProvider.getRootNodes();

expect(children).to.deep.equal([]);
});
Expand All @@ -745,7 +740,7 @@ suite('Unit Tests Test Explorer TestTreeViewProvider', () => {
testFolders: [],
testSuites: []
};
const children = await treeProvider.getRootNodes(tests);
const children = treeProvider.getRootNodes(tests);

expect(children).to.deep.equal([]);
});
Expand Down Expand Up @@ -803,7 +798,7 @@ suite('Unit Tests Test Explorer TestTreeViewProvider', () => {
folders: [child1Folder],
name: rootFolderPath,
nameToRun: 'child',
testFiles: [],
testFiles: [file1, file2],
time: 0,
resource: Uri.file(__filename)
};
Expand All @@ -815,7 +810,7 @@ suite('Unit Tests Test Explorer TestTreeViewProvider', () => {
testFolders: [rootFolder, child1Folder, child2Folder],
testSuites: []
};
const children = await treeProvider.getRootNodes(tests);
const children = treeProvider.getRootNodes(tests);

expect(children).to.be.lengthOf(3);
expect(children).to.deep.equal([file1, file2, child1Folder]);
Expand Down Expand Up @@ -886,7 +881,7 @@ suite('Unit Tests Test Explorer TestTreeViewProvider', () => {
testFolders: [child3Folder, child1Folder, child2Folder],
testSuites: []
};
const children = await treeProvider.getRootNodes(tests);
const children = treeProvider.getRootNodes(tests);

expect(children).to.be.lengthOf(2);
expect(children).to.deep.equal([child1Folder, child3Folder]);
Expand Down