Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] File Block VI-a: Implementing unit tests #27225

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions packages/block-library/src/file/test/__snapshots__/edit.native.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`File block renders file without crashing 1`] = `
<View
pointerEvents="box-none"
>
<View>
Modal
<View>
<RCTAztecView
accessible={true}
activeFormats={Array []}
blockType={
Object {
"tag": "p",
}
}
deleteEnter={true}
disableEditingMenu={false}
focusable={true}
fontFamily="serif"
isMultiline={false}
maxImagesWidth={200}
onBackspace={[Function]}
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onContentSizeChange={[Function]}
onEnter={[Function]}
onFocus={[Function]}
onHTMLContentWithCursor={[Function]}
onKeyDown={[Function]}
onPaste={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onSelectionChange={[Function]}
onStartShouldSetResponder={[Function]}
placeholder="File name"
placeholderTextColor="gray"
style={
Object {
"backgroundColor": undefined,
"maxWidth": undefined,
"minHeight": 0,
}
}
text={
Object {
"eventCount": undefined,
"linkTextColor": undefined,
"selection": null,
"text": "<p >File name</p>",
}
}
textAlign="left"
triggerKeyCodes={Array []}
/>
</View>
<View
style={
Array [
Object {},
Object {
"alignSelf": "flex-start",
},
]
}
>
<TextInput
allowFontScaling={true}
fontFamily="serif"
onChange={[Function]}
rejectResponderTermination={true}
scrollEnabled={false}
style={
Object {
"fontFamily": "serif",
}
}
underlineColorAndroid="transparent"
value="Download"
/>
</View>
</View>
</View>
`;

exports[`File block renders placeholder without crashing 1`] = `
<View
style={
Object {
"flex": 1,
}
}
>
<View
accessibilityHint="Double tap to select"
accessibilityLabel="File block. Empty"
accessibilityRole="button"
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Array [
undefined,
undefined,
undefined,
],
undefined,
]
}
>
Modal
<View
style={
Object {
"fill": "gray",
}
}
>
<View
style={Object {}}
>
Svg
</View>
</View>
<Text>
File
</Text>
<Text>
CHOOSE A FILE
</Text>
</View>
</View>
`;
42 changes: 42 additions & 0 deletions packages/block-library/src/file/test/edit.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* External dependencies
*/
import renderer from 'react-test-renderer';

/**
* Internal dependencies
*/
import { FileEdit } from '../edit.native.js';

const getTestComponentWithContent = ( attributes = {} ) => {
return renderer.create(
<FileEdit
attributes={ attributes }
setAttributes={ jest.fn() }
getMedia={ jest.fn() }
getStylesFromColorScheme={ jest.fn() }
/>
);
};

describe( 'File block', () => {
it( 'renders placeholder without crashing', () => {
const component = getTestComponentWithContent();
const rendered = component.toJSON();
expect( rendered ).toMatchSnapshot();
} );

it( 'renders file without crashing', () => {
const component = getTestComponentWithContent( {
showDownloadButton: true,
downloadButtonText: 'Download',
href: 'https://wordpress.org/latest.zip',
fileName: 'File name',
textLinkHref: 'https://wordpress.org/latest.zip',
id: '1',
} );

const rendered = component.toJSON();
expect( rendered ).toMatchSnapshot();
} );
} );