-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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] Add 'Insert from URL' option to Image block #40334
Changes from 7 commits
e686dde
3b9afa3
cec7316
0b48a73
d56ab56
504eabf
d5394d0
8b79cf1
c660f75
760b9cf
b3312b9
badb6e1
ee5456b
0e647c1
4d33bb1
aede9d3
dbc6e23
07ee97d
7e8b6cb
7995ef9
344c340
ee61ccb
a43fce1
7b721c0
ae02763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,11 @@ import { | |
MEDIA_TYPE_IMAGE, | ||
MEDIA_TYPE_VIDEO, | ||
MEDIA_TYPE_AUDIO, | ||
OPTION_CHOOSE_FROM_DEVICE, | ||
OPTION_TAKE_VIDEO, | ||
OPTION_TAKE_PHOTO, | ||
OPTION_INSERT_FROM_URL, | ||
OPTION_WORDPRESS_MEDIA_LIBRARY, | ||
} from '../index'; | ||
|
||
const MEDIA_URL = 'http://host.media.type'; | ||
|
@@ -33,7 +35,7 @@ describe( 'MediaUpload component', () => { | |
expect( wrapper ).toBeTruthy(); | ||
} ); | ||
|
||
it( 'shows right media capture option for media type', () => { | ||
describe( 'Media capture options for different media block types', () => { | ||
const expectOptionForMediaType = ( mediaType, expectedOption ) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name of the function references the word
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an additional note, I noticed that the second argument's name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good callout on making
I think this is a good callout as well. To be honest, I wasn't sure if passing the text strings as an array to
What do you think about this approach @fluiddot ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't have a strong opinion on whether having that function accepts one option or multiple 🤔 . Regarding this function, my gut feeling is that the logic could be eventually moved to a generic helper, as it's likely to be used on other test cases. So, in that case, I'd advocate having the one option only so we keep the helper simple, and then let the test cases handle the multiple options case. I think it might even help with the readability of the tests.
I think that's a good approach 👍. The only thing I'd like to mention is that if we use |
||
const wrapper = render( | ||
<MediaUpload | ||
|
@@ -52,11 +54,33 @@ describe( 'MediaUpload component', () => { | |
); | ||
fireEvent.press( wrapper.getByText( 'Open Picker' ) ); | ||
|
||
wrapper.getByText( expectedOption ); | ||
wrapper.findByText( expectedOption ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think part of the failures in the unit tests is related to this line, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated |
||
}; | ||
expectOptionForMediaType( MEDIA_TYPE_IMAGE, OPTION_TAKE_PHOTO ); | ||
expectOptionForMediaType( MEDIA_TYPE_VIDEO, OPTION_TAKE_VIDEO ); | ||
expectOptionForMediaType( MEDIA_TYPE_AUDIO, OPTION_INSERT_FROM_URL ); | ||
|
||
it( 'shows the correct media capture options for the Image block', () => { | ||
expectOptionForMediaType( MEDIA_TYPE_IMAGE, [ | ||
OPTION_CHOOSE_FROM_DEVICE, | ||
OPTION_TAKE_PHOTO, | ||
OPTION_WORDPRESS_MEDIA_LIBRARY, | ||
OPTION_INSERT_FROM_URL, | ||
] ); | ||
} ); | ||
|
||
it( 'shows the correct media capture options for the Video block', () => { | ||
expectOptionForMediaType( MEDIA_TYPE_VIDEO, [ | ||
OPTION_CHOOSE_FROM_DEVICE, | ||
OPTION_TAKE_VIDEO, | ||
OPTION_WORDPRESS_MEDIA_LIBRARY, | ||
OPTION_INSERT_FROM_URL, | ||
] ); | ||
} ); | ||
|
||
it( 'shows the correct media capture options for the Audio block', () => { | ||
expectOptionForMediaType( MEDIA_TYPE_AUDIO, [ | ||
OPTION_WORDPRESS_MEDIA_LIBRARY, | ||
OPTION_INSERT_FROM_URL, | ||
] ); | ||
} ); | ||
} ); | ||
|
||
const expectMediaPickerForOption = ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that this constant is not used anywhere although is exported. Not a big issue but I was wondering if it was added for a different purpose 🤔 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I had added it for a test case that ended up not being used, so I agree that it could be removed. 👍