// Mock `window.location` with Jest spies and extend expect
import 'jest-location-mock'
+
+// Mock `window.fetch` with Jest
+import 'jest-fetch-mock'
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { action } from './openFolderAction'
+import type { Navigation } from '../services/Navigation'
+
import { expect } from '@jest/globals'
import { File, Folder, Node, Permission } from '@nextcloud/files'
+
+import { action } from './openFolderAction'
import { DefaultType, FileAction } from '../services/FileAction'
-import type { Navigation } from '../services/Navigation'
const view = {
id: 'files',
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
- expect(goToRouteMock).toBeCalledWith(null, null, { dir: '/FooBar' })
+ expect(goToRouteMock).toBeCalledWith(null, { fileid: undefined, view: 'files' }, { dir: '/FooBar' })
})
test('Open folder fails without node', async () => {
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { action } from './sidebarAction'
+import type { Navigation } from '../services/Navigation'
+
import { expect } from '@jest/globals'
import { File, Permission } from '@nextcloud/files'
+
+import { action } from './sidebarAction'
import { FileAction } from '../services/FileAction'
-import type { Navigation } from '../services/Navigation'
import logger from '../logger'
const view = {
test('Open sidebar', async () => {
const openMock = jest.fn()
window.OCA = { Files: { Sidebar: { open: openMock } } }
+ const goToRouteMock = jest.fn()
+ window.OCP = { Files: { Router: { goToRoute: goToRouteMock } } }
const file = new File({
id: 1,
// Silent action
expect(exec).toBe(null)
expect(openMock).toBeCalledWith('/foobar.txt')
+ expect(goToRouteMock).toBeCalledWith(
+ null,
+ { view: view.id, fileid: 1 },
+ { dir: '/' },
+ true,
+ )
})
test('Open sidebar fails', async () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
- expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/' })
+ expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/' })
})
test('View in (sub) folder', async () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
- expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo/Bar' })
+ expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo/Bar' })
})
test('View in folder fails without node', async () => {
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { action } from './openInFilesAction'
+import type { Navigation } from '../../../files/src/services/Navigation'
+
import { expect } from '@jest/globals'
import { File, Permission } from '@nextcloud/files'
-import { DefaultType, FileAction } from '../../../files/src/services/FileAction'
-import * as eventBus from '@nextcloud/event-bus'
-import axios from '@nextcloud/axios'
-import type { Navigation } from '../../../files/src/services/Navigation'
+
import '../main'
+import { action } from './openInFilesAction'
+import { DefaultType, FileAction } from '../../../files/src/services/FileAction'
import { deletedSharesViewId, pendingSharesViewId, sharedWithOthersViewId, sharedWithYouViewId, sharesViewId, sharingByLinksViewId } from '../views/shares'
const view = {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
- expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo' })
+ expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo' })
})
})
window.OCP.Files.Router.goToRoute(
null, // use default route
{ view: 'files', fileid: node.fileid },
- { dir: node.dirname, fileid: node.fileid },
+ { dir: node.dirname },
)
return null
},
'@nextcloud/vue',
'ansi-regex',
'char-regex',
+ 'hot-patcher',
'is-svg',
'splitpanes',
'string-length',
"vue-multiselect": "^2.1.6",
"vue-observe-visibility": "^1.0.0",
"vue-router": "^3.6.5",
- "vue-virtual-scroll-list": "github:skjnldsv/vue-virtual-scroll-list#master",
"vue-virtual-scroller": "^1.1.2",
"vuedraggable": "^2.24.3",
"vuex": "^3.6.2",
"jasmine-sinon": "^0.4.0",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.5.0",
+ "jest-fetch-mock": "^3.0.3",
"jest-location-mock": "^1.0.9",
"jsdoc": "^4.0.2",
"karma": "^6.4.2",
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
+ "node_modules/jest-fetch-mock": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/jest-fetch-mock/-/jest-fetch-mock-3.0.3.tgz",
+ "integrity": "sha512-Ux1nWprtLrdrH4XwE7O7InRY6psIi3GOsqNESJgMJ+M5cv4A8Lh7SN9d2V2kKRZ8ebAfcd1LNyZguAOb6JiDqw==",
+ "dev": true,
+ "dependencies": {
+ "cross-fetch": "^3.0.4",
+ "promise-polyfill": "^8.1.3"
+ }
+ },
+ "node_modules/jest-fetch-mock/node_modules/cross-fetch": {
+ "version": "3.1.8",
+ "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz",
+ "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==",
+ "dev": true,
+ "dependencies": {
+ "node-fetch": "^2.6.12"
+ }
+ },
"node_modules/jest-get-type": {
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz",
"node": ">=0.4.0"
}
},
+ "node_modules/promise-polyfill": {
+ "version": "8.3.0",
+ "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.3.0.tgz",
+ "integrity": "sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==",
+ "dev": true
+ },
"node_modules/prompts": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",
"integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
"dev": true
},
- "node_modules/vue-virtual-scroll-list": {
- "version": "2.3.5",
- "resolved": "git+ssh://git@github.com/skjnldsv/vue-virtual-scroll-list.git#0f81a0090c3d5f934a7e44c1a90ab8bf36757ea1",
- "license": "MIT"
- },
"node_modules/vue-virtual-scroller": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vue-virtual-scroller/-/vue-virtual-scroller-1.1.2.tgz",
"vue-multiselect": "^2.1.6",
"vue-observe-visibility": "^1.0.0",
"vue-router": "^3.6.5",
- "vue-virtual-scroll-list": "github:skjnldsv/vue-virtual-scroll-list#master",
"vue-virtual-scroller": "^1.1.2",
"vuedraggable": "^2.24.3",
"vuex": "^3.6.2",
"jasmine-sinon": "^0.4.0",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.5.0",
+ "jest-fetch-mock": "^3.0.3",
"jest-location-mock": "^1.0.9",
"jsdoc": "^4.0.2",
"karma": "^6.4.2",