mediawiki-extensions-Relate.../tests/qunit/ext.relatedArticles.cards/CardView.test.js
Jan Drewniak fcd4d1a272 Hygiene: Followup from 191fc2a
pass a collection of jQuery objects to `.append` instead of
and array.

Use `.css` instead of `.attr` to set thumbnail background image.

Change a unit to reflect the escaping pattern of the `.css` method

Bug: T219846
Change-Id: I6359be2db6c7c7a8e4b52296e0801d4ded921b46
2019-05-01 22:28:47 +02:00

30 lines
724 B
JavaScript

( function () {
'use strict';
var CardModel = mw.cards.CardModel,
CardView = mw.cards.CardView;
QUnit.module( 'ext.relatedArticles.cards/CardView' );
QUnit.test( '#_render escapes the thumbnailUrl model attribute', function ( assert ) {
var model = new CardModel( {
title: 'One',
url: mw.util.getUrl( 'One' ),
hasThumbnail: true,
thumbnailUrl: 'http://foo.bar/\');display:none;"//baz.jpg',
isThumbnailProtrait: false
} ),
view = new CardView( model ),
style;
style = view.$el.find( '.ext-related-articles-card-thumb' )
.eq( 0 )
.attr( 'style' );
assert.strictEqual(
style,
"background-image: url(\"http://foo.bar/');display:none;\\\"//baz.jpg\");"
);
} );
}() );