Skip to content

Commit b3efc9b

Browse files
committed
refactor: improve code coverage, remove dead code
1 parent e11afa3 commit b3efc9b

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

src/helpers/find-all.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ function findAllInternal(
4242
): HostElement[] {
4343
const results: HostElement[] = [];
4444

45-
//console.log(`${indent} 🟢 findAllInternal`, node.type, node.props);
46-
4745
// Match descendants first but do not add them to results yet.
4846
const matchingDescendants: HostElement[] = [];
4947
node.children.forEach((child) => {
@@ -67,20 +65,3 @@ function findAllInternal(
6765

6866
return results;
6967
}
70-
71-
export function findAllByProps(
72-
root: HostElement,
73-
props: { [propName: string]: any },
74-
options?: FindAllOptions,
75-
): HostElement[] {
76-
return findAll(root, (element) => matchProps(element, props), options);
77-
}
78-
79-
function matchProps(element: HostElement, props: { [propName: string]: any }): boolean {
80-
for (const key in props) {
81-
if (props[key] !== element.props[key]) {
82-
return false;
83-
}
84-
}
85-
return true;
86-
}

src/matchers/__tests__/to-be-empty-element.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { View } from 'react-native';
2+
import { Text, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -12,6 +12,7 @@ test('toBeEmptyElement() base case', () => {
1212
render(
1313
<View testID="not-empty">
1414
<View testID="empty" />
15+
<Text testID="text">Hello</Text>
1516
</View>,
1617
);
1718

@@ -32,7 +33,21 @@ test('toBeEmptyElement() base case', () => {
3233
Received:
3334
<View
3435
testID="empty"
35-
/>"
36+
/>
37+
<Text
38+
testID="text"
39+
>
40+
Hello
41+
</Text>"
42+
`);
43+
44+
const text = screen.getByTestId('text');
45+
expect(text).not.toBeEmptyElement();
46+
expect(() => expect(text).toBeEmptyElement()).toThrowErrorMatchingInlineSnapshot(`
47+
"expect(element).toBeEmptyElement()
48+
49+
Received:
50+
Hello"
3651
`);
3752
});
3853

src/matchers/__tests__/utils.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function fakeMatcher() {
88
}
99

1010
test('formatElement', () => {
11+
expect(formatElement('Hello')).toMatchInlineSnapshot(`"Hello"`);
1112
expect(formatElement(null)).toMatchInlineSnapshot(`" null"`);
1213
});
1314

0 commit comments

Comments
 (0)