|
3 | 3 | * For full copyright and license information view LICENSE file distributed with this source code.
|
4 | 4 | */
|
5 | 5 | YUI.add('ez-subitemlistitemview-tests', function (Y) {
|
6 |
| - var renderTest, propertiesTest, priorityUpdateTest, |
| 6 | + var renderTest, propertiesTest, priorityUpdateTest, editTest, |
7 | 7 | Assert = Y.Assert, Mock = Y.Mock;
|
8 | 8 |
|
9 | 9 | function createModelMock(name) {
|
@@ -367,7 +367,7 @@ YUI.add('ez-subitemlistitemview-tests', function (Y) {
|
367 | 367 | vars.contentType,
|
368 | 368 | "The contentType should be available in the template"
|
369 | 369 | );
|
370 |
| - |
| 370 | + |
371 | 371 | return rendered;
|
372 | 372 | }, this));
|
373 | 373 | this.view.get('availableProperties')[attr] = {
|
@@ -628,8 +628,87 @@ YUI.add('ez-subitemlistitemview-tests', function (Y) {
|
628 | 628 | },
|
629 | 629 | });
|
630 | 630 |
|
| 631 | + editTest = new Y.Test.Case({ |
| 632 | + name: "eZ Subitem List View edit test", |
| 633 | + |
| 634 | + _createModelMock: createModelMock, |
| 635 | + |
| 636 | + setUp: function () { |
| 637 | + this._createModelMock('location'); |
| 638 | + this._createModelMock('content'); |
| 639 | + this._createModelMock('contentType'); |
| 640 | + this.languageCode = "fre-FR"; |
| 641 | + this.contentInfoMock = new Mock(); |
| 642 | + |
| 643 | + Mock.expect(this.contentInfoMock, { |
| 644 | + method: 'get', |
| 645 | + args: ['mainLanguageCode'], |
| 646 | + returns: this.languageCode, |
| 647 | + }); |
| 648 | + |
| 649 | + Mock.expect(this.location, { |
| 650 | + method: 'get', |
| 651 | + args: ['contentInfo'], |
| 652 | + returns: this.contentInfoMock, |
| 653 | + }); |
| 654 | + |
| 655 | + this.view = new Y.eZ.SubitemListItemView({ |
| 656 | + container: '.container', |
| 657 | + location: this.location, |
| 658 | + content: this.content, |
| 659 | + contentType: this.contentType, |
| 660 | + displayedProperties: [], |
| 661 | + }); |
| 662 | + this.view.render(); |
| 663 | + }, |
| 664 | + |
| 665 | + tearDown: function () { |
| 666 | + this.view.destroy(); |
| 667 | + delete this.view; |
| 668 | + }, |
| 669 | + |
| 670 | + 'Should fire `editContentRequest` when edit button is clicked': function () { |
| 671 | + var editButton, |
| 672 | + eventFired = false; |
| 673 | + |
| 674 | + editButton = this.view.get('container').one('.ez-subitemlistitem-edit'); |
| 675 | + |
| 676 | + this.view.on('editContentRequest', Y.bind(function (e) { |
| 677 | + eventFired = true; |
| 678 | + |
| 679 | + Assert.areSame( |
| 680 | + this.contentInfoMock, |
| 681 | + e.contentInfo, |
| 682 | + "The contentInfo provided by the event should be the same." |
| 683 | + ); |
| 684 | + Assert.areSame( |
| 685 | + this.languageCode, |
| 686 | + e.languageCode, |
| 687 | + "The languageCode provided by the event should be the same." |
| 688 | + ); |
| 689 | + Assert.areSame( |
| 690 | + this.contentType, |
| 691 | + e.contentType, |
| 692 | + "The contentType provided by the event should be the same." |
| 693 | + ); |
| 694 | + }, this)); |
| 695 | + |
| 696 | + editButton.simulateGesture('tap', Y.bind(function () { |
| 697 | + this.resume(function (e) { |
| 698 | + Assert.isTrue( |
| 699 | + eventFired, |
| 700 | + "The `editContentRequest` event should have been fired" |
| 701 | + ); |
| 702 | + }); |
| 703 | + }, this)); |
| 704 | + this.wait(); |
| 705 | + }, |
| 706 | + }); |
| 707 | + |
| 708 | + |
631 | 709 | Y.Test.Runner.setName("eZ Subitem List View tests");
|
632 | 710 | Y.Test.Runner.add(renderTest);
|
633 | 711 | Y.Test.Runner.add(propertiesTest);
|
634 | 712 | Y.Test.Runner.add(priorityUpdateTest);
|
| 713 | + Y.Test.Runner.add(editTest); |
635 | 714 | }, '', {requires: ['test', 'template', 'handlebars', 'node-event-simulate', 'ez-subitemlistitemview']});
|
0 commit comments