Skip to content

Commit ebb97ee

Browse files
committed
test: fix webview, signature unit test
1 parent 3c3afd2 commit ebb97ee

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

packages/pluggableWidgets/signature-native/src/__tests__/Signature.android.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import { fireEvent, render } from "@testing-library/react-native";
66
import { Signature, Props } from "../Signature";
77
import { actionValue, dynamicValue, EditableValueBuilder } from "@mendix/piw-utils-internal";
88

9+
jest.mock("react-native", () => {
10+
const RN = jest.requireActual("react-native");
11+
RN.NativeModules.RNCWebView = { isFileUploadSupported: jest.fn(() => true) };
12+
return RN;
13+
});
14+
915
jest.mock("react-native/Libraries/Utilities/Platform", () => {
1016
const Platform = jest.requireActual("react-native/Libraries/Utilities/Platform");
1117
Platform.OS = "android";

packages/pluggableWidgets/signature-native/src/__tests__/Signature.ios.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { fireEvent, render } from "@testing-library/react-native";
55
import { Signature, Props } from "../Signature";
66
import { actionValue, dynamicValue, EditableValueBuilder } from "@mendix/piw-utils-internal";
77

8+
jest.mock("react-native", () => {
9+
const RN = jest.requireActual("react-native");
10+
RN.NativeModules.RNCWebView = { isFileUploadSupported: jest.fn(() => true) };
11+
return RN;
12+
});
13+
814
jest.mock("react-native/Libraries/Utilities/Platform", () => {
915
const Platform = jest.requireActual("react-native/Libraries/Utilities/Platform");
1016
Platform.OS = "ios";

packages/pluggableWidgets/signature-native/src/__tests__/__snapshots__/Signature.android.spec.tsx.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ exports[`Signature Android renders with custom styles 1`] = `
4444
javaScriptEnabled={true}
4545
messagingEnabled={true}
4646
messagingModuleName="WebViewMessageHandler2"
47-
onError={[Function]}
47+
nestedScrollEnabled={false}
4848
onHttpError={[Function]}
49-
onLoadEnd={[Function]}
5049
onLoadingError={[Function]}
5150
onLoadingFinish={[Function]}
5251
onLoadingProgress={[Function]}
@@ -57,6 +56,8 @@ exports[`Signature Android renders with custom styles 1`] = `
5756
overScrollMode="always"
5857
saveFormDataDisabled={false}
5958
scalesPageToFit={true}
59+
setBuiltInZoomControls={true}
60+
setDisplayZoomControls={false}
6061
setSupportMultipleWindows={true}
6162
source={
6263
{
@@ -1153,9 +1154,8 @@ exports[`Signature Android renders with default styles 1`] = `
11531154
javaScriptEnabled={true}
11541155
messagingEnabled={true}
11551156
messagingModuleName="WebViewMessageHandler1"
1156-
onError={[Function]}
1157+
nestedScrollEnabled={false}
11571158
onHttpError={[Function]}
1158-
onLoadEnd={[Function]}
11591159
onLoadingError={[Function]}
11601160
onLoadingFinish={[Function]}
11611161
onLoadingProgress={[Function]}
@@ -1166,6 +1166,8 @@ exports[`Signature Android renders with default styles 1`] = `
11661166
overScrollMode="always"
11671167
saveFormDataDisabled={false}
11681168
scalesPageToFit={true}
1169+
setBuiltInZoomControls={true}
1170+
setDisplayZoomControls={false}
11691171
setSupportMultipleWindows={true}
11701172
source={
11711173
{

packages/pluggableWidgets/signature-native/src/__tests__/__snapshots__/Signature.ios.spec.tsx.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ exports[`Signature iOS renders with custom styles 1`] = `
4444
javaScriptEnabled={true}
4545
messagingEnabled={true}
4646
messagingModuleName="WebViewMessageHandler2"
47-
onError={[Function]}
47+
nestedScrollEnabled={false}
4848
onHttpError={[Function]}
49-
onLoadEnd={[Function]}
5049
onLoadingError={[Function]}
5150
onLoadingFinish={[Function]}
5251
onLoadingProgress={[Function]}
@@ -57,6 +56,8 @@ exports[`Signature iOS renders with custom styles 1`] = `
5756
overScrollMode="always"
5857
saveFormDataDisabled={false}
5958
scalesPageToFit={true}
59+
setBuiltInZoomControls={true}
60+
setDisplayZoomControls={false}
6061
setSupportMultipleWindows={true}
6162
source={
6263
{
@@ -1147,9 +1148,8 @@ exports[`Signature iOS renders with default styles 1`] = `
11471148
javaScriptEnabled={true}
11481149
messagingEnabled={true}
11491150
messagingModuleName="WebViewMessageHandler1"
1150-
onError={[Function]}
1151+
nestedScrollEnabled={false}
11511152
onHttpError={[Function]}
1152-
onLoadEnd={[Function]}
11531153
onLoadingError={[Function]}
11541154
onLoadingFinish={[Function]}
11551155
onLoadingProgress={[Function]}
@@ -1160,6 +1160,8 @@ exports[`Signature iOS renders with default styles 1`] = `
11601160
overScrollMode="always"
11611161
saveFormDataDisabled={false}
11621162
scalesPageToFit={true}
1163+
setBuiltInZoomControls={true}
1164+
setDisplayZoomControls={false}
11631165
setSupportMultipleWindows={true}
11641166
source={
11651167
{

packages/pluggableWidgets/web-view-native/src/__tests__/WebView.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { WebView as RNWebView } from "react-native-webview";
55

66
import { Props, WebView } from "../WebView";
77

8+
jest.mock("react-native", () => {
9+
const RN = jest.requireActual("react-native");
10+
RN.NativeModules.RNCWebView = { isFileUploadSupported: jest.fn(() => true) };
11+
return RN;
12+
});
13+
814
describe("WebView", () => {
915
let defaultProps: Props;
1016

packages/pluggableWidgets/web-view-native/src/__tests__/__snapshots__/WebView.spec.tsx.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ exports[`WebView renders a web view when a url is provided 1`] = `
3131
javaScriptEnabled={true}
3232
messagingEnabled={true}
3333
messagingModuleName="WebViewMessageHandler1"
34-
onError={[Function]}
34+
nestedScrollEnabled={false}
3535
onHttpError={[Function]}
36-
onLoad={[Function]}
3736
onLoadingError={[Function]}
3837
onLoadingFinish={[Function]}
3938
onLoadingProgress={[Function]}
@@ -44,6 +43,8 @@ exports[`WebView renders a web view when a url is provided 1`] = `
4443
overScrollMode="always"
4544
saveFormDataDisabled={false}
4645
scalesPageToFit={true}
46+
setBuiltInZoomControls={true}
47+
setDisplayZoomControls={false}
4748
setSupportMultipleWindows={true}
4849
source={
4950
{
@@ -103,9 +104,8 @@ exports[`WebView renders a web view when html content is provided 1`] = `
103104
javaScriptEnabled={true}
104105
messagingEnabled={true}
105106
messagingModuleName="WebViewMessageHandler2"
106-
onError={[Function]}
107+
nestedScrollEnabled={false}
107108
onHttpError={[Function]}
108-
onLoad={[Function]}
109109
onLoadingError={[Function]}
110110
onLoadingFinish={[Function]}
111111
onLoadingProgress={[Function]}
@@ -116,6 +116,8 @@ exports[`WebView renders a web view when html content is provided 1`] = `
116116
overScrollMode="always"
117117
saveFormDataDisabled={false}
118118
scalesPageToFit={true}
119+
setBuiltInZoomControls={true}
120+
setDisplayZoomControls={false}
119121
setSupportMultipleWindows={true}
120122
source={
121123
{

0 commit comments

Comments
 (0)