mediawiki-extensions-Relate.../tests/qunit/CardView.test.js

30 lines
822 B
JavaScript
Raw Normal View History

( function () {
'use strict';
var CardModel = require( '../../resources/ext.relatedArticles.cards/CardModel.js' ),
CardView = require( '../../resources/ext.relatedArticles.cards/CardView.js' );
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\");"
);
} );
}() );