Skip to content

Commit

Permalink
Standardize filenames in packages/expect (#7306)
Browse files Browse the repository at this point in the history
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

<!-- Please remember to update CHANGELOG.md in the root of the project if you have not done so. -->

## Summary

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

References Standardize file naming #4969.

Updates naming in package expect. Uses conventions listed in #4969 (comment):
- Files that primarily export types, objects or classes should use CapitalizedFileNames.js and should mirror what’s inside 1:1.
- Files that export a single function should have the function name with camelCase in it.
- Folder names should use dashes, unless they are special folders.

### Decisions
- Test & snapshot files retained their name, but converted it to camelCase.
- Files which exported an object were named according to the internal object, which was camelCase. However, I believe that the standard referenced above states that objects should have CapitalizedNames. Should the internal objects be renamed too?
    - `matchers.js`
    - `jestMatchersObject.js`
    - `spyMatchers.js`
    - `toThrowmatchers.js`

### Questions
How should `asymmetricMatchers.js` be named? It exports a class `AsymmetricMatcher`, but it also exports a bunch of functions, and was named in camelCase before.


## Test plan

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

Output of yarn run test on master and standardize filenames in packages/jest circus branches was the same.

[jest-test-expect-master.txt](https://github.com/facebook/jest/files/2532360/jest-test-expect-master.txt)
[jest-test-expect-standardize-filenames.txt](https://github.com/facebook/jest/files/2532363/jest-test-expect-standardize-filenames.txt)
  • Loading branch information
andrew-pyle authored and thymikee committed Oct 31, 2018
1 parent fb61bff commit 968ddc4
Show file tree
Hide file tree
Showing 22 changed files with 18 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

### Fixes

- `[expect]` Standardize file naming in `expect` ([#7306](https://github.com/facebook/jest/pull/7306))
- `[jest-each]` Add empty array validation check ([#7249](https://github.com/facebook/jest/pull/7249))
- `[jest-cli]` Interrupt tests if interactive watch plugin key is pressed ([#7222](https://github.com/facebook/jest/pull/7222))
- `[jest-cli]` Fix coverage summary reporting ([#7058](https://github.com/facebook/jest/pull/7058))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {
stringNotContaining,
stringMatching,
stringNotMatching,
} = require('../asymmetric_matchers');
} = require('../asymmetricMatchers');

test('Any.asymmetricMatch()', () => {
const Thing = function() {};
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/__tests__/extend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const matcherUtils = require('jest-matcher-utils');
const {iterableEquality, subsetEquality} = require('../utils');
const {equals} = require('../jasmine_utils');
const {equals} = require('../jasmineUtils');
const jestExpect = require('../');

jestExpect.extend({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
'use strict';

const fakeChalk = jest.requireActual('../fake_chalk');
const fakeChalk = jest.requireActual('../fakeChalk');

describe('Fake Chalk', () => {
it('returns input when invoked', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
* @flow
*/

import {
equals,
fnNameFor,
hasProperty,
isA,
isUndefined,
} from './jasmine_utils';
import {equals, fnNameFor, hasProperty, isA, isUndefined} from './jasmineUtils';

import {emptyObject} from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
pluralize,
} from 'jest-matcher-utils';

import {getState, setState} from './jest_matchers_object';
import {getState, setState} from './jestMatchersObject';

const resetAssertionsLocalState = () => {
setState({
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions packages/expect/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import type {
import * as matcherUtils from 'jest-matcher-utils';
import {iterableEquality, subsetEquality} from './utils';
import matchers from './matchers';
import spyMatchers from './spy_matchers';
import spyMatchers from './spyMatchers';
import toThrowMatchers, {
createMatcher as createThrowMatcher,
} from './to_throw_matchers';
import {equals} from './jasmine_utils';
} from './toThrowMatchers';
import {equals} from './jasmineUtils';
import {
any,
anything,
Expand All @@ -39,15 +39,15 @@ import {
stringNotContaining,
stringMatching,
stringNotMatching,
} from './asymmetric_matchers';
} from './asymmetricMatchers';
import {
INTERNAL_MATCHER_FLAG,
getState,
setState,
getMatchers,
setMatchers,
} from './jest_matchers_object';
import extractExpectedAssertionsErrors from './extract_expected_assertions_errors';
} from './jestMatchersObject';
import extractExpectedAssertionsErrors from './extractExpectedAssertionsErrors';

class JestAssertionError extends Error {
matcherResult: any;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import {AsymmetricMatcher} from './asymmetric_matchers';
import {AsymmetricMatcher} from './asymmetricMatchers';
import type {
Expect,
MatchersObject,
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
typeEquality,
isOneline,
} from './utils';
import {equals} from './jasmine_utils';
import {equals} from './jasmineUtils';

type ContainIterable =
| Array<any>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
printWithType,
RECEIVED_COLOR,
} from 'jest-matcher-utils';
import {equals} from './jasmine_utils';
import {equals} from './jasmineUtils';
import {iterableEquality, partition, isOneline} from './utils';
import diff from 'jest-diff';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
printExpected,
printWithType,
} from 'jest-matcher-utils';
import {equals} from './jasmine_utils';
import {equals} from './jasmineUtils';
import {isError} from './utils';

export const createMatcher = (matcherName: string, fromPromise?: boolean) => (
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
isA,
isImmutableUnorderedKeyed,
isImmutableUnorderedSet,
} from './jasmine_utils';
} from './jasmineUtils';

type GetPath = {
hasEndProp?: boolean,
Expand Down
2 changes: 1 addition & 1 deletion scripts/browserBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function browserBuild(pkgName, entryPath, destination) {
{
resolveId(id) {
return id === 'chalk'
? path.resolve(__dirname, '../packages/expect/build/fake_chalk.js')
? path.resolve(__dirname, '../packages/expect/build/fakeChalk.js')
: undefined;
},
},
Expand Down

0 comments on commit 968ddc4

Please sign in to comment.