Skip to content

Commit de641a6

Browse files
huntiefacebook-github-bot
authored andcommitted
Enforce consistent-test-it lint rule
Summary: Enable [jest/consistent-test-it](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/consistent-test-it.md) rule and align codebase using `eslint --fix`. Motivation: - `test` is the [canonically documented](https://jestjs.io/docs/api#testname-fn-timeout) function name in Jest. - Marginally more self-describing. Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D63384640 fbshipit-source-id: 1b86c275954fe851ca8d6c2197d0a4f47baf5d1e
1 parent d565b54 commit de641a6

File tree

86 files changed

+1144
-1140
lines changed

Some content is hidden

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

86 files changed

+1144
-1140
lines changed

packages/buck-worker-tool/src/__tests__/worker-test.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ describe('Buck worker:', () => {
5151
});
5252

5353
describe('handshake:', () => {
54-
it('responds to a correct handshake', () => {
54+
test('responds to a correct handshake', () => {
5555
inStream.write(handshake());
5656

5757
return end().then(data => expect(data).toEqual([handshake()]));
5858
});
5959

60-
it('responds to a handshake with a `protocol_version` different from "0"', () => {
60+
test('responds to a handshake with a `protocol_version` different from "0"', () => {
6161
inStream.write({
6262
id: 0,
6363
type: 'handshake',
@@ -76,7 +76,7 @@ describe('Buck worker:', () => {
7676
);
7777
});
7878

79-
it('errors for a second handshake', () => {
79+
test('errors for a second handshake', () => {
8080
inStream.write(handshake());
8181
inStream.write(handshake(1));
8282

@@ -90,7 +90,7 @@ describe('Buck worker:', () => {
9090
});
9191
});
9292

93-
it('errors for unknown message types', () => {
93+
test('errors for unknown message types', () => {
9494
inStream.write(handshake());
9595
inStream.write({id: 1, type: 'arbitrary'});
9696
return end().then(([, response]) =>
@@ -165,7 +165,7 @@ describe('Buck worker:', () => {
165165
return Promise.all(streamClosedPromises);
166166
});
167167

168-
it('errors if `args_path` cannot be opened', () => {
168+
test('errors if `args_path` cannot be opened', () => {
169169
mockFiles({some: {'args-path': undefined}});
170170
inStream.write(command({id: 5, args_path: '/some/args-path'}));
171171
return end(2).then(([, response]) => {
@@ -177,7 +177,7 @@ describe('Buck worker:', () => {
177177
});
178178
});
179179

180-
it('errors if `stdout_path` cannot be opened', () => {
180+
test('errors if `stdout_path` cannot be opened', () => {
181181
const path = '/does/not/exist';
182182
inStream.write(command({id: 5, stdout_path: path}));
183183
return end(2).then(([, response]) => {
@@ -189,7 +189,7 @@ describe('Buck worker:', () => {
189189
});
190190
});
191191

192-
it('errors if `stderr_path` cannot be opened', () => {
192+
test('errors if `stderr_path` cannot be opened', () => {
193193
const path = '/does/not/exist';
194194
inStream.write(command({id: 5, stderr_path: path}));
195195
return end(2).then(([, response]) => {
@@ -201,7 +201,7 @@ describe('Buck worker:', () => {
201201
});
202202
});
203203

204-
it('errors for unspecified commands', () => {
204+
test('errors for unspecified commands', () => {
205205
mockFiles({
206206
arbitrary: {
207207
file: '--flag-without-preceding-command',
@@ -223,7 +223,7 @@ describe('Buck worker:', () => {
223223
);
224224
});
225225

226-
it('errors for empty commands', () => {
226+
test('errors for empty commands', () => {
227227
mockFiles({
228228
arbitrary: {
229229
file: '',
@@ -245,7 +245,7 @@ describe('Buck worker:', () => {
245245
);
246246
});
247247

248-
it('errors for unknown commands', () => {
248+
test('errors for unknown commands', () => {
249249
mockFiles({
250250
arbitrary: {
251251
file: 'arbitrary',
@@ -267,7 +267,7 @@ describe('Buck worker:', () => {
267267
);
268268
});
269269

270-
it('errors if no `args_path` is specified', () => {
270+
test('errors if no `args_path` is specified', () => {
271271
inStream.write({
272272
id: 1,
273273
type: 'command',
@@ -283,7 +283,7 @@ describe('Buck worker:', () => {
283283
);
284284
});
285285

286-
it('errors if no `stdout_path` is specified', () => {
286+
test('errors if no `stdout_path` is specified', () => {
287287
inStream.write({
288288
id: 1,
289289
type: 'command',
@@ -299,7 +299,7 @@ describe('Buck worker:', () => {
299299
);
300300
});
301301

302-
it('errors if no `stderr_path` is specified', () => {
302+
test('errors if no `stderr_path` is specified', () => {
303303
inStream.write({
304304
id: 1,
305305
type: 'command',
@@ -315,7 +315,7 @@ describe('Buck worker:', () => {
315315
);
316316
});
317317

318-
it('passes arguments to an existing command', async () => {
318+
test('passes arguments to an existing command', async () => {
319319
commands.transform = jest.fn();
320320
const args = 'foo bar baz\tmore';
321321
mockFiles({
@@ -338,7 +338,7 @@ describe('Buck worker:', () => {
338338
);
339339
});
340340

341-
it('passes JSON/structured arguments to an existing command', async () => {
341+
test('passes JSON/structured arguments to an existing command', async () => {
342342
commands.transform = jest.fn();
343343
const args = {foo: 'bar', baz: 'glo'};
344344
mockFiles({
@@ -357,7 +357,7 @@ describe('Buck worker:', () => {
357357
expect(commands.transform).toBeCalledWith([], args, anything());
358358
});
359359

360-
it('passes a console object to the command', () => {
360+
test('passes a console object to the command', () => {
361361
mockFiles({
362362
args: 'transform',
363363
stdio: {},
@@ -385,7 +385,7 @@ describe('Buck worker:', () => {
385385
});
386386
});
387387

388-
it('responds with success if the command finishes succesfully', () => {
388+
test('responds with success if the command finishes succesfully', () => {
389389
commands.transform = (args, _) => {};
390390
mockFiles({path: {to: {args: 'transform'}}});
391391
inStream.write(
@@ -404,7 +404,7 @@ describe('Buck worker:', () => {
404404
);
405405
});
406406

407-
it('responds with error if the command does not exist', async () => {
407+
test('responds with error if the command does not exist', async () => {
408408
commands.transform = jest.fn(() => Promise.resolve());
409409
mockFiles({path: {to: {args: 'inexistent_command'}}});
410410
inStream.write(
@@ -425,7 +425,7 @@ describe('Buck worker:', () => {
425425
);
426426
});
427427

428-
it('responds with error if the command errors asynchronously', () => {
428+
test('responds with error if the command errors asynchronously', () => {
429429
commands.transform = jest.fn((args, _, callback) =>
430430
Promise.reject(new Error('arbitrary')),
431431
);
@@ -446,7 +446,7 @@ describe('Buck worker:', () => {
446446
);
447447
});
448448

449-
it('responds with error if the command throws synchronously', () => {
449+
test('responds with error if the command throws synchronously', () => {
450450
commands.transform = (args, _) => {
451451
throw new Error('arbitrary');
452452
};

packages/metro-babel-register/src/__tests__/parses-without-transpilation-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
const {promises: fsPromises} = require('fs');
1515
const vm = require('vm');
1616

17-
it('can be loaded directly without transpilation', async () => {
17+
test('can be loaded directly without transpilation', async () => {
1818
const code = await fsPromises.readFile(
1919
require.resolve('../babel-register'),
2020
'utf8',

packages/metro-babel-transformer/src/__tests__/transform-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const path = require('path');
1515

1616
const PROJECT_ROOT = path.sep === '/' ? '/my/project' : 'C:\\my\\project';
1717

18-
it('exposes the correct absolute path to a source file to plugins', () => {
18+
test('exposes the correct absolute path to a source file to plugins', () => {
1919
let visitorFilename;
2020
let pluginCwd;
2121
transform({

packages/metro-cache/src/__tests__/Cache-test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('Cache', () => {
4747
jest.resetModules().restoreAllMocks();
4848
});
4949

50-
it('returns null when no result is found', async () => {
50+
test('returns null when no result is found', async () => {
5151
const store1 = createStore();
5252
const store2 = createStore();
5353
const cache = new Cache([store1, store2]);
@@ -60,7 +60,7 @@ describe('Cache', () => {
6060
expect(store2.get).toHaveBeenCalledTimes(1);
6161
});
6262

63-
it('sequentially searches up until it finds a valid result', async () => {
63+
test('sequentially searches up until it finds a valid result', async () => {
6464
const store1 = createStore();
6565
const store2 = createStore();
6666
const store3 = createStore();
@@ -77,7 +77,7 @@ describe('Cache', () => {
7777
expect(store3.get).not.toHaveBeenCalled();
7878
});
7979

80-
it('skips all cache stores when a hit is produced, based on the same key', async () => {
80+
test('skips all cache stores when a hit is produced, based on the same key', async () => {
8181
const store1 = createStore();
8282
const store2 = createStore();
8383
const store3 = createStore();
@@ -94,7 +94,7 @@ describe('Cache', () => {
9494
expect(store3.set).not.toHaveBeenCalled();
9595
});
9696

97-
it('awaits for promises on stores, even if they return undefined', async () => {
97+
test('awaits for promises on stores, even if they return undefined', async () => {
9898
let resolve;
9999

100100
const store1 = createStore();
@@ -120,7 +120,7 @@ describe('Cache', () => {
120120
expect(store2.get).toHaveBeenCalledTimes(1);
121121
});
122122

123-
it('throws all errors on a buggy store set', async () => {
123+
test('throws all errors on a buggy store set', async () => {
124124
const goodStore = createStore('GoodStore');
125125
const badAsyncStore = createStore('BadAsyncStore');
126126
const badSyncStore = createStore('BadSyncStore');
@@ -150,7 +150,7 @@ describe('Cache', () => {
150150
expect(error?.errors[1].cause).toEqual(RangeError('foo'));
151151
});
152152

153-
it('throws on a buggy store get', async () => {
153+
test('throws on a buggy store get', async () => {
154154
const store1 = createStore();
155155
const store2 = createStore();
156156
const cache = new Cache([store1, store2]);
@@ -168,7 +168,7 @@ describe('Cache', () => {
168168
expect(error).toBeInstanceOf(TypeError);
169169
});
170170

171-
it('logs the right messages when getting without errors', async () => {
171+
test('logs the right messages when getting without errors', async () => {
172172
const store1 = createStore('Local');
173173
const store2 = createStore('Network');
174174
const cache = new Cache([store1, store2]);
@@ -188,7 +188,7 @@ describe('Cache', () => {
188188
]);
189189
});
190190

191-
it('logs the right messages when getting with errors', async () => {
191+
test('logs the right messages when getting with errors', async () => {
192192
const store1 = createStore('Local');
193193
const store2 = createStore('Network');
194194
const cache = new Cache([store1, store2]);
@@ -212,7 +212,7 @@ describe('Cache', () => {
212212
]);
213213
});
214214

215-
it('logs the right messages when setting', async () => {
215+
test('logs the right messages when setting', async () => {
216216
const store1 = createStore('Local');
217217
const store2 = createStore('Network');
218218
const cache = new Cache([store1, store2]);
@@ -228,7 +228,7 @@ describe('Cache', () => {
228228
});
229229

230230
describe('disabled cache', () => {
231-
it('returns null for reads', async () => {
231+
test('returns null for reads', async () => {
232232
// $FlowFixMe[missing-empty-array-annot]
233233
const cache = new Cache([]);
234234

@@ -237,7 +237,7 @@ describe('Cache', () => {
237237
expect(result).toBe(null);
238238
});
239239

240-
it('ignores writes', async () => {
240+
test('ignores writes', async () => {
241241
// $FlowFixMe[missing-empty-array-annot]
242242
const cache = new Cache([]);
243243

@@ -247,7 +247,7 @@ describe('Cache', () => {
247247
expect(result).toBe(null);
248248
});
249249

250-
it('logs nothing', async () => {
250+
test('logs nothing', async () => {
251251
// $FlowFixMe[missing-empty-array-annot]
252252
const cache = new Cache([]);
253253

packages/metro-cache/src/__tests__/stableHash-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
const stableHash = require('../stableHash');
1414

1515
describe('stableHash', () => {
16-
it('ensures that the hash implementation supports switched order properties', () => {
16+
test('ensures that the hash implementation supports switched order properties', () => {
1717
const sortedHash = stableHash({
1818
a: 3,
1919
b: 4,

packages/metro-cache/src/stores/__tests__/AutoCleanFileStore-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('AutoCleanFileStore', () => {
2626
jest.spyOn(fs, 'unlinkSync');
2727
});
2828

29-
it('sets and writes into the cache', async () => {
29+
test('sets and writes into the cache', async () => {
3030
// $FlowFixMe[underconstrained-implicit-instantiation]
3131
const fileStore = new AutoCleanFileStore({
3232
root: '/root',
@@ -51,7 +51,7 @@ describe('AutoCleanFileStore', () => {
5151
expect(await fileStore.get(cache)).toEqual(null);
5252
});
5353

54-
it('returns null when reading a non-existing file', async () => {
54+
test('returns null when reading a non-existing file', async () => {
5555
// $FlowFixMe[underconstrained-implicit-instantiation]
5656
const fileStore = new AutoCleanFileStore({root: '/root'});
5757
const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]);

packages/metro-cache/src/stores/__tests__/FileStore-test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ describe('FileStore', () => {
2727
jest.spyOn(fs, 'unlinkSync');
2828
});
2929

30-
it('sets and writes into the cache', async () => {
30+
test('sets and writes into the cache', async () => {
3131
const fileStore = new FileStore({root: '/root'});
3232
const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]);
3333

3434
await fileStore.set(cache, {foo: 42});
3535
expect(await fileStore.get(cache)).toEqual({foo: 42});
3636
});
3737

38-
it('returns null when reading a non-existing file', async () => {
38+
test('returns null when reading a non-existing file', async () => {
3939
const fileStore = new FileStore({root: '/root'});
4040
const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]);
4141

4242
expect(await fileStore.get(cache)).toEqual(null);
4343
});
4444

45-
it('returns null when reading a empty file', async () => {
45+
test('returns null when reading a empty file', async () => {
4646
const fileStore = new FileStore({root: '/root'});
4747
const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]);
4848
const filePath = fileStore._getFilePath(cache);
@@ -51,7 +51,7 @@ describe('FileStore', () => {
5151
expect(await fileStore.get(cache)).toEqual(null);
5252
});
5353

54-
it('writes into cache if folder is missing', async () => {
54+
test('writes into cache if folder is missing', async () => {
5555
const fileStore = new FileStore({root: '/root'});
5656
const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]);
5757
const data = Buffer.from([0xca, 0xc4, 0xe5]);
@@ -61,7 +61,7 @@ describe('FileStore', () => {
6161
expect(await fileStore.get(cache)).toEqual(data);
6262
});
6363

64-
it('reads and writes binary data', async () => {
64+
test('reads and writes binary data', async () => {
6565
const fileStore = new FileStore({root: '/root'});
6666
const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]);
6767
const data = Buffer.from([0xca, 0xc4, 0xe5]);

0 commit comments

Comments
 (0)