Skip to content

Commit

Permalink
Mock Animated View to prevent out of memory error when a ref is set
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanregisser committed Dec 22, 2020
1 parent 3c502ce commit a555521
Show file tree
Hide file tree
Showing 18 changed files with 1,046 additions and 879 deletions.
9 changes: 9 additions & 0 deletions packages/mobile/jest_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ afterEach(cleanup)

// Mock LayoutAnimation as it's done not automatically
jest.mock('react-native/Libraries/LayoutAnimation/LayoutAnimation.js')

// Mock Animated Views this way otherwise we get a
// `JavaScript heap out of memory` error when a ref is set (?!)
// See https://github.com/callstack/react-native-testing-library/issues/539
jest.mock('react-native/Libraries/Animated/src/components/AnimatedView.js', () => 'View')
jest.mock(
'react-native/Libraries/Animated/src/components/AnimatedScrollView.js',
() => 'RCTScrollView'
)
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ exports[`FiatExchange renders correctly 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"opacity": 1,
"padding": 0,
"position": "absolute",
}
Array [
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"padding": 0,
"position": "absolute",
},
Object {
"opacity": 1,
},
]
}
testID="Hamburguer"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ exports[`renders correctly 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"opacity": 1,
"padding": 0,
"position": "absolute",
}
Array [
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"padding": 0,
"position": "absolute",
},
Object {
"opacity": 1,
},
]
}
testID="Hamburguer"
>
Expand Down
135 changes: 86 additions & 49 deletions packages/mobile/src/account/__snapshots__/Settings.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ exports[`Account renders correctly 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"opacity": 1,
"padding": 0,
"position": "absolute",
}
Array [
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"padding": 0,
"position": "absolute",
},
Object {
"opacity": 1,
},
]
}
testID="Hamburguer"
>
Expand Down Expand Up @@ -2297,14 +2301,18 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"opacity": 1,
"padding": 0,
"position": "absolute",
}
Array [
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"padding": 0,
"position": "absolute",
},
Object {
"opacity": 1,
},
]
}
testID="Hamburguer"
>
Expand Down Expand Up @@ -3349,10 +3357,14 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
"width": 215,
}
Array [
Object {
"width": 215,
},
Object {
"opacity": 1,
},
]
}
>
<Text
Expand Down Expand Up @@ -3388,9 +3400,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand All @@ -3417,9 +3432,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand All @@ -3446,9 +3464,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand All @@ -3475,9 +3496,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand All @@ -3504,9 +3528,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand All @@ -3533,9 +3560,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand All @@ -3562,9 +3592,12 @@ exports[`Account renders correctly when dev mode active 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
Array [
undefined,
Object {
"opacity": 1,
},
]
}
>
<Text>
Expand Down Expand Up @@ -4818,14 +4851,18 @@ exports[`Account renders correctly when verification is not possible 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"opacity": 1,
"padding": 0,
"position": "absolute",
}
Array [
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"padding": 0,
"position": "absolute",
},
Object {
"opacity": 1,
},
]
}
testID="Hamburguer"
>
Expand Down
20 changes: 12 additions & 8 deletions packages/mobile/src/account/__snapshots__/Support.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ exports[`Support renders correctly 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"opacity": 1,
"padding": 0,
"position": "absolute",
}
Array [
Object {
"left": 0,
"marginBottom": 0,
"marginLeft": 16,
"padding": 0,
"position": "absolute",
},
Object {
"opacity": 1,
},
]
}
testID="Hamburguer"
>
Expand Down

0 comments on commit a555521

Please sign in to comment.