Skip to content

Commit f88d1bb

Browse files
committed
feat: fix config and render-debug tests
1 parent 7af0b70 commit f88d1bb

File tree

3 files changed

+188
-5
lines changed

3 files changed

+188
-5
lines changed

src/__tests__/__snapshots__/render-debug.test.tsx.snap

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,173 @@ exports[`debug with only props from TextInput components 1`] = `
284284
</Text>
285285
</View>"
286286
`;
287+
288+
exports[`debug: another custom message 1`] = `
289+
"another custom message
290+
291+
<View>
292+
<Text>
293+
Is the banana fresh?
294+
</Text>
295+
<Text
296+
testID="bananaFresh"
297+
>
298+
not fresh
299+
</Text>
300+
<TextInput
301+
placeholder="Add custom freshness"
302+
testID="bananaCustomFreshness"
303+
value="Custom Freshie"
304+
/>
305+
<TextInput
306+
defaultValue="What did you inspect?"
307+
placeholder="Who inspected freshness?"
308+
testID="bananaChef"
309+
value="I inspected freshie"
310+
/>
311+
<TextInput
312+
defaultValue="What banana?"
313+
/>
314+
<TextInput
315+
defaultValue="hello"
316+
value=""
317+
/>
318+
<View
319+
accessibilityState={
320+
{
321+
"busy": undefined,
322+
"checked": undefined,
323+
"disabled": undefined,
324+
"expanded": undefined,
325+
"selected": undefined,
326+
}
327+
}
328+
accessibilityValue={
329+
{
330+
"max": undefined,
331+
"min": undefined,
332+
"now": undefined,
333+
"text": undefined,
334+
}
335+
}
336+
accessible={true}
337+
collapsable={false}
338+
focusable={true}
339+
onBlur={[Function onBlur]}
340+
onClick={[Function onClick]}
341+
onFocus={[Function onFocus]}
342+
onResponderGrant={[Function onResponderGrant]}
343+
onResponderMove={[Function onResponderMove]}
344+
onResponderRelease={[Function onResponderRelease]}
345+
onResponderTerminate={[Function onResponderTerminate]}
346+
onResponderTerminationRequest={[Function onResponderTerminationRequest]}
347+
onStartShouldSetResponder={[Function onStartShouldSetResponder]}
348+
role="button"
349+
>
350+
<Text>
351+
Change freshness!
352+
</Text>
353+
</View>
354+
<Text
355+
testID="duplicateText"
356+
>
357+
First Text
358+
</Text>
359+
<Text
360+
testID="duplicateText"
361+
>
362+
Second Text
363+
</Text>
364+
<Text>
365+
0
366+
</Text>
367+
</View>"
368+
`;
369+
370+
exports[`debug: shallow 1`] = `
371+
"another custom message
372+
373+
"
374+
`;
375+
376+
exports[`debug: with message 1`] = `
377+
"my custom message
378+
379+
<View>
380+
<Text>
381+
Is the banana fresh?
382+
</Text>
383+
<Text
384+
testID="bananaFresh"
385+
>
386+
not fresh
387+
</Text>
388+
<TextInput
389+
placeholder="Add custom freshness"
390+
testID="bananaCustomFreshness"
391+
value="Custom Freshie"
392+
/>
393+
<TextInput
394+
defaultValue="What did you inspect?"
395+
placeholder="Who inspected freshness?"
396+
testID="bananaChef"
397+
value="I inspected freshie"
398+
/>
399+
<TextInput
400+
defaultValue="What banana?"
401+
/>
402+
<TextInput
403+
defaultValue="hello"
404+
value=""
405+
/>
406+
<View
407+
accessibilityState={
408+
{
409+
"busy": undefined,
410+
"checked": undefined,
411+
"disabled": undefined,
412+
"expanded": undefined,
413+
"selected": undefined,
414+
}
415+
}
416+
accessibilityValue={
417+
{
418+
"max": undefined,
419+
"min": undefined,
420+
"now": undefined,
421+
"text": undefined,
422+
}
423+
}
424+
accessible={true}
425+
collapsable={false}
426+
focusable={true}
427+
onBlur={[Function onBlur]}
428+
onClick={[Function onClick]}
429+
onFocus={[Function onFocus]}
430+
onResponderGrant={[Function onResponderGrant]}
431+
onResponderMove={[Function onResponderMove]}
432+
onResponderRelease={[Function onResponderRelease]}
433+
onResponderTerminate={[Function onResponderTerminate]}
434+
onResponderTerminationRequest={[Function onResponderTerminationRequest]}
435+
onStartShouldSetResponder={[Function onStartShouldSetResponder]}
436+
role="button"
437+
>
438+
<Text>
439+
Change freshness!
440+
</Text>
441+
</View>
442+
<Text
443+
testID="duplicateText"
444+
>
445+
First Text
446+
</Text>
447+
<Text
448+
testID="duplicateText"
449+
>
450+
Second Text
451+
</Text>
452+
<Text>
453+
0
454+
</Text>
455+
</View>"
456+
`;

