diff --git a/packages/inferno-test-utils/__tests__/__snapshots__/snapshots.spec.jsx.snap b/packages/inferno-test-utils/__tests__/__snapshots__/snapshots.spec.tsx.snap
similarity index 99%
rename from packages/inferno-test-utils/__tests__/__snapshots__/snapshots.spec.jsx.snap
rename to packages/inferno-test-utils/__tests__/__snapshots__/snapshots.spec.tsx.snap
index 16ddce595..80064f5d3 100644
--- a/packages/inferno-test-utils/__tests__/__snapshots__/snapshots.spec.jsx.snap
+++ b/packages/inferno-test-utils/__tests__/__snapshots__/snapshots.spec.tsx.snap
@@ -151,7 +151,7 @@ exports[`Snapshots JSX Should render fragment root 1`] = `
exports[`Snapshots JSX Should render html element 1`] = `
diff --git a/packages/inferno-test-utils/__tests__/__snapshots__/testUtils.jest.spec.jsx.snap b/packages/inferno-test-utils/__tests__/__snapshots__/testUtils.jest.spec.tsx.snap
similarity index 100%
rename from packages/inferno-test-utils/__tests__/__snapshots__/testUtils.jest.spec.jsx.snap
rename to packages/inferno-test-utils/__tests__/__snapshots__/testUtils.jest.spec.tsx.snap
diff --git a/packages/inferno-test-utils/__tests__/snapshots.spec.jsx b/packages/inferno-test-utils/__tests__/snapshots.spec.tsx
similarity index 89%
rename from packages/inferno-test-utils/__tests__/snapshots.spec.jsx
rename to packages/inferno-test-utils/__tests__/snapshots.spec.tsx
index e8bac4957..5ab6e709f 100644
--- a/packages/inferno-test-utils/__tests__/snapshots.spec.jsx
+++ b/packages/inferno-test-utils/__tests__/snapshots.spec.tsx
@@ -2,7 +2,7 @@ import { Component, createFragment, Fragment } from 'inferno';
import { renderToSnapshot } from 'inferno-test-utils';
import { ChildFlags } from 'inferno-vnode-flags';
-if (window.usingJest) {
+if ((window as any).usingJest) {
describe('Snapshots', () => {
class Foobar extends Component {
render({ children }) {
@@ -37,7 +37,7 @@ if (window.usingJest) {
it('Should render html element', () => {
expect(
renderToSnapshot(
- {}} aria-colspan="3" className="foo">
+ {}} aria-colspan={3} className="foo">
Bar
,
),
@@ -142,13 +142,19 @@ if (window.usingJest) {
});
it('Should not fail when returning children array from component root, which contains text node. Github #1404', () => {
+ interface LabelProps {
+ label?: string;
+ htmlFor?: string;
+ optional?: boolean;
+ children: any;
+ }
const Label = ({
label,
htmlFor,
children,
optional = false,
...props
- }) => {
+ }: LabelProps) => {
if (optional && !label) {
return children;
}
@@ -180,13 +186,19 @@ if (window.usingJest) {
});
it('Should not fail when returning children array from component root, Github #1404', () => {
+ interface LabelProps {
+ label?: string;
+ htmlFor?: string;
+ optional?: boolean;
+ children: any;
+ }
const Label = ({
- label,
- htmlFor,
- children,
- optional = false,
- ...props
- }) => {
+ label,
+ htmlFor,
+ children,
+ optional = false,
+ ...props
+ }: LabelProps) => {
if (optional && !label) {
return children;
}
@@ -208,12 +220,8 @@ if (window.usingJest) {
it('Should flush setStates before building snapshot', () => {
class App extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- foo: '',
- };
+ state = {
+ foo: ''
}
componentDidMount() {
diff --git a/packages/inferno-test-utils/__tests__/testUtils.jest.spec.jsx b/packages/inferno-test-utils/__tests__/testUtils.jest.spec.tsx
similarity index 96%
rename from packages/inferno-test-utils/__tests__/testUtils.jest.spec.jsx
rename to packages/inferno-test-utils/__tests__/testUtils.jest.spec.tsx
index f16e994f9..b27f17da0 100644
--- a/packages/inferno-test-utils/__tests__/testUtils.jest.spec.jsx
+++ b/packages/inferno-test-utils/__tests__/testUtils.jest.spec.tsx
@@ -5,7 +5,7 @@ const FunctionalComponent = function (props) {
return createElement('div', props);
};
-const usingJest = window.usingJest;
+const usingJest = (window as any).usingJest as boolean;
describe('renderToSnapshot', () => {
it('should return a snapshot from a valid vNode', () => {
diff --git a/packages/inferno-test-utils/__tests__/testUtils.spec.jsx b/packages/inferno-test-utils/__tests__/testUtils.spec.tsx
similarity index 94%
rename from packages/inferno-test-utils/__tests__/testUtils.spec.jsx
rename to packages/inferno-test-utils/__tests__/testUtils.spec.tsx
index 7dd4de691..26d657ca2 100644
--- a/packages/inferno-test-utils/__tests__/testUtils.spec.jsx
+++ b/packages/inferno-test-utils/__tests__/testUtils.spec.tsx
@@ -180,11 +180,11 @@ describe('Test Utils', () => {
it('should return false for VNodes of incorrect type', () => {
expect(isDOMVNodeOfType(createElement('div'), 'foo')).toBe(false);
- expect(isDOMVNodeOfType(createElement('div'), {})).toBe(false);
- expect(isDOMVNodeOfType(createElement('div'), [])).toBe(false);
- expect(isDOMVNodeOfType(createElement('div'), 10)).toBe(false);
- expect(isDOMVNodeOfType(createElement('div'), undefined)).toBe(false);
- expect(isDOMVNodeOfType(createElement('div'), null)).toBe(false);
+ expect(isDOMVNodeOfType(createElement('div'), {} as never)).toBe(false);
+ expect(isDOMVNodeOfType(createElement('div'), [] as never)).toBe(false);
+ expect(isDOMVNodeOfType(createElement('div'), 10 as never)).toBe(false);
+ expect(isDOMVNodeOfType(createElement('div'), undefined as never)).toBe(false);
+ expect(isDOMVNodeOfType(createElement('div'), null as never)).toBe(false);
});
});
@@ -333,13 +333,13 @@ describe('Test Utils', () => {
it('should return false for DOMElements of incorrect type', () => {
expect(isDOMElementOfType(createDOMElement('div'), 'foo')).toBe(false);
- expect(isDOMElementOfType(createDOMElement('div'), {})).toBe(false);
- expect(isDOMElementOfType(createDOMElement('div'), [])).toBe(false);
- expect(isDOMElementOfType(createDOMElement('div'), 10)).toBe(false);
- expect(isDOMElementOfType(createDOMElement('div'), undefined)).toBe(
+ expect(isDOMElementOfType(createDOMElement('div'), {} as never)).toBe(false);
+ expect(isDOMElementOfType(createDOMElement('div'), [] as never)).toBe(false);
+ expect(isDOMElementOfType(createDOMElement('div'), 10 as never)).toBe(false);
+ expect(isDOMElementOfType(createDOMElement('div'), undefined as never)).toBe(
false,
);
- expect(isDOMElementOfType(createDOMElement('div'), null)).toBe(false);
+ expect(isDOMElementOfType(createDOMElement('div'), null as never)).toBe(false);
});
});
@@ -411,7 +411,7 @@ describe('Test Utils', () => {
expect(
isRenderedClassComponentOfType(
renderIntoContainer(createClassVNode),
- 'div',
+ 'div' as never,
),
).toBe(false);
@@ -436,7 +436,7 @@ describe('Test Utils', () => {
expect(
isRenderedClassComponentOfType(
renderIntoContainer(extendClassVNode),
- 'div',
+ 'div' as never,
),
).toBe(false);
});
@@ -459,6 +459,8 @@ describe('Test Utils', () => {
expect(spy).not.toHaveBeenCalled();
findAllInRenderedTree(tree1, (args) => {
spy(args.type);
+
+ return true
});
// 0: section
// 1: FunctionalComponent
@@ -470,8 +472,11 @@ describe('Test Utils', () => {
});
it('should call predicate in the correct order', () => {
- const types = [];
- findAllInRenderedTree(tree1, ({ type }) => types.push(type));
+ const types: unknown[] = [];
+ findAllInRenderedTree(tree1, ({ type }) => {
+ types.push(type)
+ return true
+ });
expect(types).toEqual(['section', FunctionalComponent, 'div']);
});
@@ -507,8 +512,7 @@ describe('Test Utils', () => {
);
it('should throw an error when not passed a VNode', () => {
- const errorRegex = /findAllInVNodeTree/;
- const predicate = (vNode) => {
+ const predicate = () => {
return true;
};
const testValue = (value) => {
@@ -534,6 +538,7 @@ describe('Test Utils', () => {
findAllInVNodeTree(tree2, (args) => {
predicate(args.type);
+ return true;
});
// 0: section
// 1: FunctionalComponent
@@ -543,8 +548,11 @@ describe('Test Utils', () => {
});
it('should call predicate in the correct order', () => {
- const types = [];
- findAllInVNodeTree(tree2, ({ type }) => types.push(type));
+ const types: unknown[] = [];
+ findAllInVNodeTree(tree2, ({ type }) => {
+ types.push(type);
+ return true;
+ });
expect(types).toEqual(['section', FunctionalComponent]);
});
});
@@ -616,7 +624,7 @@ describe('Test Utils', () => {
);
it('should return an array of matched DOM elements', () => {
- const testValue = (tagName, length, instance) => {
+ const testValue = (tagName, length) => {
const result = scryRenderedDOMElementsWithTag(tree4, tagName);
expect(result instanceof Array).toBeTruthy();
expect(result.length).toBe(length);
@@ -708,7 +716,6 @@ describe('Test Utils', () => {
);
it('should throw an error when more than one result is found #1', () => {
- const errorRegex = /Did not find exactly one match/;
const testValue = (classNames) => {
expect(() => {
findRenderedDOMElementWithClass(tree7, classNames);
@@ -719,7 +726,7 @@ describe('Test Utils', () => {
});
it('should return a matched DOM element', () => {
- const testValue = (classNames, instance) => {
+ const testValue = (classNames) => {
const result = findRenderedDOMElementWithClass(tree7, classNames);
const arrOfClassName = classNames.split(' ');
for (let i = 0; i < arrOfClassName.length; i++) {
@@ -762,7 +769,6 @@ describe('Test Utils', () => {
);
it('should throw an error when more than one result is found #2', () => {
- const errorRegex = /Did not find exactly one match/;
const testValue = (tagName) => {
expect(() => {
findRenderedDOMElementWithTag(tree8, tagName);
@@ -773,7 +779,7 @@ describe('Test Utils', () => {
});
it('should return a matched DOM element', () => {
- const testValue = (tagName, instance) => {
+ const testValue = (tagName) => {
const result = findRenderedDOMElementWithTag(tree8, tagName);
expect(result.tagName).toBe(tagName.toUpperCase());
@@ -796,7 +802,6 @@ describe('Test Utils', () => {
);
it('should throw an error when more than one result is found #3', () => {
- const errorRegex = /Did not find exactly one match/;
const testValue = (type) => {
expect(() => {
findRenderedVNodeWithType(tree9, type);
@@ -834,7 +839,6 @@ describe('Test Utils', () => {
);
it('should throw an error when more than one result is found #4', () => {
- const errorRegex = /Did not find exactly one match/;
const testValue = (type) => {
expect(() => {
findVNodeWithType(tree10, type);