Skip to content

Commit 56278ee

Browse files
committed
Improve refactorability of other projects' tests.
1 parent 379a48c commit 56278ee

File tree

53 files changed

+226
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+226
-186
lines changed

apps/api-extractor/src/analyzer/test/PackageMetadataManager.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ function firstArgument(mockFn: jest.Mock): any {
3030

3131
/* eslint-disable @typescript-eslint/typedef */
3232

33-
describe('PackageMetadataManager', () => {
34-
describe('.writeTsdocMetadataFile()', () => {
33+
describe(PackageMetadataManager.name, () => {
34+
describe(PackageMetadataManager.writeTsdocMetadataFile.name, () => {
3535
const originalWriteFile = FileSystem.writeFile;
3636
const mockWriteFile: jest.Mock = jest.fn();
3737
beforeAll(() => {
@@ -50,7 +50,7 @@ describe('PackageMetadataManager', () => {
5050
});
5151
});
5252

53-
describe('.resolveTsdocMetadataPath()', () => {
53+
describe(PackageMetadataManager.resolveTsdocMetadataPath.name, () => {
5454
describe('when an empty tsdocMetadataPath is provided', () => {
5555
const tsdocMetadataPath: string = '';
5656
describe('given a package.json where the field "tsdocMetadata" is defined', () => {

apps/api-extractor/src/analyzer/test/SyntaxHelpers.test.ts

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

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

6-
describe('SyntaxHelpers', () => {
7-
test('.toAlphaNumericCamelCase()', () => {
6+
describe(SyntaxHelpers.name, () => {
7+
it(SyntaxHelpers.makeCamelCaseIdentifier.name, () => {
88
// prettier-ignore
99
const inputs:string[] = [
1010
'',

apps/api-extractor/src/api/test/ExtractorConfig-lookup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function expectEqualPaths(path1: string, path2: string): void {
1515
}
1616

1717
// Tests for expanding the "<lookup>" token for the "projectFolder" setting in api-extractor.json
18-
describe('ExtractorConfig-lookup', () => {
18+
describe(`${ExtractorConfig.name}.${ExtractorConfig.loadFileAndPrepare.name}`, () => {
1919
it.only('config-lookup1: looks up ./api-extractor.json', () => {
2020
const extractorConfig: ExtractorConfig = ExtractorConfig.loadFileAndPrepare(
2121
path.join(testDataFolder, 'config-lookup1/api-extractor.json')

apps/heft/src/pluginFramework/logging/test/FileError.test.ts

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

44
import { FileError, FileErrorFormat } from '../FileError';
55

6-
describe('FileError', () => {
6+
describe(FileError.name, () => {
77
it('normalizes slashes in file paths', () => {
88
const error1: FileError = new FileError('message', 'path\\to\\file', 0);
99
expect(error1.filePath).toEqual('path/to/file');

apps/heft/src/utilities/subprocess/test/SubprocessRunnerBase.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { SubprocessRunnerBase } from '../SubprocessRunnerBase';
55
import { FileError } from '../../../pluginFramework/logging/FileError';
66

7-
describe('SubprocessRunnerBase', () => {
7+
describe(SubprocessRunnerBase.name, () => {
88
it(`${SubprocessRunnerBase.serializeForIpcMessage.name} correctly serializes objects`, () => {
99
expect(SubprocessRunnerBase.serializeForIpcMessage(1)).toMatchSnapshot();
1010
expect(SubprocessRunnerBase.serializeForIpcMessage(false)).toMatchSnapshot();

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { RushCommandLineParser } from '../../RushCommandLineParser';
88
import { AddAction } from '../AddAction';
99

1010
describe(AddAction.name, () => {
11-
describe(`basic "rush add" tests`, () => {
11+
describe('basic "rush add" tests', () => {
1212
let doRushAddMock: jest.SpyInstance;
1313
let oldExitCode: number | undefined;
1414
let oldArgs: string[];
@@ -28,7 +28,7 @@ describe(AddAction.name, () => {
2828
process.argv = oldArgs;
2929
});
3030

31-
describe(`'add' action`, () => {
31+
describe("'add' action", () => {
3232
it(`adds a dependency to just one repo in the workspace`, async () => {
3333
const startPath: string = `${__dirname}/addRepo`;
3434
const aPath: string = `${__dirname}/addRepo/a`;
@@ -53,7 +53,7 @@ describe(AddAction.name, () => {
5353
});
5454
});
5555

56-
describe(`'add' action with --all`, () => {
56+
describe("'add' action with --all", () => {
5757
it(`adds a dependency to all repos in the workspace`, async () => {
5858
const startPath: string = `${__dirname}/addRepo`;
5959
const aPath: string = `${__dirname}/addRepo/a`;

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe(RushCommandLineParser.name, () => {
9292
});
9393

9494
describe('in basic repo', () => {
95-
describe(`'build' action`, () => {
95+
describe("'build' action", () => {
9696
it(`executes the package's 'build' script`, async () => {
9797
const repoName: string = 'basicAndRunBuildActionRepo';
9898
const instance: IParserTestInstance = getCommandLineParserInstance(repoName, 'build');
@@ -124,7 +124,7 @@ describe(RushCommandLineParser.name, () => {
124124
});
125125
});
126126

127-
describe(`'rebuild' action`, () => {
127+
describe("'rebuild' action", () => {
128128
it(`executes the package's 'build' script`, async () => {
129129
const repoName: string = 'basicAndRunRebuildActionRepo';
130130
const instance: IParserTestInstance = getCommandLineParserInstance(repoName, 'rebuild');
@@ -157,8 +157,8 @@ describe(RushCommandLineParser.name, () => {
157157
});
158158
});
159159

160-
describe(`in repo with 'rebuild' command overridden`, () => {
161-
describe(`'build' action`, () => {
160+
describe("in repo with 'rebuild' command overridden", () => {
161+
describe("'build' action", () => {
162162
it(`executes the package's 'build' script`, async () => {
163163
const repoName: string = 'overrideRebuildAndRunBuildActionRepo';
164164
const instance: IParserTestInstance = getCommandLineParserInstance(repoName, 'build');
@@ -190,7 +190,7 @@ describe(RushCommandLineParser.name, () => {
190190
});
191191
});
192192

193-
describe(`'rebuild' action`, () => {
193+
describe("'rebuild' action", () => {
194194
it(`executes the package's 'rebuild' script`, async () => {
195195
const repoName: string = 'overrideRebuildAndRunRebuildActionRepo';
196196
const instance: IParserTestInstance = getCommandLineParserInstance(repoName, 'rebuild');
@@ -223,8 +223,8 @@ describe(RushCommandLineParser.name, () => {
223223
});
224224
});
225225

226-
describe(`in repo with 'rebuild' or 'build' partially set`, () => {
227-
describe(`'build' action`, () => {
226+
describe("in repo with 'rebuild' or 'build' partially set", () => {
227+
describe("'build' action", () => {
228228
it(`executes the package's 'build' script`, async () => {
229229
const repoName: string = 'overrideAndDefaultBuildActionRepo';
230230
const instance: IParserTestInstance = getCommandLineParserInstance(repoName, 'build');
@@ -255,7 +255,7 @@ describe(RushCommandLineParser.name, () => {
255255
});
256256
});
257257

258-
describe(`'rebuild' action`, () => {
258+
describe("'rebuild' action", () => {
259259
it(`executes the package's 'build' script`, async () => {
260260
// broken
261261
const repoName: string = 'overrideAndDefaultRebuildActionRepo';
@@ -288,7 +288,7 @@ describe(RushCommandLineParser.name, () => {
288288
});
289289
});
290290

291-
describe(`in repo with 'build' command overridden as a global command`, () => {
291+
describe("in repo with 'build' command overridden as a global command", () => {
292292
it(`throws an error when starting Rush`, async () => {
293293
const repoName: string = 'overrideBuildAsGlobalCommandRepo';
294294

@@ -300,7 +300,7 @@ describe(RushCommandLineParser.name, () => {
300300
});
301301
});
302302

303-
describe(`in repo with 'rebuild' command overridden as a global command`, () => {
303+
describe("in repo with 'rebuild' command overridden as a global command", () => {
304304
it(`throws an error when starting Rush`, async () => {
305305
const repoName: string = 'overrideRebuildAsGlobalCommandRepo';
306306

@@ -312,7 +312,7 @@ describe(RushCommandLineParser.name, () => {
312312
});
313313
});
314314

315-
describe(`in repo with 'build' command overridden with 'safeForSimultaneousRushProcesses=true'`, () => {
315+
describe("in repo with 'build' command overridden with 'safeForSimultaneousRushProcesses=true'", () => {
316316
it(`throws an error when starting Rush`, async () => {
317317
const repoName: string = 'overrideBuildWithSimultaneousProcessesRepo';
318318

@@ -324,7 +324,7 @@ describe(RushCommandLineParser.name, () => {
324324
});
325325
});
326326

327-
describe(`in repo with 'rebuild' command overridden with 'safeForSimultaneousRushProcesses=true'`, () => {
327+
describe("in repo with 'rebuild' command overridden with 'safeForSimultaneousRushProcesses=true'", () => {
328328
it(`throws an error when starting Rush`, async () => {
329329
const repoName: string = 'overrideRebuildWithSimultaneousProcessesRepo';
330330

apps/rush/src/test/MinimalRushConfiguration.test.ts

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

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

8-
describe('MinimalRushConfiguration', () => {
8+
describe(MinimalRushConfiguration.name, () => {
99
afterEach(() => {
1010
jest.restoreAllMocks();
1111
});

build-tests/heft-jest-reporters-test/src/test/index.test.ts

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

44
import { addThreeStars } from '..';
55

6-
describe('addThreeStars', () => {
6+
describe(addThreeStars.name, () => {
77
it('adds three stars', () => {
88
expect(addThreeStars('***Hello World')).toEqual('***Hello World***');
99
});

eslint/eslint-plugin-packlets/src/test/Path.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function relativeCaseInsensitive(from: string, to: string) {
1515
return toPosixPath(Path['_relativeCaseInsensitive'](toNativePath(from), toNativePath(to)));
1616
}
1717

18-
describe('Path', () => {
18+
describe(Path.name, () => {
1919
test('_detectCaseSensitive()', () => {
2020
// NOTE: To ensure these tests are deterministic, only use absolute paths
2121
expect(relativeCaseInsensitive('/', '/')).toEqual('');

libraries/heft-config-file/src/test/ConfigurationFile.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from '@rushstack/node-core-library';
1515
import { RigConfig } from '@rushstack/rig-package';
1616

17-
describe('ConfigurationFile', () => {
17+
describe(ConfigurationFile.name, () => {
1818
const projectRoot: string = nodeJsPath.resolve(__dirname, '..', '..');
1919
let terminalProvider: StringBufferTerminalProvider;
2020
let terminal: Terminal;

libraries/node-core-library/src/Terminal/test/AnsiEscape.test.ts

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

7-
describe('AnsiEscape', () => {
7+
describe(AnsiEscape.name, () => {
88
let initialColorsEnabled: boolean;
99

1010
beforeAll(() => {

libraries/node-core-library/src/Terminal/test/Colors.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { Terminal } from '../Terminal';
55
import { StringBufferTerminalProvider } from '../StringBufferTerminalProvider';
66
import { createColorGrid } from './createColorGrid';
77
import { AnsiEscape } from '../AnsiEscape';
8+
import { Colors } from '../Colors';
89

9-
describe('Colors', () => {
10+
describe(Colors.name, () => {
1011
let terminal: Terminal;
1112
let provider: StringBufferTerminalProvider;
1213

libraries/node-core-library/src/test/Async.test.ts

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

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

6-
describe('Async', () => {
7-
describe('mapAsync', () => {
6+
describe(Async.name, () => {
7+
describe(Async.mapAsync.name, () => {
88
it('handles an empty array correctly', async () => {
99
const result = await Async.mapAsync([] as number[], async (item) => `result ${item}`);
1010
expect(result).toEqual([]);
@@ -128,7 +128,7 @@ describe('Async', () => {
128128
});
129129
});
130130

131-
describe('forEachAsync', () => {
131+
describe(Async.forEachAsync.name, () => {
132132
it('handles an empty array correctly', async () => {
133133
let running: number = 0;
134134
let maxRunning: number = 0;

libraries/node-core-library/src/test/Enum.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum MixedEnum {
2222
Banana = 'banana'
2323
}
2424

25-
describe('Enum', () => {
25+
describe(Enum.name, () => {
2626
test('tryGetValueByKey', () => {
2727
// NumericEnum
2828
const numeric1: NumericEnum | undefined = Enum.tryGetValueByKey(NumericEnum, 'Apple');

libraries/node-core-library/src/test/EnvironmentMap.test.ts

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

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

8-
describe('EnvironmentMap', () => {
8+
describe(EnvironmentMap.name, () => {
99
test('_sanityCheck() throws', () => {
1010
const map = new EnvironmentMap();
1111
const environmentObject = { A: '123' };

libraries/node-core-library/src/test/Import.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { Import } from '../Import';
66
import { PackageJsonLookup } from '../PackageJsonLookup';
77
import { Path } from '../Path';
88

9-
describe('Import', () => {
9+
describe(Import.name, () => {
1010
const packageRoot: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!;
1111

12-
describe('resolveModule', () => {
12+
describe(Import.resolveModule.name, () => {
1313
it('returns an absolute path as-is', () => {
1414
const absolutePaths: string[] = ['/var/test/path'];
1515

@@ -135,7 +135,7 @@ describe('Import', () => {
135135
});
136136
});
137137

138-
describe('resolvePackage', () => {
138+
describe(Import.resolvePackage.name, () => {
139139
it('resolves a dependency', () => {
140140
expect(
141141
Import.resolvePackage({ packageName: '@rushstack/heft', baseFolderPath: __dirname }).replace(

libraries/node-core-library/src/test/JsonFile.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { JsonFile } from '../JsonFile';
66
// The PosixModeBits are intended to be used with bitwise operations.
77
/* eslint-disable no-bitwise */
88

9-
describe('JsonFile tests', () => {
9+
describe(JsonFile.name, () => {
1010
it('adds a header comment', () => {
1111
expect(
1212
JsonFile.stringify(

libraries/node-core-library/src/test/JsonSchema.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { JsonFile, JsonObject } from '../JsonFile';
55
import { JsonSchema, IJsonSchemaErrorInfo } from '../JsonSchema';
66

7-
describe('JsonSchema', () => {
7+
describe(JsonSchema.name, () => {
88
const schemaPath: string = `${__dirname}/test-data/test-schema.json`;
99
const schema: JsonSchema = JsonSchema.fromFile(schemaPath);
1010

libraries/node-core-library/src/test/LockFile.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ function setLockFileGetProcessStartTime(fn: (process: number) => string | undefi
1111
(LockFile as any)._getStartTime = fn;
1212
}
1313

14-
describe('LockFile', () => {
14+
describe(LockFile.name, () => {
1515
afterEach(() => {
1616
setLockFileGetProcessStartTime(getProcessStartTime);
1717
});
1818

19-
describe('getLockFilePath', () => {
19+
describe(LockFile.getLockFilePath.name, () => {
2020
test('only accepts alphabetical characters for resource name', () => {
2121
expect(() => {
2222
LockFile.getLockFilePath(process.cwd(), 'foo123');
@@ -49,7 +49,7 @@ describe('LockFile', () => {
4949
});
5050
});
5151

52-
describe('getProcessStartTimeFromProcStat', () => {
52+
describe(getProcessStartTimeFromProcStat.name, () => {
5353
function createStatOutput(value2: string, n: number): string {
5454
let statOutput: string = `0 ${value2} S`;
5555
for (let i: number = 0; i < n; i++) {
@@ -97,7 +97,7 @@ describe('LockFile', () => {
9797

9898
if (process.platform === 'darwin' || process.platform === 'linux') {
9999
describe('Linux and Mac', () => {
100-
describe('getLockFilePath()', () => {
100+
describe(LockFile.getLockFilePath.name, () => {
101101
test('returns a resolved path containing the pid', () => {
102102
expect(path.join(process.cwd(), `test#${process.pid}.lock`)).toEqual(
103103
LockFile.getLockFilePath('./', 'test')
@@ -171,7 +171,7 @@ describe('LockFile', () => {
171171
}
172172

173173
if (process.platform === 'win32') {
174-
describe('getLockFilePath()', () => {
174+
describe(LockFile.getLockFilePath.name, () => {
175175
test("returns a resolved path that doesn't contain", () => {
176176
expect(path.join(process.cwd(), `test.lock`)).toEqual(LockFile.getLockFilePath('./', 'test'));
177177
});

libraries/node-core-library/src/test/PackageJsonLookup.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { PackageJsonLookup } from '../PackageJsonLookup';
66
import { IPackageJson, INodePackageJson } from '../IPackageJson';
77
import { FileConstants } from '../Constants';
88

9-
describe('PackageJsonLookup', () => {
9+
describe(PackageJsonLookup.name, () => {
1010
describe('basic tests', () => {
11-
test('', () => {
11+
test(PackageJsonLookup.loadOwnPackageJson.name, () => {
1212
expect(PackageJsonLookup.loadOwnPackageJson(__dirname).name).toEqual('@rushstack/node-core-library');
1313
});
1414

15-
test('tryLoadPackageJsonFor() test', () => {
15+
test(PackageJsonLookup.prototype.tryLoadPackageJsonFor.name, () => {
1616
const packageJsonLookup: PackageJsonLookup = new PackageJsonLookup();
1717
const sourceFilePath: string = path.join(__dirname, './test-data/example-package');
1818
const packageJson: IPackageJson | undefined = packageJsonLookup.tryLoadPackageJsonFor(sourceFilePath);
@@ -26,7 +26,7 @@ describe('PackageJsonLookup', () => {
2626
}
2727
});
2828

29-
test('tryLoadNodePackageJsonFor() test package with no version', () => {
29+
test(`${PackageJsonLookup.prototype.tryLoadNodePackageJsonFor.name} test package with no version`, () => {
3030
const packageJsonLookup: PackageJsonLookup = new PackageJsonLookup();
3131
const sourceFilePath: string = path.join(__dirname, './test-data/example-package-no-version');
3232
const packageJson: INodePackageJson | undefined =
@@ -41,7 +41,7 @@ describe('PackageJsonLookup', () => {
4141
}
4242
});
4343

44-
test('tryGetPackageFolderFor() test', () => {
44+
test(PackageJsonLookup.prototype.tryGetPackageFolderFor.name, () => {
4545
const packageJsonLookup: PackageJsonLookup = new PackageJsonLookup();
4646
const sourceFilePath: string = path.join(__dirname, './test-data/example-package/src/ExampleFile.txt');
4747

0 commit comments

Comments
 (0)