diff --git a/Tests/js/views/assets/ez-universaldiscoveryview-tests.js b/Tests/js/views/assets/ez-universaldiscoveryview-tests.js index 7d1d0eae1..a9d8be3eb 100644 --- a/Tests/js/views/assets/ez-universaldiscoveryview-tests.js +++ b/Tests/js/views/assets/ez-universaldiscoveryview-tests.js @@ -514,6 +514,9 @@ YUI.add('ez-universaldiscoveryview-tests', function (Y) { this.method2._set("identifier", "method2"); this.confirmedList = new Y.View(); + this.startingLocation = {}; + this.startingLocationId = '42'; + this.virtualRootLocation = {}; this.view = new Y.eZ.UniversalDiscoveryView({ container: '.container', @@ -563,6 +566,10 @@ YUI.add('ez-universaldiscoveryview-tests', function (Y) { var method2 = this.method2, method1 = this.method1; + this.view.set('startingLocation', this.startingLocation); + this.view.set('startingLocationId', this.startingLocationId); + this.view.set('virtualRootLocation', this.virtualRootLocation); + this.view.set('active', true); this.view.set('visibleMethod', 'method2'); @@ -572,15 +579,31 @@ YUI.add('ez-universaldiscoveryview-tests', function (Y) { ); Assert.isFalse( method1.get('visible'), - "The method2 should not be visible" + "The method1 should not be visible" + ); + + Assert.areSame( + method2.get('startingLocation'), this.startingLocation, + "method should have been updated with startingLocation" + ); + + Assert.areSame( + method2.get('startingLocationId'), this.startingLocationId, + "method should have been updated with startingLocationId" ); + + Assert.areSame( + method2.get('virtualRootLocation'), this.virtualRootLocation, + "method should have been updated with virtualRootLocation" + ); + Assert.isTrue( method2.get('multiple'), - "The method2 mutiple flag should be true" + "The method2 multiple flag should be true" ); Assert.isTrue( method1.get('multiple'), - "The method1 mutiple flag should be true" + "The method1 multiple flag should be true" ); }, @@ -683,6 +706,43 @@ YUI.add('ez-universaldiscoveryview-tests', function (Y) { ); }, + "Should instantiate the search method": function () { + var methods = this.view.get('methods'); + + Assert.isArray( + methods, + "The method list should be an array" + ); + Assert.areEqual( + 2, methods.length, + "The default method list should contain 2 elements" + ); + Assert.isInstanceOf( + Y.eZ.UniversalDiscoverySearchView, methods[1], + "The first element should be an instance of the search method" + ); + Assert.areSame( + this.multiple, methods[1].get('multiple'), + "The selection mode should be passed to the method views" + ); + Assert.isFunction( + methods[1].get('isAlreadySelected'), + "The isAlreadySelected function should be passed to the method views" + ); + Assert.areSame( + this.startingLocationId, methods[1].get('startingLocationId'), + "The startingLocationId should be passed to the method views" + ); + Assert.areSame( + this.startingLocation, methods[1].get('startingLocation'), + "The startingLocation should be passed to the method views" + ); + Assert.areSame( + this.virtualRootLocation, methods[1].get('virtualRootLocation'), + "The virtualRootLocation should be passed to the method views" + ); + }, + "Should add the universal discovery view as a bubble target": function () { var methods = this.view.get('methods'), bubble = false;