2017-06-06 23:38:57 +00:00
|
|
|
( function () {
|
|
|
|
'use strict';
|
|
|
|
|
2022-04-14 23:11:07 +00:00
|
|
|
var CardModel = require( '../../resources/ext.relatedArticles.cards/CardModel.js' );
|
2017-06-06 23:38:57 +00:00
|
|
|
|
|
|
|
QUnit.module( 'ext.relatedArticles.cards/CardModel' );
|
|
|
|
|
2017-09-01 15:16:31 +00:00
|
|
|
QUnit.test( '#set', function ( assert ) {
|
2017-06-06 23:38:57 +00:00
|
|
|
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 );
|
|
|
|
} );
|
|
|
|
|
2017-09-01 15:16:31 +00:00
|
|
|
QUnit.test( '#get', function ( assert ) {
|
2017-06-06 23:38:57 +00:00
|
|
|
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.' );
|
|
|
|
} );
|
|
|
|
}() );
|