X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/72c12f527787181e4abb09fc968f07e795179c3c..e92207c912aed73a07340b5fb2a9e2cb23e1da5f:/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.test.ts diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.test.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.test.ts index 88b7fd02..3964ee47 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.test.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.test.ts @@ -2,40 +2,44 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { collectionPanelFilesReducer } from "./collections-panel-files-reducer"; +import { collectionPanelFilesReducer } from "./collection-panel-files-reducer"; import { collectionPanelFilesAction } from "./collection-panel-files-actions"; -import { CollectionFile, CollectionDirectory, createFile, createDirectory } from "../../../models/collection-file"; -import { createTree, setNode, getNodeValue, mapTreeValues, Tree } from "../../../models/tree"; +import { CollectionFile, CollectionDirectory, createCollectionFile, createCollectionDirectory } from "~/models/collection-file"; +import { createTree, setNode, getNodeValue, mapTreeValues, TreeNodeStatus } from "~/models/tree"; import { CollectionPanelFile, CollectionPanelDirectory } from "./collection-panel-files-state"; describe('CollectionPanelFilesReducer', () => { const files: Array = [ - createDirectory({ id: 'Directory 1', name: 'Directory 1', parentId: '' }), - createDirectory({ id: 'Directory 2', name: 'Directory 2', parentId: 'Directory 1' }), - createDirectory({ id: 'Directory 3', name: 'Directory 3', parentId: '' }), - createDirectory({ id: 'Directory 4', name: 'Directory 4', parentId: 'Directory 3' }), - createFile({ id: 'file1.txt', name: 'file1.txt', parentId: 'Directory 2' }), - createFile({ id: 'file2.txt', name: 'file2.txt', parentId: 'Directory 2' }), - createFile({ id: 'file3.txt', name: 'file3.txt', parentId: 'Directory 3' }), - createFile({ id: 'file4.txt', name: 'file4.txt', parentId: 'Directory 3' }), - createFile({ id: 'file5.txt', name: 'file5.txt', parentId: 'Directory 4' }), + createCollectionDirectory({ id: 'Directory 1', name: 'Directory 1', path: '' }), + createCollectionDirectory({ id: 'Directory 2', name: 'Directory 2', path: 'Directory 1' }), + createCollectionDirectory({ id: 'Directory 3', name: 'Directory 3', path: '' }), + createCollectionDirectory({ id: 'Directory 4', name: 'Directory 4', path: 'Directory 3' }), + createCollectionFile({ id: 'file1.txt', name: 'file1.txt', path: 'Directory 2' }), + createCollectionFile({ id: 'file2.txt', name: 'file2.txt', path: 'Directory 2' }), + createCollectionFile({ id: 'file3.txt', name: 'file3.txt', path: 'Directory 3' }), + createCollectionFile({ id: 'file4.txt', name: 'file4.txt', path: 'Directory 3' }), + createCollectionFile({ id: 'file5.txt', name: 'file5.txt', path: 'Directory 4' }), ]; const collectionFilesTree = files.reduce((tree, file) => setNode({ children: [], id: file.id, - parent: file.parentId, - value: file + parent: file.path, + value: file, + active: false, + selected: false, + expanded: false, + status: TreeNodeStatus.INITIAL, })(tree), createTree()); const collectionPanelFilesTree = collectionPanelFilesReducer( createTree(), - collectionPanelFilesAction.SET_COLLECTION_FILES({ files: collectionFilesTree })); + collectionPanelFilesAction.SET_COLLECTION_FILES(collectionFilesTree)); it('SET_COLLECTION_FILES', () => { expect(getNodeValue('Directory 1')(collectionPanelFilesTree)).toEqual({ - ...createDirectory({ id: 'Directory 1', name: 'Directory 1', parentId: '' }), + ...createCollectionDirectory({ id: 'Directory 1', name: 'Directory 1', path: '' }), collapsed: true, selected: false });