mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-12-19 11:30:44 +00:00
1a4bd424b4
Avoid loose assertion Change-Id: I6fd398ef2608c836fd59e0a48271f11c5e0d78a9
36 lines
931 B
JavaScript
36 lines
931 B
JavaScript
( function () {
|
|
'use strict';
|
|
|
|
const CardModel = require( '../../resources/ext.relatedArticles.readMore/CardModel.js' );
|
|
|
|
QUnit.module( 'ext.relatedArticles.cards/CardModel' );
|
|
|
|
QUnit.test( '#set', function ( assert ) {
|
|
let 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.true( false, 'It doesn\'t emit an event when silenced.' );
|
|
} );
|
|
|
|
model.set( 'foo', 'bar', true );
|
|
} );
|
|
|
|
QUnit.test( '#get', function ( assert ) {
|
|
const 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.' );
|
|
} );
|
|
}() );
|