Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/315533
Change subject: [wip] Add ModelManager qunit tests ...................................................................... [wip] Add ModelManager qunit tests Change-Id: I78e621bbeaaf1edef95dbfe550d1fbc6df9c311e --- A tests/qunit/model/test_mw.echo.dm.ModelManager.js 1 file changed, 74 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/33/315533/1 diff --git a/tests/qunit/model/test_mw.echo.dm.ModelManager.js b/tests/qunit/model/test_mw.echo.dm.ModelManager.js new file mode 100644 index 0000000..2807b73 --- /dev/null +++ b/tests/qunit/model/test_mw.echo.dm.ModelManager.js @@ -0,0 +1,74 @@ +( function ( mw, $ ) { + + QUnit.module( 'ext.echo.dm - mw.echo.dm.ModelManager' ); + + QUnit.test( 'Constructing the model', function ( assert ) { + var model = new mw.echo.dm.ModelManager( + new mw.echo.dm.UnreadNotificationCounter( null, 'alert', 100 ) + ); + + assert.ok( + model.getUnreadCounter() instanceof mw.echo.dm.UnreadNotificationCounter, + 'Unread counter stored' + ); + assert.ok( + model.getLocalCounter() instanceof mw.echo.dm.UnreadNotificationCounter, + 'Local unread counter created' + ); + assert.ok( + model.getFiltersModel() instanceof mw.echo.dm.FiltersModel, + 'Filters model created' + ); + assert.ok( + model.getPaginationModel() instanceof mw.echo.dm.PaginationModel, + 'Pagination model created' + ); + assert.ok( + model.getSeenTimeModel() instanceof mw.echo.dm.SeenTimeModel, + 'SeenTime model created' + ); + } ); + + QUnit.test( 'Managing notification models', function ( assert ) { + var i, + manager = new mw.echo.dm.ModelManager( + new mw.echo.dm.UnreadNotificationCounter( null, 'alert', 100 ) + ), + notifListModel = new mw.echo.dm.NotificationsList( { modelName: 'notifList' } ), + xwikiModel = new mw.echo.dm.CrossWikiNotificationItem( -1, { modelName: 'xwiki', count: 8 } ), + bundleModel = new mw.echo.dm.BundleNotificationItem( 99, [ + new mw.echo.dm.NotificationItem( 0, { read: false, seen: false, timestamp: '201601010000' } ), + new mw.echo.dm.NotificationItem( 1, { read: false, seen: false, timestamp: '201601010100' } ), + new mw.echo.dm.NotificationItem( 2, { read: false, seen: true, timestamp: '201601010200' } ), + new mw.echo.dm.NotificationItem( 3, { read: false, seen: true, timestamp: '201601010300' } ), + new mw.echo.dm.NotificationItem( 4, { read: false, seen: true, timestamp: '201601010400' } ) + ], { modelName: 'bundleItem' } ); + + manager.setNotificationModels( { + // Notifications list + notifList: notifListModel, + xwiki: xwikiModel, + localBundle: bundleModel + } ); + + assert.equal( + manager.getAllNotificationCount(), + 13,// 8 + 0 + 5 + 'Counting notification items from all models #1' + ); + + notifListModel.setItems( [ + new mw.echo.dm.NotificationItem( 10, { read: false, seen: false, timestamp: '201601010000' } ), + new mw.echo.dm.NotificationItem( 11, { read: false, seen: false, timestamp: '201601010000' } ), + new mw.echo.dm.NotificationItem( 12, { read: false, seen: false, timestamp: '201601010000' } ), + new mw.echo.dm.NotificationItem( 13, { read: false, seen: false, timestamp: '201601010000' } ), + ] ); + assert.equal( + manager.getAllNotificationCount(), + 17,// 4 + 8 + 5 + 'Counting notification items from all models #2' + ); + + } ); +} )( mediaWiki, jQuery ); + -- To view, visit https://gerrit.wikimedia.org/r/315533 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I78e621bbeaaf1edef95dbfe550d1fbc6df9c311e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits