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:
Denys Vuika
2018-06-19 08:16:53 +01:00
committed by GitHub
parent abd63ba0a4
commit 1a53f8d2aa
13 changed files with 171 additions and 169 deletions

View File

@@ -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();
});
});
});