jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/394652 )
Change subject: Media: Unit testing for metadata and derivatives parsing ...................................................................... Media: Unit testing for metadata and derivatives parsing Bug: T177430 Change-Id: I8cf8764fc60cf8a85fa847ca3ada16a1fa6fa094 --- M test/lib/media/media-test.js 1 file changed, 58 insertions(+), 0 deletions(-) Approvals: BearND: Looks good to me, approved jenkins-bot: Verified diff --git a/test/lib/media/media-test.js b/test/lib/media/media-test.js index 9417069..5e65504 100644 --- a/test/lib/media/media-test.js +++ b/test/lib/media/media-test.js @@ -36,6 +36,35 @@ const validItems = images.concat(videos).concat(audio); const invalidItems = [noTypeFigure, noTypeSpan, noTypeFigureInline]; +const imageWithCaption = + '<figure typeof="mw:Image">' + + '<img resource="./File:Foo"/>' + + '<figcaption>An <i>example</i> image</figcaption>' + + '</figure>'; + +const videoWithMetadata = + '<figure typeof="mw:Video" data-mw=\'{"starttime": "1", "thumbtime": "2", "endtime": "3"}\'>' + + '<video resource="./File:Foo"/>' + + '</figure>'; + +const videoWithDerivative = + '<figure typeof="mw:Video">' + + '<video resource="./File:Foo">' + + '<source src="https://example.com/Foo.ogv"' + + ' type=\'video/ogg; codecs="theora, vorbis"\'' + + ' data-title="Foo"' + + ' data-shorttitle="Foo"' + + ' data-file-width="120"' + + ' data-file-height="120"' + + '/>' + + '</video>' + + '</figure>'; + +const spokenWikipedia = + '<div id="section_SpokenWikipedia">' + + '<figure typeof="mw:Audio"><video resource="./File:Foo"/></figure>' + + '</div>'; + describe('lib:media', () => { it('items should be found for expected selectors', () => { @@ -54,4 +83,33 @@ assert.deepEqual(result.length, 0); }); + it('all expected captions are present', () => { + const result = media.getMediaItemInfoFromPage(imageWithCaption)[0]; + assert.deepEqual(result.caption_html, 'An <i>example</i> image'); + assert.deepEqual(result.caption_text, 'An example image'); + }); + + it('all expected data-mw properties are present', () => { + const result = media.getMediaItemInfoFromPage(videoWithMetadata)[0]; + assert.deepEqual(result.start_time, 1); + assert.deepEqual(result.thumb_time, 2); + assert.deepEqual(result.end_time, 3); + }); + + it('all expected derivative properties are present', () => { + const result = media.getMediaItemInfoFromPage(videoWithDerivative)[0]; + const derivative = result.derivatives[0]; + assert.deepEqual(derivative.src, 'https://example.com/Foo.ogv'); + assert.deepEqual(derivative.type, 'video/ogg; codecs="theora, vorbis"'); + assert.deepEqual(derivative.title, 'Foo'); + assert.deepEqual(derivative.short_title, 'Foo'); + assert.deepEqual(derivative.width, 120); + assert.deepEqual(derivative.height, 120); + }); + + it('spoken Wikipedia file is correctly identified', () => { + const result = media.getMediaItemInfoFromPage(spokenWikipedia)[0]; + assert.deepEqual(result.audio_type, 'spoken'); + }); + }); -- To view, visit https://gerrit.wikimedia.org/r/394652 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8cf8764fc60cf8a85fa847ca3ada16a1fa6fa094 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Mholloway <mhollo...@wikimedia.org> Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org> Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org> Gerrit-Reviewer: Mhurd <mh...@wikimedia.org> Gerrit-Reviewer: Ppchelko <ppche...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits