mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
unified selection state (#433)
* selection state * use unified selection state * cleanup tests * remove "console.log" * remove old selection property * remove coma
This commit is contained in:
@@ -24,15 +24,10 @@
|
||||
*/
|
||||
|
||||
import { PageComponent } from './page.component';
|
||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||
|
||||
class TestClass extends PageComponent {
|
||||
node: any;
|
||||
|
||||
setSelection(selection: MinimalNodeEntity[] = []) {
|
||||
this.onSelectionChanged(selection);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super(null, null, null);
|
||||
}
|
||||
@@ -58,47 +53,4 @@ describe('PageComponent', () => {
|
||||
expect(component.getParentNodeId()).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasSelection()', () => {
|
||||
it('returns true when it has nodes selected', () => {
|
||||
component.setSelection([
|
||||
{ entry: { isFile: true } },
|
||||
{ entry: { isFile: true } }
|
||||
]);
|
||||
expect(component.hasSelection).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when it has no selections', () => {
|
||||
component.setSelection([]);
|
||||
expect(component.hasSelection).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectedFile', () => {
|
||||
it('returns true if selected node is file', () => {
|
||||
const selection = [ { entry: { isFile: true } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.selectedFile).toBe(selection[0]);
|
||||
});
|
||||
|
||||
it('returns false if selected node is folder', () => {
|
||||
const selection = [ { entry: { isFile: false, isFolder: true } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.selectedFile).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectedFolder', () => {
|
||||
it('returns true if selected node is folder', () => {
|
||||
const selection = [ { entry: { isFile: false, isFolder: true } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.selectedFolder).toBe(selection[0]);
|
||||
});
|
||||
|
||||
it('returns false if selected node is file', () => {
|
||||
const selection = [ { entry: { isFile: true, isFolder: false } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.selectedFolder).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user