Skip to content

Commit 9730b79

Browse files
committed
Improve refactorability in tests.
1 parent b33ffb5 commit 9730b79

29 files changed

+68
-66
lines changed

apps/rush-lib/src/api/test/ChangeFile.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ChangeFile } from '../ChangeFile';
77
import { RushConfiguration } from '../RushConfiguration';
88
import { ChangeType } from '../ChangeManagement';
99

10-
describe('ChangeFile', () => {
10+
describe(ChangeFile.name, () => {
1111
it('can add a change', () => {
1212
const rushFilename: string = path.resolve(__dirname, 'repo', 'rush-npm.json');
1313
const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushFilename);

apps/rush-lib/src/api/test/CommonVersionsConfiguration.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55

66
import { CommonVersionsConfiguration } from '../CommonVersionsConfiguration';
77

8-
describe('CommonVersionsConfiguration', () => {
8+
describe(CommonVersionsConfiguration.name, () => {
99
it('can load the file', () => {
1010
const filename: string = path.resolve(__dirname, 'jsonFiles', 'common-versions.json');
1111
const configuration: CommonVersionsConfiguration = CommonVersionsConfiguration.loadFromFile(filename);

apps/rush-lib/src/api/test/EnvironmentConfiguration.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as path from 'path';
55
import { EnvironmentConfiguration } from '../EnvironmentConfiguration';
66

7-
describe('EnvironmentConfiguration', () => {
7+
describe(EnvironmentConfiguration.name, () => {
88
let _oldEnv: typeof process.env;
99

1010
beforeEach(() => {
@@ -17,7 +17,7 @@ describe('EnvironmentConfiguration', () => {
1717
process.env = _oldEnv;
1818
});
1919

20-
describe('validate', () => {
20+
describe(EnvironmentConfiguration.validate.name, () => {
2121
it('correctly allows no environment variables', () => {
2222
expect(EnvironmentConfiguration.validate).not.toThrow();
2323
});

apps/rush-lib/src/api/test/EventHooks.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55
import { RushConfiguration } from '../RushConfiguration';
66
import { Event, EventHooks } from '../EventHooks';
77

8-
describe('EventHooks', () => {
8+
describe(EventHooks.name, () => {
99
it('loads a post build hook from rush.json', () => {
1010
const rushFilename: string = path.resolve(__dirname, 'repo', 'rush-npm.json');
1111
const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushFilename);

apps/rush-lib/src/api/test/LastInstallFlag.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// See LICENSE in the project root for license information.
33

44
import * as path from 'path';
5+
import { FileSystem } from '@rushstack/node-core-library';
56

67
import { LastInstallFlag } from '../LastInstallFlag';
7-
import { FileSystem } from '@rushstack/node-core-library';
88

99
const TEMP_DIR: string = path.join(__dirname, 'temp');
1010

11-
describe('LastInstallFlag', () => {
11+
describe(LastInstallFlag.name, () => {
1212
beforeEach(() => {
1313
FileSystem.ensureEmptyFolder(TEMP_DIR);
1414
});

apps/rush-lib/src/api/test/RushConfiguration.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function assertPathProperty(validatedPropertyName: string, absolutePath: string,
1919
expect(normalizePathForComparison(absolutePath)).toEqual(normalizePathForComparison(resolvedRelativePath));
2020
}
2121

22-
describe('RushConfiguration', () => {
22+
describe(RushConfiguration.name, () => {
2323
let _oldEnv: typeof process.env;
2424

2525
beforeEach(() => {

apps/rush-lib/src/api/test/VersionMismatchFinder.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { VersionMismatchFinderProject } from '../../logic/versionMismatch/Versio
1212
import { VersionMismatchFinderCommonVersions } from '../../logic/versionMismatch/VersionMismatchFinderCommonVersions';
1313

1414
/* eslint-disable @typescript-eslint/no-explicit-any */
15-
describe('VersionMismatchFinder', () => {
15+
describe(VersionMismatchFinder.name, () => {
1616
it('finds no mismatches if there are none', () => {
1717
const projectA: VersionMismatchFinderEntity = new VersionMismatchFinderProject({
1818
packageName: 'A',

apps/rush-lib/src/api/test/VersionPolicy.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { IPackageJson } from '@rushstack/node-core-library';
77
import { VersionPolicyConfiguration } from '../VersionPolicyConfiguration';
88
import { VersionPolicy, LockStepVersionPolicy, IndividualVersionPolicy, BumpType } from '../VersionPolicy';
99

10-
describe('VersionPolicy', () => {
11-
describe('LockStepVersion', () => {
10+
describe(VersionPolicy.name, () => {
11+
describe(LockStepVersionPolicy.name, () => {
1212
const filename: string = path.resolve(__dirname, 'jsonFiles', 'rushWithLockVersion.json');
1313
const versionPolicyConfig: VersionPolicyConfiguration = new VersionPolicyConfiguration(filename);
1414
let versionPolicy1: VersionPolicy;
@@ -116,7 +116,7 @@ describe('VersionPolicy', () => {
116116
});
117117
});
118118

119-
describe('IndividualVersionPolicy', () => {
119+
describe(IndividualVersionPolicy.name, () => {
120120
const fileName: string = path.resolve(__dirname, 'jsonFiles', 'rushWithIndividualVersion.json');
121121
const versionPolicyConfig: VersionPolicyConfiguration = new VersionPolicyConfiguration(fileName);
122122
const versionPolicy: VersionPolicy = versionPolicyConfig.getVersionPolicy('testPolicy2');

apps/rush-lib/src/cli/actions/test/AddAction.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import * as path from 'path';
77

88
import { PackageJsonUpdater } from '../../../logic/PackageJsonUpdater';
99
import { RushCommandLineParser } from '../../RushCommandLineParser';
10+
import { AddAction } from '../AddAction';
1011

11-
describe('AddAction', () => {
12+
describe(AddAction.name, () => {
1213
describe(`basic "rush add" tests`, () => {
1314
let doRushAddMock: jest.SpyInstance;
1415
let oldExitCode: number | undefined;

apps/rush-lib/src/cli/test/RushCommandLineParser.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ function getCommandLineParserInstance(repoName: string, taskName: string): IPars
8282
const SPAWN_ARG_ARGS: number = 1;
8383
const SPAWN_ARG_OPTIONS: number = 2;
8484

85-
describe('RushCommandLineParser', () => {
86-
describe('execute', () => {
85+
describe(RushCommandLineParser.name, () => {
86+
describe(RushCommandLineParser.prototype.execute.name, () => {
8787
afterEach(() => {
8888
jest.clearAllMocks();
8989
});

apps/rush-lib/src/cli/test/RushXCommandLine.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { RushConfigurationProject } from '../../api/RushConfigurationProject';
1010

1111
import { RushXCommandLine } from '../RushXCommandLine';
1212

13-
describe('RushXCommandLine', () => {
13+
describe(RushXCommandLine.name, () => {
1414
let $argv: string[];
1515
let $versions: NodeJS.ProcessVersions;
1616
let executeLifecycleCommandMock: jest.SpyInstance | undefined;
@@ -81,7 +81,7 @@ describe('RushXCommandLine', () => {
8181
jest.restoreAllMocks();
8282
});
8383

84-
describe('launchRushX', () => {
84+
describe(RushXCommandLine.launchRushX.name, () => {
8585
it('prints usage info', () => {
8686
process.argv = ['node', 'startx.js', '--help'];
8787
executeLifecycleCommandMock!.mockReturnValue(0);

apps/rush-lib/src/logic/buildCache/test/ProjectBuildCache.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface ITestOptions {
1616
trackedProjectFiles: string[] | undefined;
1717
}
1818

19-
describe('ProjectBuildCache', () => {
19+
describe(ProjectBuildCache.name, () => {
2020
async function prepareSubject(options: Partial<ITestOptions>): Promise<ProjectBuildCache | undefined> {
2121
const terminal: Terminal = new Terminal(new StringBufferTerminalProvider());
2222
const projectChangeAnalyzer = {
@@ -53,7 +53,7 @@ describe('ProjectBuildCache', () => {
5353
return subject;
5454
}
5555

56-
describe('tryGetProjectBuildCache', () => {
56+
describe(ProjectBuildCache.tryGetProjectBuildCache.name, () => {
5757
it('returns a ProjectBuildCache with a calculated cacheId value', async () => {
5858
const subject: ProjectBuildCache = (await prepareSubject({}))!;
5959
expect(subject['_cacheId']).toMatchInlineSnapshot(

apps/rush-lib/src/logic/operations/test/AsyncOperationQueue.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function nullSort(a: Operation, b: Operation): number {
1414
return 0;
1515
}
1616

17-
describe('AsyncOperationQueue', () => {
17+
describe(AsyncOperationQueue.name, () => {
1818
it('iterates operations in topological order', async () => {
1919
const operations = [
2020
new Operation(new MockOperationRunner('a')!, OperationStatus.Ready),

apps/rush-lib/src/logic/operations/test/OperationSelector.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe(OperationSelector.name, () => {
5454
commandLineConfiguration = new CommandLineConfiguration(commandLineJson);
5555
});
5656

57-
describe('#createOperations', () => {
57+
describe(OperationSelector.prototype.createOperations.name, () => {
5858
it('handles a full build', () => {
5959
const buildCommand: IPhasedCommand = commandLineConfiguration.commands.get('build')! as IPhasedCommand;
6060

apps/rush-lib/src/logic/operations/test/ShellOperationRunner.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { convertSlashesForWindows } from '../ShellOperationRunner';
55

6-
describe('convertSlashesForWindows()', () => {
6+
describe(convertSlashesForWindows.name, () => {
77
it('converted inputs', () => {
88
expect(convertSlashesForWindows('./node_modules/.bin/tslint -c config/tslint.json')).toEqual(
99
'.\\node_modules\\.bin\\tslint -c config/tslint.json'

apps/rush-lib/src/logic/operations/test/__snapshots__/OperationSelector.test.ts.snap

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`OperationSelector #createOperations handles a full build 1`] = `
3+
exports[`OperationSelector createOperations handles a full build 1`] = `
44
Array [
55
Object {
66
"dependencies": Array [],
@@ -619,7 +619,7 @@ Array [
619619
]
620620
`;
621621

622-
exports[`OperationSelector #createOperations handles filtered phases 1`] = `
622+
exports[`OperationSelector createOperations handles filtered phases 1`] = `
623623
Array [
624624
Object {
625625
"dependencies": Array [],
@@ -689,7 +689,7 @@ Array [
689689
]
690690
`;
691691

692-
exports[`OperationSelector #createOperations handles filtered phases 2`] = `
692+
exports[`OperationSelector createOperations handles filtered phases 2`] = `
693693
Array [
694694
Object {
695695
"dependencies": Array [
@@ -941,7 +941,7 @@ Array [
941941
]
942942
`;
943943

944-
exports[`OperationSelector #createOperations handles filtered phases on filtered projects 1`] = `
944+
exports[`OperationSelector createOperations handles filtered phases on filtered projects 1`] = `
945945
Array [
946946
Object {
947947
"dependencies": Array [],
@@ -961,7 +961,7 @@ Array [
961961
]
962962
`;
963963

964-
exports[`OperationSelector #createOperations handles filtered phases on filtered projects 2`] = `
964+
exports[`OperationSelector createOperations handles filtered phases on filtered projects 2`] = `
965965
Array [
966966
Object {
967967
"dependencies": Array [
@@ -1040,7 +1040,7 @@ Array [
10401040
]
10411041
`;
10421042

1043-
exports[`OperationSelector #createOperations handles filtered projects 1`] = `
1043+
exports[`OperationSelector createOperations handles filtered projects 1`] = `
10441044
Array [
10451045
Object {
10461046
"dependencies": Array [],
@@ -1098,7 +1098,7 @@ Array [
10981098
]
10991099
`;
11001100

1101-
exports[`OperationSelector #createOperations handles filtered projects 2`] = `
1101+
exports[`OperationSelector createOperations handles filtered projects 2`] = `
11021102
Array [
11031103
Object {
11041104
"dependencies": Array [],

apps/rush-lib/src/logic/test/ChangeFiles.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { IChangelog } from '../../api/Changelog';
88
import { ChangeFiles } from '../ChangeFiles';
99
import { RushConfiguration } from '../../api/RushConfiguration';
1010

11-
describe('ChangeFiles', () => {
11+
describe(ChangeFiles.name, () => {
1212
let rushConfiguration: RushConfiguration;
1313

1414
beforeEach(() => {
1515
rushConfiguration = {} as RushConfiguration;
1616
});
1717

18-
describe('getFiles', () => {
18+
describe(ChangeFiles.prototype.getFiles.name, () => {
1919
it('returns correctly when there is one change file', () => {
2020
const changesPath: string = path.join(__dirname, 'leafChange');
2121
const changeFiles: ChangeFiles = new ChangeFiles(changesPath);
@@ -44,7 +44,7 @@ describe('ChangeFiles', () => {
4444
});
4545
});
4646

47-
describe('validate', () => {
47+
describe(ChangeFiles.validate.name, () => {
4848
it('throws when there is a patch in a hotfix branch.', () => {
4949
const changeFile: string = path.join(__dirname, 'leafChange', 'change1.json');
5050
const changedPackages: string[] = ['d'];
@@ -97,7 +97,7 @@ describe('ChangeFiles', () => {
9797
});
9898
});
9999

100-
describe('deleteAll', () => {
100+
describe(ChangeFiles.prototype.deleteAll.name, () => {
101101
it('delete all files when there are no prerelease packages', () => {
102102
const changesPath: string = path.join(__dirname, 'multipleChangeFiles');
103103
const changeFiles: ChangeFiles = new ChangeFiles(changesPath);

apps/rush-lib/src/logic/test/ChangeManager.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { RushConfiguration } from '../../api/RushConfiguration';
77
import { ChangeManager } from '../ChangeManager';
88
import { PrereleaseToken } from '../PrereleaseToken';
99

10-
describe('ChangeManager', () => {
10+
describe(ChangeManager.name, () => {
1111
const rushJsonFile: string = path.resolve(__dirname, 'packages', 'rush.json');
1212
let rushConfiguration: RushConfiguration;
1313
let changeManager: ChangeManager;
@@ -179,7 +179,7 @@ describe('ChangeManager', () => {
179179
/* eslint-enable dot-notation */
180180
});
181181

182-
describe('WorkspaceChangeManager', () => {
182+
describe(`${ChangeManager.name} (workspace)`, () => {
183183
const rushJsonFile: string = path.resolve(__dirname, 'workspacePackages', 'rush.json');
184184
let rushConfiguration: RushConfiguration;
185185
let changeManager: ChangeManager;

apps/rush-lib/src/logic/test/ChangelogGenerator.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ChangelogGenerator } from '../ChangelogGenerator';
1010
import * as path from 'path';
1111
import { IChangeRequests } from '../PublishUtilities';
1212

13-
describe('updateIndividualChangelog', () => {
13+
describe(ChangelogGenerator.updateIndividualChangelog.name, () => {
1414
const rushJsonFile: string = path.resolve(__dirname, 'packages', 'rush.json');
1515
let rushConfiguration: RushConfiguration;
1616

@@ -254,7 +254,7 @@ describe('updateIndividualChangelog', () => {
254254
});
255255
});
256256

257-
describe('updateChangelogs', () => {
257+
describe(ChangelogGenerator.updateChangelogs.name, () => {
258258
const rushJsonFile: string = path.resolve(__dirname, 'packages', 'rush.json');
259259
let rushConfiguration: RushConfiguration;
260260

apps/rush-lib/src/logic/test/Git.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import { Git } from '../Git';
55

6-
describe('Git', () => {
7-
describe('normalizeGitUrlToHttps', () => {
6+
describe(Git.name, () => {
7+
describe(Git.normalizeGitUrlForComparison.name, () => {
88
it('correctly normalizes URLs', () => {
99
expect(Git.normalizeGitUrlForComparison('invalid.git')).toEqual('invalid');
1010
expect(Git.normalizeGitUrlForComparison('[email protected]:ExampleOrg/ExampleProject.git')).toEqual(

apps/rush-lib/src/logic/test/LookupByPath.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { LookupByPath } from '../LookupByPath';
55

6-
describe('iteratePathSegments', () => {
6+
describe(LookupByPath.iteratePathSegments.name, () => {
77
it('returns empty for an empty string', () => {
88
const result = [...LookupByPath.iteratePathSegments('')];
99
expect(result.length).toEqual(0);
@@ -22,7 +22,7 @@ describe('iteratePathSegments', () => {
2222
});
2323
});
2424

25-
describe('findChildPath', () => {
25+
describe(LookupByPath.prototype.findChildPath.name, () => {
2626
it('returns empty for an empty tree', () => {
2727
expect(new LookupByPath().findChildPath('foo')).toEqual(undefined);
2828
});

apps/rush-lib/src/logic/test/PublishUtilities.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function generateVersionPolicySnapshot(allChanges: IChangeRequests): string {
5757
return lines.join('\n');
5858
}
5959

60-
describe('findChangeRequests', () => {
60+
describe(PublishUtilities.findChangeRequests.name, () => {
6161
let packagesRushConfiguration: RushConfiguration;
6262
let repoRushConfiguration: RushConfiguration;
6363

@@ -461,7 +461,7 @@ describe('findChangeRequests', () => {
461461
});
462462
});
463463

464-
describe('sortChangeRequests', () => {
464+
describe(PublishUtilities.sortChangeRequests.name, () => {
465465
let rushConfiguration: RushConfiguration;
466466

467467
beforeEach(() => {
@@ -492,7 +492,7 @@ describe('sortChangeRequests', () => {
492492
});
493493
});
494494

495-
describe('isRangeDependency', () => {
495+
describe(PublishUtilities.isRangeDependency.name, () => {
496496
it('can test ranges', () => {
497497
expect(PublishUtilities.isRangeDependency('>=1.0.0 <2.0.0')).toEqual(true);
498498
expect(PublishUtilities.isRangeDependency('>=1.0.0-pr.1 <2.0.0')).toEqual(true);
@@ -502,7 +502,7 @@ describe('isRangeDependency', () => {
502502
});
503503
});
504504

505-
describe('getNewDependencyVersion', () => {
505+
describe(PublishUtilities.getNewDependencyVersion.name, () => {
506506
it('can update dependency versions', () => {
507507
const dependencies: { [key: string]: string } = {
508508
a: '~1.0.0',
@@ -545,7 +545,7 @@ describe('getNewDependencyVersion', () => {
545545
});
546546
});
547547

548-
describe('findWorkspaceChangeRequests', () => {
548+
describe(PublishUtilities.findChangeRequests.name, () => {
549549
let packagesRushConfiguration: RushConfiguration;
550550
let repoRushConfiguration: RushConfiguration;
551551

@@ -888,7 +888,7 @@ describe('findWorkspaceChangeRequests', () => {
888888
});
889889
});
890890

891-
describe('getNewWorkspaceDependencyVersion', () => {
891+
describe(PublishUtilities.getNewDependencyVersion.name, () => {
892892
it('can update dependency versions', () => {
893893
const dependencies: { [key: string]: string } = {
894894
a: 'workspace:~1.0.0',

0 commit comments

Comments
 (0)