Skip to content

Roll out jest/consistent-test-it rule #4352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const transformerWithOptions = require('./transformerWithOptions');

describe('`development` option', () => {
it('tests the hash when `development` is set', () => {
test('tests the hash when `development` is set', () => {
expect(
transformerWithOptions(
{eagerEsModules: true},
Expand All @@ -22,7 +22,7 @@ describe('`development` option', () => {
).toMatchSnapshot();
});

it('tests the hash when `isDevVariable` is set', () => {
test('tests the hash when `isDevVariable` is set', () => {
expect(
transformerWithOptions({
eagerEsModules: true,
Expand All @@ -31,7 +31,7 @@ describe('`development` option', () => {
).toMatchSnapshot();
});

it('uses a custom build command in message', () => {
test('uses a custom build command in message', () => {
expect(
transformerWithOptions(
{
Expand All @@ -43,7 +43,7 @@ describe('`development` option', () => {
).toMatchSnapshot();
});

it('does not test the hash when `development` is not set', () => {
test('does not test the hash when `development` is not set', () => {
expect(
transformerWithOptions(
{eagerEsModules: true},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const transformerWithOptions = require('./transformerWithOptions');

describe('`development` option', () => {
it('tests the hash when `development` is set', () => {
test('tests the hash when `development` is set', () => {
expect(
transformerWithOptions(
{},
Expand All @@ -22,15 +22,15 @@ describe('`development` option', () => {
).toMatchSnapshot();
});

it('tests the hash when `isDevVariableName` is set', () => {
test('tests the hash when `isDevVariableName` is set', () => {
expect(
transformerWithOptions({isDevVariableName: 'IS_DEV'})(
'graphql`fragment TestFrag on Node { id }`',
),
).toMatchSnapshot();
});

it('uses a custom build command in message', () => {
test('uses a custom build command in message', () => {
expect(
transformerWithOptions(
{
Expand All @@ -41,7 +41,7 @@ describe('`development` option', () => {
).toMatchSnapshot();
});

it('does not test the hash when `development` is not set', () => {
test('does not test the hash when `development` is not set', () => {
expect(
transformerWithOptions(
{},
Expand Down
8 changes: 4 additions & 4 deletions packages/react-relay/__tests__/ClientEdges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('ClientEdges', () => {
});
});

it('should fetch and render client-edge query', () => {
test('should fetch and render client-edge query', () => {
function TestComponent() {
return (
<RelayEnvironmentProvider environment={environment}>
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('ClientEdges', () => {
expect(renderer?.toJSON()).toBe('Alice');
});

it('should fetch and render `null` for client-edge query that returns `null`.', () => {
test('should fetch and render `null` for client-edge query that returns `null`.', () => {
function TestComponent() {
return (
<RelayEnvironmentProvider environment={environment}>
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('ClientEdges', () => {
expect(renderer?.toJSON()).toBe('MISSING');
});

it('should throw for missing client-edge field data marked with @required', () => {
test('should throw for missing client-edge field data marked with @required', () => {
function TestComponent() {
return (
<RelayEnvironmentProvider environment={environment}>
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('ClientEdges', () => {
expect(renderer?.toJSON()).toBe(null);
});

it('should throw for missing client-edge (client object) field data marked with @required', () => {
test('should throw for missing client-edge (client object) field data marked with @required', () => {
function TestComponent() {
return (
<RelayEnvironmentProvider environment={environment}>
Expand Down
10 changes: 5 additions & 5 deletions packages/react-relay/__tests__/ClientOnlyQueries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ describe('Client-only queries', () => {
});
});

it('should render missing data', () => {
test('should render missing data', () => {
expect(renderer.toJSON()).toEqual('MISSING');
});

it('should render data from the store', () => {
test('should render data from the store', () => {
TestRenderer.act(() => {
environment.commitPayload(operation, {
defaultSettings: {
Expand All @@ -122,7 +122,7 @@ describe('Client-only queries', () => {
expect(renderer.toJSON()).toEqual('My Client Field');
});

it('should render with new environment', () => {
test('should render with new environment', () => {
environment = createEnvironment(
RecordSource.create({
'client:root': {
Expand All @@ -148,7 +148,7 @@ describe('Client-only queries', () => {
expect(renderer.toJSON()).toEqual('Another Client Field');
});

it('should still render with store-or-network', () => {
test('should still render with store-or-network', () => {
environment = createEnvironment(
RecordSource.create({
'client:root': {
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('Client-only queries', () => {
expect(renderer.toJSON()).toEqual('Another Client Field');
});

it('should handle updatable client-only query', () => {
test('should handle updatable client-only query', () => {
const updatableQuery = graphql`
query ClientOnlyQueriesTestUpdatableQuery @updatable {
defaultSettings {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-relay/__tests__/LiveResolvers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ describe.each([
});
}

it('should renderer the data from the store, after global state resolves the value', () => {
test('should renderer the data from the store, after global state resolves the value', () => {
const source = RelayRecordSource.create({
'client:root': {
__id: 'client:root',
Expand Down Expand Up @@ -750,7 +750,7 @@ describe.each([
);
});

it('should render undefined value for missing data in live resolver field', () => {
test('should render undefined value for missing data in live resolver field', () => {
const source = RelayRecordSource.create({
'client:root': {
__id: 'client:root',
Expand Down Expand Up @@ -798,7 +798,7 @@ describe.each([
expect(renderer.toJSON()).toEqual('Alice: undefined');
});

it('should render undefined value for missing data in live resolver field and trigger different states of suspense ', () => {
test('should render undefined value for missing data in live resolver field and trigger different states of suspense ', () => {
const source = RelayRecordSource.create({
'client:root': {
__id: 'client:root',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('QueryResource Client Edges behavior', () => {
});
});

it('Only issues one operation when multiple fragments are under a client edge', async () => {
test('Only issues one operation when multiple fragments are under a client edge', async () => {
// Simulate rendering the query; we expect a single operation for the client edge to be
// issued. Ideally it would only be issued once sub-components whose fragments access
// data on the client edge are rendered, but this isn't implemented because it is more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
});
});

it('resolves & subscribes fragment props', () => {
test('resolves & subscribes fragment props', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;

Expand Down Expand Up @@ -212,7 +212,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
});
});

it('re-renders on subscription callback', () => {
test('re-renders on subscription callback', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;

Expand Down Expand Up @@ -270,7 +270,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
});
});

it('resolves new props', () => {
test('resolves new props', () => {
let userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const instance = ReactTestRenderer.create(
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
});
});

it('resolves new props when ids dont change', () => {
test('resolves new props when ids dont change', () => {
let userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const instance = ReactTestRenderer.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe.skip('ReactRelayFragmentContainer-react-double-effects-test', () => {
RelayFeatureFlags.ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT = false;
});

it('unsubscribes and re-subscribes to fragment when effects are double invoked', () => {
test('unsubscribes and re-subscribes to fragment when effects are double invoked', () => {
// $FlowFixMe[prop-missing]
warning.mockClear();

Expand Down
36 changes: 18 additions & 18 deletions packages/react-relay/__tests__/ReactRelayFragmentContainer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ describe('ReactRelayFragmentContainer', () => {
});
});

it('generates a name for containers', () => {
test('generates a name for containers', () => {
expect(TestContainer.$$typeof).toBe(Symbol.for('react.forward_ref'));
expect(TestContainer.render.displayName).toBe('Relay(TestComponent)');
});

it('throws for invalid fragment set', () => {
test('throws for invalid fragment set', () => {
expect(() => {
ReactRelayFragmentContainer.createContainer(TestComponent, 'a string');
}).toThrowError(
Expand All @@ -172,7 +172,7 @@ describe('ReactRelayFragmentContainer', () => {
);
});

it('throws for invalid fragments', () => {
test('throws for invalid fragments', () => {
expect(() => {
ReactRelayFragmentContainer.createContainer(TestComponent, {
foo: null,
Expand All @@ -184,15 +184,15 @@ describe('ReactRelayFragmentContainer', () => {
);
});

it('does not throw when fragments are in modern mode', () => {
test('does not throw when fragments are in modern mode', () => {
expect(() => {
ReactRelayFragmentContainer.createContainer(TestComponent, {
foo: {kind: 'Fragment'},
});
}).not.toThrow();
});

it('passes non-fragment props to the component', () => {
test('passes non-fragment props to the component', () => {
expectToWarn(
'createFragmentSpecResolver: Expected prop `user` to be supplied to `Relay(TestComponent)`, but got `undefined`. Pass an explicit `null` if this is intentional.',
() => {
Expand All @@ -216,7 +216,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(environment.subscribe.mock.calls.length).toBe(0);
});

it('passes through null props', () => {
test('passes through null props', () => {
ReactTestRenderer.create(
<ContextSetter environment={environment}>
<TestContainer user={null} />
Expand All @@ -234,7 +234,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(environment.subscribe.mock.calls.length).toBe(0);
});

it('resolves & subscribes fragment props', () => {
test('resolves & subscribes fragment props', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;

Expand Down Expand Up @@ -276,7 +276,7 @@ describe('ReactRelayFragmentContainer', () => {
});
});

it('re-renders on subscription callback', () => {
test('re-renders on subscription callback', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;

Expand Down Expand Up @@ -318,7 +318,7 @@ describe('ReactRelayFragmentContainer', () => {
});
});

it('resolves new props', () => {
test('resolves new props', () => {
let userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const instance = ReactTestRenderer.create(
Expand Down Expand Up @@ -368,7 +368,7 @@ describe('ReactRelayFragmentContainer', () => {
});
});

it('resolves new props when ids dont change', () => {
test('resolves new props when ids dont change', () => {
let userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const instance = ReactTestRenderer.create(
Expand Down Expand Up @@ -421,7 +421,7 @@ describe('ReactRelayFragmentContainer', () => {
});
});

it('does not update for same props/data', () => {
test('does not update for same props/data', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const instance = ReactTestRenderer.create(
Expand All @@ -442,7 +442,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(environment.subscribe).not.toBeCalled();
});

it('does not update for equal scalar props', () => {
test('does not update for equal scalar props', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const scalar = 42;
Expand All @@ -468,7 +468,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(environment.subscribe).not.toBeCalled();
});

it('updates for unequal function props', () => {
test('updates for unequal function props', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const scalar = 42;
Expand Down Expand Up @@ -499,7 +499,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(environment.subscribe).not.toBeCalled();
});

it('updates for unequal scalar props', () => {
test('updates for unequal scalar props', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const scalar = 42;
Expand Down Expand Up @@ -529,7 +529,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(environment.subscribe).not.toBeCalled();
});

it('always updates for non-scalar props', () => {
test('always updates for non-scalar props', () => {
const userPointer = environment.lookup(ownerUser1.fragment, ownerUser1).data
.node;
const instance = ReactTestRenderer.create(
Expand Down Expand Up @@ -573,7 +573,7 @@ describe('ReactRelayFragmentContainer', () => {
);
});

it('does not proxy instance methods', () => {
test('does not proxy instance methods', () => {
class TestNoProxy extends React.Component {
render() {
return <div />;
Expand Down Expand Up @@ -613,7 +613,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(() => containerRef.instanceMethod('foo')).toThrow();
});

it('can be unwrapped in tests', () => {
test('can be unwrapped in tests', () => {
class TestUnwrapping extends React.Component {
render() {
return <div>Unwrapped</div>;
Expand Down Expand Up @@ -663,7 +663,7 @@ describe('ReactRelayFragmentContainer', () => {
expect(actualYields).toEqual(expectedYields);
}

it('upon commit, it should pick up changes in data that happened before comitting', () => {
test('upon commit, it should pick up changes in data that happened before comitting', () => {
const Scheduler = require('scheduler');
const YieldChild = props => {
Scheduler.log(props.children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ReactTestRenderer = require('react-test-renderer');
const {createMockEnvironment} = require('relay-test-utils-internal');

describe('ReactRelayFragmentMockRenderer', () => {
it('renders fragment containers with mock data as supplied as props', () => {
test('renders fragment containers with mock data as supplied as props', () => {
class ChildComponent extends React.Component {
render() {
return <h2>{this.props.viewer.actor.id}</h2>;
Expand Down
Loading