Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Remove always-true hasHooks flag
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Nov 4, 2022
1 parent 1e2f272 commit 9067f76
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 38 deletions.
1 change: 0 additions & 1 deletion test/test/_helpers/describeHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default function describeHooks({ Wrap, Wrapper }, ...hooks) {

hooks.forEach((hook) => {
require(`../shared/hooks/${hook}`).default({
hasHooks: true,
Wrap,
WrapRendered: isShallow ? Wrap : (...args) => Wrap(...args).children(),
Wrapper,
Expand Down
3 changes: 1 addition & 2 deletions test/test/shared/hooks/_hook.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from '../../_helpers/react-compat';

export default function describe$Hook({
hasHooks,
Wrap,
WrapRendered,
Wrapper,
Expand All @@ -37,6 +36,6 @@ export default function describe$Hook({
isMount,
makeDOMElement,
}) {
describeIf(hasHooks, 'hooks: $Hook', () => {
describe('hooks: $Hook', () => {
});
}
4 changes: 2 additions & 2 deletions test/test/shared/hooks/custom.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { describeIf } from '../../_helpers';

import { useEffect, useState } from '../../_helpers/react-compat';

export default function describeCustomHooks({ hasHooks, Wrap, isShallow }) {
describeIf(hasHooks, 'hooks: custom', () => {
export default function describeCustomHooks({ Wrap, isShallow }) {
describe('hooks: custom', () => {
describe('custom hook: useCounter', () => {
function useCounter({ initialCount = 0, step = 1 } = {}) {
const [count, setCount] = useState(initialCount);
Expand Down
6 changes: 3 additions & 3 deletions test/test/shared/hooks/useCallback.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { expect } from 'chai';

import { describeIf, itIf } from '../../_helpers';
import { itIf } from '../../_helpers';

import { useCallback } from '../../_helpers/react-compat';

export default function describeUseCallback({ hasHooks, Wrap, isShallow }) {
describeIf(hasHooks, 'hooks: useCallback', () => {
export default function describeUseCallback({ Wrap, isShallow }) {
describe('hooks: useCallback', () => {
function RendersNull() {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions test/test/shared/hooks/useContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { describeIf, itIf } from '../../_helpers';

import { useContext, useState, createContext } from '../../_helpers/react-compat';

export default function describeUseContext({ hasHooks, Wrap, isShallow }) {
describeIf(hasHooks, 'hooks: useContext', () => {
export default function describeUseContext({ Wrap, isShallow }) {
describe('hooks: useContext', () => {
describe('simple example', () => {
const initialTitle = 'initialTitle';
const TitleContext = createContext && createContext(initialTitle);
Expand Down
6 changes: 2 additions & 4 deletions test/test/shared/hooks/useDebugValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import React from 'react';
import { expect } from 'chai';
import sinon from 'sinon';

import { describeIf } from '../../_helpers';

import { useDebugValue } from '../../_helpers/react-compat';

export default function describeUseDebugValue({ hasHooks, Wrap }) {
export default function describeUseDebugValue({ Wrap }) {
// TODO: `useDebugValue`: test using react debug tools, verify it actually works, and try to add it to `.debug`
describeIf(hasHooks, 'hooks: useDebugValue', () => {
describe('hooks: useDebugValue', () => {
function ComponentUsingDebugValue({ value }) {
useDebugValue(`debug value: ${value}`);

Expand Down
4 changes: 2 additions & 2 deletions test/test/shared/hooks/useEffect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import sinon from 'sinon-sandbox';
import { describeIf, itIf } from '../../_helpers';
import { useEffect, useState, Fragment } from '../../_helpers/react-compat';

export default function describeUseEffect({ hasHooks, Wrap, isShallow }) {
export default function describeUseEffect({ Wrap, isShallow }) {
// TODO: enable when the shallow renderer fixes its bug, see https://github.com/facebook/react/issues/15275.
describeIf(hasHooks && !isShallow, 'hooks: useEffect', () => {
describeIf(!isShallow, 'hooks: useEffect', () => {
const timeout = 100;
function ComponentUsingEffectHook() {
const [ctr, setCtr] = useState(0);
Expand Down
6 changes: 2 additions & 4 deletions test/test/shared/hooks/useImperativeHandle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import React from 'react';
import { expect } from 'chai';
import sinon from 'sinon-sandbox';

import { describeIf } from '../../_helpers';

import { useImperativeHandle, useRef, forwardRef } from '../../_helpers/react-compat';

export default function describeUseImperativeHandle({ hasHooks, Wrap, isShallow }) {
describeIf(hasHooks, 'hooks: useImperativeHandle', () => {
export default function describeUseImperativeHandle({ Wrap, isShallow }) {
describe('hooks: useImperativeHandle', () => {
function Computer({ compute }, ref) {
const computerRef = useRef({ compute });
useImperativeHandle(ref, () => ({
Expand Down
6 changes: 3 additions & 3 deletions test/test/shared/hooks/useLayoutEffect.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { expect } from 'chai';

import { describeIf, itIf } from '../../_helpers';
import { itIf } from '../../_helpers';

import { useLayoutEffect, useState } from '../../_helpers/react-compat';

export default function describeUseLayoutEffect({ hasHooks, Wrap, isShallow }) {
describeIf(hasHooks, 'hooks: useLayoutEffect', () => {
export default function describeUseLayoutEffect({ Wrap, isShallow }) {
describe('hooks: useLayoutEffect', () => {
function ComponentUsingLayoutEffectHook() {
const [ctr, setCtr] = useState(0);
useLayoutEffect(() => {
Expand Down
6 changes: 2 additions & 4 deletions test/test/shared/hooks/useMemo.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import { expect } from 'chai';

import { describeIf } from '../../_helpers';

import { useMemo } from '../../_helpers/react-compat';

export default function describeUseMemo({ hasHooks, Wrap }) {
describeIf(hasHooks, 'hooks: useMemo', () => {
export default function describeUseMemo({ Wrap }) {
describe('hooks: useMemo', () => {
function RendersNull() {
return null;
}
Expand Down
6 changes: 2 additions & 4 deletions test/test/shared/hooks/useReducer.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import { expect } from 'chai';

import { describeIf } from '../../_helpers';

import { useReducer } from '../../_helpers/react-compat';

export default function describeUseReducer({ hasHooks, Wrap }) {
describeIf(hasHooks, 'hooks: useReducer', () => {
export default function describeUseReducer({ Wrap }) {
describe('hooks: useReducer', () => {
describe('with custom dispatch', () => {
const initialState = [];

Expand Down
6 changes: 2 additions & 4 deletions test/test/shared/hooks/useRef.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import { expect } from 'chai';

import { describeIf } from '../../_helpers';

import { useRef } from '../../_helpers/react-compat';

export default function describeUseRef({ hasHooks, Wrap }) {
describeIf(hasHooks, 'hooks: useRef', () => {
export default function describeUseRef({ Wrap }) {
describe('hooks: useRef', () => {
function ComponentUsingRef() {
const id = useRef(Math.floor(100 * Math.random()));
return <div>{id.current}</div>;
Expand Down
6 changes: 3 additions & 3 deletions test/test/shared/hooks/useState.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { expect } from 'chai';

import { describeIf, itIf } from '../../_helpers';
import { itIf } from '../../_helpers';

import { useState, useEffect, Fragment } from '../../_helpers/react-compat';

export default function describeUseState({ hasHooks, Wrap, isShallow }) {
describeIf(hasHooks, 'hooks: useState', () => {
export default function describeUseState({ Wrap, isShallow }) {
describe('hooks: useState', () => {
function FooCounter({ initialCount: initial = 0 }) {
const [count, setCount] = useState(+initial);

Expand Down

0 comments on commit 9067f76

Please sign in to comment.