mediawiki-extensions-Relate.../tests/qunit/CardModel.test.js
Jon Robson 911d78e8ee [organization] organize file by module
Follow up to I9442b0336e22ca795cc06f76068215266fe81271

Bug: T306228
Change-Id: Ifb1f1937009b098999471cfa5e820a063dc5a4a0
2022-04-18 08:37:22 -07:00

36 lines
925 B
JavaScript

( function () {
'use strict';
var CardModel = require( '../../resources/ext.relatedArticles.readMore/CardModel.js' );
QUnit.module( 'ext.relatedArticles.cards/CardModel' );
QUnit.test( '#set', 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', 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.' );
} );
}() );