Skip to content

Commit

Permalink
test: add WorkspaceRoot.createTestItem tests for item's URI
Browse files Browse the repository at this point in the history
  • Loading branch information
akwodkiewicz committed Oct 16, 2023
1 parent 53b7c8e commit 5079dd8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test-provider/test-item-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ jest.unmock('../../src/test-provider/test-item-data');
jest.unmock('../../src/test-provider/test-provider-helper');
jest.unmock('../../src/appGlobals');
jest.unmock('../../src/TestResults/match-node');
jest.unmock('../../src/virtual-workspace-folder');
jest.unmock('../../src/TestResults/match-by-context');
jest.unmock('../test-helper');
jest.unmock('./test-helper');
Expand Down Expand Up @@ -48,6 +49,7 @@ import { mockController, mockExtExplorerContext } from './test-helper';
import * as errors from '../../src/errors';
import { ItemCommand } from '../../src/test-provider/types';
import { RunMode } from '../../src/JestExt/run-mode';
import { VirtualWorkspaceFolder } from '../../src/virtual-workspace-folder';

const mockPathSep = (newSep: string) => {
(path as jest.Mocked<any>).setSep(newSep);
Expand Down Expand Up @@ -1459,6 +1461,43 @@ describe('test-item-data', () => {
});
});
});
describe('createTestItem', () => {
describe('for a regular workspace folder', () => {
let workspaceFolder: vscode.WorkspaceFolder;
let wsRoot: WorkspaceRoot;

beforeEach(() => {
workspaceFolder = helper.makeWorkspaceFolder('workspace-1');
wsRoot = createAllTestItems().wsRoot;
wsRoot.context.ext.workspace = workspaceFolder;
});

it("creates an item using folder's uri", () => {
const item = wsRoot.createTestItem();
expect(item.uri).toEqual(workspaceFolder.uri);
});
});

describe('for a virtual workspace folder', () => {
let virtualWorkspaceFolder: VirtualWorkspaceFolder;
let wsRoot: WorkspaceRoot;

beforeEach(() => {
virtualWorkspaceFolder = new VirtualWorkspaceFolder(
helper.makeWorkspaceFolder('workspace-1'),
'virtual-a',
'packages/a'
);
wsRoot = createAllTestItems().wsRoot;
wsRoot.context.ext.workspace = virtualWorkspaceFolder;
});

it("creates an item using virtual folder's effectiveUri", () => {
const item = wsRoot.createTestItem();
expect(item.uri).toEqual(virtualWorkspaceFolder.effectiveUri);
});
});
});
});

describe('simulate complete run flow', () => {
Expand Down

0 comments on commit 5079dd8

Please # to comment.