mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
extra unit tests (#1713)
* typing fixes * "canDownloadSelection" tests * fix import * move test to proper block
This commit is contained in:
@@ -24,8 +24,51 @@
|
||||
*/
|
||||
|
||||
import * as app from './app.rules';
|
||||
import { TestRuleContext } from './test-rule-context';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
|
||||
describe('app.evaluators', () => {
|
||||
describe('canDownloadSelection', () => {
|
||||
it('should return [false] if selection is empty', () => {
|
||||
const context = new TestRuleContext();
|
||||
|
||||
expect(context.selection.isEmpty).toBe(true);
|
||||
expect(app.canDownloadSelection(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] for the trashcan entries', () => {
|
||||
const context = new TestRuleContext();
|
||||
context.selection.isEmpty = false;
|
||||
context.navigation = { url: '/trashcan' };
|
||||
|
||||
expect(app.canDownloadSelection(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should allow downloading files', () => {
|
||||
const context = new TestRuleContext();
|
||||
context.selection.isEmpty = false;
|
||||
context.selection.nodes = [{ entry: { isFile: true } } as NodeEntry];
|
||||
|
||||
expect(app.canDownloadSelection(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow downloading folders', () => {
|
||||
const context = new TestRuleContext();
|
||||
context.selection.isEmpty = false;
|
||||
context.selection.nodes = [{ entry: { isFolder: true } } as NodeEntry];
|
||||
|
||||
expect(app.canDownloadSelection(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should now allow downloading unknown selection', () => {
|
||||
const context = new TestRuleContext();
|
||||
context.selection.isEmpty = false;
|
||||
context.selection.nodes = [{ entry: {} } as NodeEntry];
|
||||
|
||||
expect(app.canDownloadSelection(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isWriteLocked', () => {
|
||||
it('should return [true] if lock type is set', () => {
|
||||
const context: any = {
|
||||
@@ -123,32 +166,32 @@ describe('app.evaluators', () => {
|
||||
|
||||
expect(app.hasLockedFiles(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return [true] when one of files has readonly lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK'
|
||||
it('should return [true] when one of files has readonly lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.hasLockedFiles(context)).toBe(true);
|
||||
expect(app.hasLockedFiles(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUpdateSelectedNode', () => {
|
||||
|
Reference in New Issue
Block a user