1
0

appSpec.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * ownCloud
  3. *
  4. * @author Vincent Petry
  5. * @copyright 2014 Vincent Petry <pvince81@owncloud.com>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  9. * License as published by the Free Software Foundation; either
  10. * version 3 of the License, or any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public
  18. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. describe('OCA.External.App tests', function() {
  22. var App = OCA.External.App;
  23. var fileList;
  24. beforeEach(function() {
  25. $('#testArea').append(
  26. '<div id="app-navigation">' +
  27. '<ul><li data-id="files"><a>Files</a></li>' +
  28. '<li data-id="sharingin"><a></a></li>' +
  29. '<li data-id="sharingout"><a></a></li>' +
  30. '</ul></div>' +
  31. '<div id="app-content">' +
  32. '<div id="app-content-files" class="hidden">' +
  33. '</div>' +
  34. '<div id="app-content-extstoragemounts" class="hidden">' +
  35. '</div>' +
  36. '</div>' +
  37. '</div>'
  38. );
  39. fileList = App.initList($('#app-content-extstoragemounts'));
  40. });
  41. afterEach(function() {
  42. App.fileList = null;
  43. fileList.destroy();
  44. fileList = null;
  45. });
  46. describe('initialization', function() {
  47. it('inits external mounts list on show', function() {
  48. expect(App.fileList).toBeDefined();
  49. });
  50. });
  51. describe('file actions', function() {
  52. it('provides default file actions', function() {
  53. var fileActions = fileList.fileActions;
  54. expect(fileActions.actions.all).toBeDefined();
  55. expect(fileActions.actions.all.Delete).toBeDefined();
  56. expect(fileActions.actions.all.Rename).toBeDefined();
  57. expect(fileActions.actions.all.Download).toBeDefined();
  58. expect(fileActions.defaults.dir).toEqual('Open');
  59. });
  60. it('redirects to files app when opening a directory', function() {
  61. var oldList = OCA.Files.App.fileList;
  62. // dummy new list to make sure it exists
  63. OCA.Files.App.fileList = new OCA.Files.FileList($('<table><thead></thead><tbody></tbody></table>'));
  64. var setActiveViewStub = sinon.stub(OCA.Files.App, 'setActiveView');
  65. // create dummy table so we can click the dom
  66. var $table = '<table><thead></thead><tbody id="fileList"></tbody></table>';
  67. $('#app-content-extstoragemounts').append($table);
  68. App._inFileList = null;
  69. fileList = App.initList($('#app-content-extstoragemounts'));
  70. fileList.setFiles([{
  71. name: 'testdir',
  72. type: 'dir',
  73. path: '/somewhere/inside/subdir',
  74. counterParts: ['user2'],
  75. shareOwner: 'user2'
  76. }]);
  77. fileList.findFileEl('testdir').find('td a.name').click();
  78. expect(OCA.Files.App.fileList.getCurrentDirectory()).toEqual('/somewhere/inside/subdir/testdir');
  79. expect(setActiveViewStub.calledOnce).toEqual(true);
  80. expect(setActiveViewStub.calledWith('files')).toEqual(true);
  81. setActiveViewStub.restore();
  82. // restore old list
  83. OCA.Files.App.fileList = oldList;
  84. });
  85. });
  86. });