mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-12-12 16:45:15 +00:00
6dee0147f4
* Move across all files * Rename ext-card- prefix to ext-related-articles- prefix ** Since all code using these prefixes is JS we do not have to worry about cached HTML Bug: T137021 Change-Id: I784fd132c36329fa0dcc49fe2804460061940347
36 lines
879 B
JavaScript
36 lines
879 B
JavaScript
( function () {
|
|
'use strict';
|
|
|
|
var CardModel = mw.cards.CardModel;
|
|
|
|
QUnit.module( 'ext.relatedArticles.cards/CardModel' );
|
|
|
|
QUnit.test( '#set', 1, function ( assert ) {
|
|
var model = new CardModel( {} );
|
|
|
|
model.on( 'change', function ( attributes ) {
|
|
assert.strictEqual(
|
|
attributes.foo,
|
|
'bar',
|
|
'It emits an event with the attribute that has changed.'
|
|
);
|
|
} );
|
|
model.set( 'foo', 'bar' );
|
|
|
|
model = new CardModel( {} );
|
|
model.on( 'change', function () {
|
|
assert.ok( false, 'It doesn\'t emit an event when silenced.' );
|
|
} );
|
|
|
|
model.set( 'foo', 'bar', true );
|
|
} );
|
|
|
|
QUnit.test( '#get', 2, function ( assert ) {
|
|
var model = new CardModel( {} );
|
|
|
|
model.set( 'foo', 'bar' );
|
|
assert.strictEqual( model.get( 'foo' ), 'bar', 'Got the correct value.' );
|
|
assert.strictEqual( model.get( 'x' ), undefined, 'Got the correct value.' );
|
|
} );
|
|
}() );
|