Skip to content

Commit

Permalink
Revert "Move *.unit.test.ts closer to the source files being tested (#…
Browse files Browse the repository at this point in the history
…9181)"

This reverts commit 942cec0.
  • Loading branch information
DonJayamanne committed Mar 2, 2022
1 parent fbc6dfb commit c2277a3
Show file tree
Hide file tree
Showing 81 changed files with 394 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ module.exports = {
basePath: './src',
zones: [
{
target: './client/**/*[!unit.].ts',
target: './client',
from: './test',
message: 'Importing test modules from ./src/test into extension code in .src/client, is not allowed.'
}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"args": [
"./out/**/*.unit.test.js",
"./out/test/**/*.unit.test.js",
"--require=out/test/unittests.js",
"--ui=tdd",
"--recursive",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"--max-line-length=88"
],
"typescript.preferences.importModuleSpecifier": "relative",
"mochaExplorer.files": "./out/**/*.unit.test.js",
"mochaExplorer.files": "./out/test/**/*.unit.test.js",
"mochaExplorer.require": ["ts-node/register", "./out/test/unittests.js"],
"mochaExplorer.ui": "tdd",
"mochaExplorer.nodeArgv": ["--enable-source-maps"]
Expand Down
2 changes: 1 addition & 1 deletion build/.mocha.unittests.js.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "./out/**/*.unit.test.js",
"spec": "./out/test/**/*.unit.test.js",
"require": ["source-map-support/register", "out/test/unittests.js"],
"reporter": "mocha-multi-reporters",
"reporter-option": "configFile=build/.mocha-multi-reporters.config",
Expand Down
2 changes: 1 addition & 1 deletion build/.mocha.unittests.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "./out/**/*.unit.test.js",
"spec": "./out/test/**/*.unit.test.js",
"require": ["out/test/unittests.js"],
"reporter": "mocha-multi-reporters",
"reporter-option": "configFile=build/.mocha-multi-reporters.config",
Expand Down
23 changes: 23 additions & 0 deletions src/client/common/helpers.unit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as assert from 'assert';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import { isNotInstalledError } from './helpers';

// Defines a Mocha test suite to group tests of similar kind together
suite('helpers', () => {
test('isNotInstalledError', (done) => {
const error = new Error('something is not installed');
assert.equal(isNotInstalledError(error), false, 'Standard error');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(error as any).code = 'ENOENT';
assert.equal(isNotInstalledError(error), true, 'ENOENT error code not detected');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(error as any).code = 127;
assert.equal(isNotInstalledError(error), true, '127 error code not detected');

done();
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { assert } from 'chai';
import { anyString, anything, instance, mock, when } from 'ts-mockito';
import { MigrateDataScienceSettingsService } from './migrateDataScienceSettingsService';
import { ApplicationEnvironment } from '../common/application/applicationEnvironment';
import { IApplicationEnvironment, IWorkspaceService } from '../common/application/types';
import { WorkspaceService } from '../common/application/workspace';
import { PersistentStateFactory, PersistentState } from '../common/persistentState';
import { IPersistentStateFactory } from '../common/types';
import { JupyterServerUriStorage } from '../datascience/jupyter/serverUriStorage';
import { IJupyterServerUriStorage } from '../datascience/types';
import { MockFileSystem } from '../../test/datascience/mockFileSystem';
import { MigrateDataScienceSettingsService } from '../../client/activation/migrateDataScienceSettingsService';
import { ApplicationEnvironment } from '../../client/common/application/applicationEnvironment';
import { IApplicationEnvironment, IWorkspaceService } from '../../client/common/application/types';
import { WorkspaceService } from '../../client/common/application/workspace';
import { PersistentStateFactory, PersistentState } from '../../client/common/persistentState';
import { IPersistentStateFactory } from '../../client/common/types';
import { JupyterServerUriStorage } from '../../client/datascience/jupyter/serverUriStorage';
import { IJupyterServerUriStorage } from '../../client/datascience/types';
import { MockFileSystem } from '../datascience/mockFileSystem';

suite('Migrate data science settings', () => {
const fs = new MockFileSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
'use strict';

import { anything, capture, instance, mock, verify, when } from 'ts-mockito';
import { ApplicationShell } from '../applicationShell';
import { CommandManager } from '../commandManager';
import { ReloadVSCodeCommandHandler } from './reloadCommand';
import { IApplicationShell, ICommandManager } from '../types';
import { Common } from '../../utils/localize';
import { ApplicationShell } from '../../../../client/common/application/applicationShell';
import { CommandManager } from '../../../../client/common/application/commandManager';
import { ReloadVSCodeCommandHandler } from '../../../../client/common/application/commands/reloadCommand';
import { IApplicationShell, ICommandManager } from '../../../../client/common/application/types';
import { Common } from '../../../../client/common/utils/localize';

// Defines a Mocha test suite to group tests of similar kind together
suite('Common Commands ReloadCommand', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import { expect } from 'chai';
import * as TypeMoq from 'typemoq';
import { ConfigurationTarget, Uri, WorkspaceConfiguration } from 'vscode';
import { IWorkspaceService } from '../application/types';
import { JupyterSettings } from '../configSettings';
import { ConfigurationService } from './service';
import { IExperimentService } from '../types';
import { IServiceContainer } from '../../ioc/types';
import { IWorkspaceService } from '../../../client/common/application/types';
import { JupyterSettings } from '../../../client/common/configSettings';
import { ConfigurationService } from '../../../client/common/configuration/service';
import { IExperimentService } from '../../../client/common/types';
import { IServiceContainer } from '../../../client/ioc/types';

suite('Configuration Service', () => {
const resource = Uri.parse('a');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assert, expect } from 'chai';
import * as fs from 'fs-extra';
import * as path from 'path';
import { CryptoUtils } from '../../client/common/crypto';
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../test/constants';
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../constants';

const RANDOM_WORDS = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'test', 'common', 'randomWords.txt');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import { assert } from 'chai';
import * as sinon from 'sinon';
import { anything, instance, mock, when } from 'ts-mockito';
import * as tasClient from 'vscode-tas-client';
import { ApplicationEnvironment } from '../application/applicationEnvironment';
import { Channel, IApplicationEnvironment, IWorkspaceService } from '../application/types';
import { WorkspaceService } from '../application/workspace';
import { ConfigurationService } from '../configuration/service';
import { ExperimentService } from './service';
import { IConfigurationService } from '../types';
import * as Telemetry from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { JVSC_EXTENSION_ID_FOR_TESTS } from '../../../test/constants';
import { MockOutputChannel } from '../../../test/mockClasses';
import { MockMemento } from '../../../test/mocks/mementos';
import { ApplicationEnvironment } from '../../../client/common/application/applicationEnvironment';
import { Channel, IApplicationEnvironment, IWorkspaceService } from '../../../client/common/application/types';
import { WorkspaceService } from '../../../client/common/application/workspace';
import { ConfigurationService } from '../../../client/common/configuration/service';
import { ExperimentService } from '../../../client/common/experiments/service';
import { IConfigurationService } from '../../../client/common/types';
import * as Telemetry from '../../../client/telemetry';
import { EventName } from '../../../client/telemetry/constants';
import { JVSC_EXTENSION_ID_FOR_TESTS } from '../../constants';
import { MockOutputChannel } from '../../mockClasses';
import { MockMemento } from '../../mocks/mementos';
suite('Experimentation service', () => {
const extensionVersion = '1.2.3';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import { assert } from 'chai';
import * as sinon from 'sinon';
import { ExperimentationTelemetry } from './telemetry';
import * as Telemetry from '../../telemetry';
import { ExperimentationTelemetry } from '../../../client/common/experiments/telemetry';
import * as Telemetry from '../../../client/telemetry';

suite('Experimentation telemetry', () => {
const event = 'SomeEventName';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import './extensions';
import '../../client/common/extensions';

// Defines a Mocha test suite to group tests of similar kind together
suite('String Extensions', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import * as sinon from 'sinon';
import { Readable } from 'stream';
import { anything, instance, mock, verify, when } from 'ts-mockito';
import { Progress } from 'vscode';
import { ApplicationShell } from '../application/applicationShell';
import { IApplicationShell } from '../application/types';
import { FileDownloader } from './fileDownloader';
import { HttpClient } from './httpClient';
import { FileSystem } from '../platform/fileSystem';
import { PlatformService } from '../platform/platformService';
import { IFileSystem } from '../platform/types';
import { IHttpClient } from '../types';
import { Http } from '../utils/localize';
import { EXTENSION_ROOT_DIR } from '../../constants';
import { noop } from '../../../test/core';
import { MockOutputChannel } from '../../../test/mockClasses';
import { ApplicationShell } from '../../../client/common/application/applicationShell';
import { IApplicationShell } from '../../../client/common/application/types';
import { FileDownloader } from '../../../client/common/net/fileDownloader';
import { HttpClient } from '../../../client/common/net/httpClient';
import { FileSystem } from '../../../client/common/platform/fileSystem';
import { PlatformService } from '../../../client/common/platform/platformService';
import { IFileSystem } from '../../../client/common/platform/types';
import { IHttpClient } from '../../../client/common/types';
import { Http } from '../../../client/common/utils/localize';
import { EXTENSION_ROOT_DIR } from '../../../client/constants';
import { noop } from '../../core';
import { MockOutputChannel } from '../../mockClasses';
const requestProgress = require('request-progress');
const request = require('request');

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
isFileNotFoundError,
isNoPermissionsError,
isNotDirError
} from './errors';
import { SystemError } from '../../../test/common/platform/utils';
} from '../../../client/common/platform/errors';
import { SystemError } from './utils';

suite('FileSystem - errors', () => {
const filename = 'spam';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import { expect } from 'chai';
import * as path from 'path';
import * as TypeMoq from 'typemoq';
import { FileSystemPathUtils } from './fs-paths';
import { getNamesAndValues } from '../../../test/utils/enum';
import { OSType } from '../utils/platform';
import { FileSystemPathUtils } from '../../../client/common/platform/fs-paths';
import { getNamesAndValues } from '../../utils/enum';
import { OSType } from '../../../client/common/utils/platform';

interface IUtilsDeps {
// executables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import * as TypeMoq from 'typemoq';
// eslint-disable-next-line @typescript-eslint/no-require-imports
import untildify = require('untildify');

import { PathUtils } from '../platform/pathUtils';
import { ProcessLogger } from './logger';
import { IOutputChannel } from '../types';
import { Logging } from '../utils/localize';
import { getOSType, OSType } from '../../../test/common';
import { PathUtils } from '../../../client/common/platform/pathUtils';
import { ProcessLogger } from '../../../client/common/process/logger';
import { IOutputChannel } from '../../../client/common/types';
import { Logging } from '../../../client/common/utils/localize';
import { getOSType, OSType } from '../../common';

/* eslint-disable */
suite('ProcessLogger suite', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { expect } from 'chai';
import { ChildProcess, spawn } from 'child_process';
import { ProcessService } from '../../../client/common/process/proc';
import { createDeferred, Deferred } from '../../../client/common/utils/async';
import { PYTHON_PATH } from '../../../test/common';
import { PYTHON_PATH } from '../../common';

interface IProcData {
proc: ChildProcess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { IProcessLogger, IPythonExecutionService, Output } from '../../../client
import { ReadWrite } from '../../../client/common/types';
import { sleep } from '../../../client/common/utils/async';
import { InterpreterInformation, PythonEnvironment } from '../../../client/pythonEnvironments/info';
import { asyncDump } from '../../../test/common/asyncDump';
import { noop } from '../../../test/core';
import { noop } from '../../core';
import { asyncDump } from '../asyncDump';
use(chaiPromised);

/* eslint-disable @typescript-eslint/no-explicit-any, */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createPythonEnv } from '../../../client/common/process/pythonEnvironmen
import { createPythonProcessService } from '../../../client/common/process/pythonProcess';
import { IProcessService, StdErrError } from '../../../client/common/process/types';
import { PythonEnvironment } from '../../../client/pythonEnvironments/info';
import { noop } from '../../../test/core';
import { noop } from '../../core';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import * as assert from 'assert';
import { chain, createDeferred, flattenIterator } from './async';
import { chain, createDeferred, flattenIterator } from '../../../client/common/utils/async';

suite('Deferred', () => {
test('Resolve', (done) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { expect, use } from 'chai';
import * as chaiPromise from 'chai-as-promised';
import { clearCache } from '../../../client/common/utils/cacheUtils';
import { cache, makeDebounceAsyncDecorator, makeDebounceDecorator } from '../../../client/common/utils/decorators';
import { sleep } from '../../../test/core';
import { sleep } from '../../core';
use(chaiPromise);

/* eslint-disable @typescript-eslint/no-explicit-any, , @typescript-eslint/no-extraneous-class */
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as path from 'path';
import * as TypeMoq from 'typemoq';
import { IFileSystem } from '../platform/types';
import { EnvironmentVariablesService, parseEnvFile } from './environment';
import { IFileSystem } from '../../../client/common/platform/types';
import { EnvironmentVariablesService, parseEnvFile } from '../../../client/common/variables/environment';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as TypeMoq from 'typemoq';
import * as path from 'path';
import { IFileSystem } from '../../common/platform/types';
import { EnvironmentVariablesService } from '../../common/variables/environment';
import { IEnvironmentVariablesProvider } from '../../common/variables/types';
import { KernelEnvironmentVariablesService } from './kernelEnvVarsService';
import { IJupyterKernelSpec } from '../types';
import { IEnvironmentActivationService } from '../../interpreter/activation/types';
import { IInterpreterService } from '../../interpreter/contracts';
import { EnvironmentType, PythonEnvironment } from '../../pythonEnvironments/info';
import { IFileSystem } from '../../../client/common/platform/types';
import { EnvironmentVariablesService } from '../../../client/common/variables/environment';
import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types';
import { KernelEnvironmentVariablesService } from '../../../client/datascience/kernel-launcher/kernelEnvVarsService';
import { IJupyterKernelSpec } from '../../../client/datascience/types';
import { IEnvironmentActivationService } from '../../../client/interpreter/activation/types';
import { IInterpreterService } from '../../../client/interpreter/contracts';
import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';
import { assert } from 'chai';
import { generateCells } from '../../client/datascience/cellFactory';
import { removeLinesFromFrontAndBack, stripComments } from '.';
import { removeLinesFromFrontAndBack, stripComments } from '../../datascience-ui/common';
import * as vscode from 'vscode';

/* eslint-disable */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { assert } from 'chai';
import { IJupyterSettings } from '../../client/common/types';
import { CellMatcher } from '../../client/datascience/cellMatcher';
import { defaultDataScienceSettings } from '../../test/datascience/helpers';
import { defaultDataScienceSettings } from './helpers';

suite('DataScience CellMatcher', () => {
test('CellMatcher', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License.
import { anything, capture, instance, mock, verify } from 'ts-mockito';
import { Uri } from 'vscode';
import { CommandManager } from '../../common/application/commandManager';
import { ICommandManager } from '../../common/application/types';
import { JupyterServerSelectorCommand } from './serverSelector';
import { Commands } from '../constants';
import { JupyterServerSelector } from '../jupyter/serverSelector';
import { CommandManager } from '../../../client/common/application/commandManager';
import { ICommandManager } from '../../../client/common/application/types';
import { JupyterServerSelectorCommand } from '../../../client/datascience/commands/serverSelector';
import { Commands } from '../../../client/datascience/constants';
import { JupyterServerSelector } from '../../../client/datascience/jupyter/serverSelector';

/* eslint-disable */
suite('DataScience - Server Selector Command', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
'use strict';
import { assert } from 'chai';
import { formatStreamText } from '.';
import { formatStreamText } from '../../datascience-ui/common';

suite('DataScience Common Tests', () => {
test('formatting stream text', async () => {
Expand Down
Loading

0 comments on commit c2277a3

Please sign in to comment.