|
| 1 | +/** |
| 2 | + * Copyright (c) 2022 Kavita Sonawane |
| 3 | + * |
| 4 | + * @author Kavita Sonawane <kavita.sonawane@t-systems.com> |
| 5 | + * |
| 6 | + * @license GNU AGPL version 3 or any later version |
| 7 | + * |
| 8 | + * This program is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU Affero General Public License as |
| 10 | + * published by the Free Software Foundation, either version 3 of the |
| 11 | + * License, or (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU Affero General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Affero General Public License |
| 19 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + */ |
| 22 | + |
| 23 | +describe('FilesPlugin tests', function() { |
| 24 | + var Plugin = FilesPlugin; |
| 25 | + |
| 26 | + beforeEach(function() { |
| 27 | + // init parameters and test table elements |
| 28 | + $('#testArea').append( |
| 29 | + '<div id="app-content-files">' + |
| 30 | + // init horrible parameters |
| 31 | + '<input type="hidden" id="dir" value="/"></input>' + |
| 32 | + '<input type="hidden" id="permissions" value="31"></input>' + |
| 33 | + // dummy controls |
| 34 | + '<div id="controls">' + |
| 35 | + ' <div class="actions creatable"></div>' + |
| 36 | + ' <div class="notCreatable"></div>' + |
| 37 | + '</div>' + |
| 38 | + // dummy table |
| 39 | + // TODO: at some point this will be rendered by the fileList class itself! |
| 40 | + '<table id="filestable" class="list-container view-grid">' + |
| 41 | + '<thead><tr>' + |
| 42 | + '<th id="allLabel">All</th>'+ |
| 43 | + '<th id="headerName" class="hidden column-name">' + |
| 44 | + '<a class="name columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' + |
| 45 | + '</th>' + |
| 46 | + '<th class="hidden column-mtime">' + |
| 47 | + '<a class="columntitle" data-sort="mtime"><span class="sort-indicator"></span></a>' + |
| 48 | + '</th>' + |
| 49 | + '</tr></thead>' + |
| 50 | + '<tbody id="fileList" class="pendingSharesList"></tbody>' + |
| 51 | + '<tbody id="fileList"></tbody>' + |
| 52 | + '<tfoot></tfoot>' + |
| 53 | + '</table>' + |
| 54 | + '<div id="emptycontent">Empty content message</div>' + |
| 55 | + '</div>' |
| 56 | + ); |
| 57 | + testFiles = { |
| 58 | + id: 1, |
| 59 | + type: 'file', |
| 60 | + name: 'One.txt', |
| 61 | + mimetype: 'text/plain', |
| 62 | + stime: 11111000, |
| 63 | + size: 123, |
| 64 | + path: 'One.txt', |
| 65 | + displayname_file_owner: 'abc', |
| 66 | + uid_file_owner: 'pq', |
| 67 | + file_source: 12, |
| 68 | + } |
| 69 | + |
| 70 | + }); |
| 71 | + |
| 72 | + describe('loading file list', function() { |
| 73 | + |
| 74 | + it('render files', function(done) { |
| 75 | + var $tr = Plugin.renderPendingShareRow(testFiles) |
| 76 | + expect($tr.length).toEqual(1); |
| 77 | + expect($tr.attr('data-id')).toEqual('12'); |
| 78 | + expect($tr.attr('data-share-id')).toEqual('1'); |
| 79 | + expect($tr.attr('data-file')).toEqual('One.txt'); |
| 80 | + expect($tr.attr('data-size')).toEqual('123'); |
| 81 | + expect($tr.attr('data-permissions')).toEqual('8'); |
| 82 | + expect($tr.attr('data-mime')).toEqual('text/plain'); |
| 83 | + expect($tr.attr('data-mtime')).toEqual('11111000'); |
| 84 | + expect($tr.attr('data-share-owner-id')).toEqual('pq'); |
| 85 | + expect($tr.find('.nametext').text().trim()).toEqual('One.txt'); |
| 86 | + |
| 87 | + done(); |
| 88 | + }); |
| 89 | + }); |
| 90 | +}); |
0 commit comments