1
0

appSpec.js 3.3 KB

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