src/__tests__/config.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { getConfig, configure, resetToDefaults, configureInternal } from '../config';
22

3+
beforeEach(() => {
4+
resetToDefaults();
5+
});
6+
37
test('getConfig() returns existing configuration', () => {
48
expect(getConfig().asyncUtilTimeout).toEqual(1000);
59
expect(getConfig().defaultIncludeHiddenElements).toEqual(false);

src/__tests__/render-debug.test.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
/* eslint-disable jest/no-conditional-expect */
12
/* eslint-disable no-console */
23
import * as React from 'react';
34
import { Pressable, Text, TextInput, View } from 'react-native';
45
import stripAnsi from 'strip-ansi';
56
import { configure, fireEvent, render, screen } from '..';
7+
import { getConfig } from '../config';
68

79
const PLACEHOLDER_FRESHNESS = 'Add custom freshness';
810
const PLACEHOLDER_CHEF = 'Who inspected freshness?';
@@ -97,16 +99,23 @@ test('debug', () => {
9799

98100
screen.debug();
99101
screen.debug('my custom message');
100-
screen.debug.shallow();
101-
screen.debug.shallow('my other custom message');
102+
if (getConfig().renderer !== 'internal') {
103+
screen.debug.shallow();
104+
screen.debug.shallow('my other custom message');
105+
}
106+
102107
screen.debug({ message: 'another custom message' });
103108

104109
const mockCalls = jest.mocked(console.log).mock.calls;
105110
expect(stripAnsi(mockCalls[0][0])).toMatchSnapshot();
106111
expect(stripAnsi(mockCalls[1][0] + mockCalls[1][1])).toMatchSnapshot('with message');
107-
expect(stripAnsi(mockCalls[2][0])).toMatchSnapshot('shallow');
108-
expect(stripAnsi(mockCalls[3][0] + mockCalls[3][1])).toMatchSnapshot('shallow with message');
109-
expect(stripAnsi(mockCalls[4][0] + mockCalls[4][1])).toMatchSnapshot('another custom message');
112+
if (getConfig().renderer !== 'internal') {
113+
expect(stripAnsi(mockCalls[2][0])).toMatchSnapshot('shallow');
114+
expect(stripAnsi(mockCalls[3][0] + mockCalls[3][1])).toMatchSnapshot('shallow with message');
115+
expect(stripAnsi(mockCalls[4][0] + mockCalls[4][1])).toMatchSnapshot('another custom message');
116+
} else {
117+
expect(stripAnsi(mockCalls[2][0] + mockCalls[2][1])).toMatchSnapshot('another custom message');
118+
}
110119

111120
const mockWarnCalls = jest.mocked(console.warn).mock.calls;
112121
expect(mockWarnCalls[0]).toEqual([

0 commit comments

Comments
 (0)