diff --git a/src/_h5ai/client/js/inc/ext/filter.js b/src/_h5ai/client/js/inc/ext/filter.js index 4639dac7..84fe90ad 100644 --- a/src/_h5ai/client/js/inc/ext/filter.js +++ b/src/_h5ai/client/js/inc/ext/filter.js @@ -43,7 +43,7 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re $filter.removeClass('pending'); view.setHint('noMatch'); - view.setItems('filter', matchedItems); + view.setItems(matchedItems); } function update() { diff --git a/src/_h5ai/client/js/inc/ext/search.js b/src/_h5ai/client/js/inc/ext/search.js index 997c4784..f91fa634 100644 --- a/src/_h5ai/client/js/inc/ext/search.js +++ b/src/_h5ai/client/js/inc/ext/search.js @@ -41,7 +41,7 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re $search.removeClass('pending'); view.setHint('noMatch'); - view.setItems('search', _.map(response.search, function (item) { + view.setItems(_.map(response.search, function (item) { return Item.get(item); })); diff --git a/src/_h5ai/client/js/inc/view/view.js b/src/_h5ai/client/js/inc/view/view.js index 1052c752..5aaa299a 100644 --- a/src/_h5ai/client/js/inc/view/view.js +++ b/src/_h5ai/client/js/inc/view/view.js @@ -84,7 +84,7 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat event.pub('item.mouseleave', item); } - function setItems(context, items) { + function setItems(items) { var removed = _.map($items.find('.item'), function (item) { @@ -103,7 +103,7 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat event.pub('view.changed', items, removed); } - function changeItems(context, add, remove) { + function changeItems(add, remove) { _.each(add, function (item) { @@ -158,7 +158,7 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat }); setHint('empty'); - setItems('location.changed', items); + setItems(items); } function onLocationRefreshed(item, added, removed) { @@ -173,7 +173,7 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat }); setHint('empty'); - changeItems('location.refreshed', add, removed); + changeItems(add, removed); } function init() { diff --git a/test/tests/unit/view/notification.js b/test/tests/unit/view/notification.js index 7a07c88d..f3208be2 100644 --- a/test/tests/unit/view/notification.js +++ b/test/tests/unit/view/notification.js @@ -96,7 +96,7 @@ describe('module \'' + ID + '\'', function () { it('is function', function () { var instance = this.applyFn(); - assert.ok(_.isFunction(instance.set)); + assert.isTrue(_.isFunction(instance.set)); }); it('works', function () { diff --git a/test/tests/unit/view/view.js b/test/tests/unit/view/view.js index 2f34be32..8113fcb5 100644 --- a/test/tests/unit/view/view.js +++ b/test/tests/unit/view/view.js @@ -26,6 +26,9 @@ describe('module \'' + ID + '\'', function () { icon: sinon.stub().returns(util.uniqId()) }; this.xSettings = {view: { + binaryPrefix: false, + hideFolders: false, + hideParentFolder: false, setParentFolderLabels: false }}; this.xContent = {$el: null}; @@ -109,6 +112,12 @@ describe('module \'' + ID + '\'', function () { assert.lengthOf($('#view > #items'), 1); }); + it('adds HTML #view-hint to #view', function () { + + this.applyFn(); + assert.lengthOf($('#view > #view-hint'), 1); + }); + it('sets default metric', function () { this.applyFn(); @@ -165,7 +174,15 @@ describe('module \'' + ID + '\'', function () { it('is function', function () { var instance = this.applyFn(); - assert.ok(_.isFunction(instance.setItems)); + assert.isTrue(_.isFunction(instance.setItems)); + }); + + it('publishes view.changed', function () { + + var instance = this.applyFn(); + instance.setItems(); + assert.isTrue(this.xEvent.pub.calledOnce); + assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed'); }); }); @@ -174,7 +191,7 @@ describe('module \'' + ID + '\'', function () { it('is function', function () { var instance = this.applyFn(); - assert.ok(_.isFunction(instance.changeItems)); + assert.isTrue(_.isFunction(instance.changeItems)); }); }); @@ -183,7 +200,7 @@ describe('module \'' + ID + '\'', function () { it('is function', function () { var instance = this.applyFn(); - assert.ok(_.isFunction(instance.setLocation)); + assert.isTrue(_.isFunction(instance.setLocation)); }); }); @@ -192,7 +209,24 @@ describe('module \'' + ID + '\'', function () { it('is function', function () { var instance = this.applyFn(); - assert.ok(_.isFunction(instance.setHint)); + assert.isTrue(_.isFunction(instance.setHint)); + }); + + it('sets correct class to #view-hint', function () { + + var key = util.uniqId(); + var instance = this.applyFn(); + instance.setHint(key); + assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key); + }); + + it('removes all other classes from #view-hint', function () { + + var key = util.uniqId(); + var instance = this.applyFn(); + $('#view-hint').addClass('a'); + instance.setHint(key); + assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key); }); });