[ACS-3379] Fix unit tests for the visibility rules of the folder rules (#2576)

* [ACS-3379] Fix unit tests for the visibility rules of the folder rules

* Add stage to .travis.yml so unit tests run on Travis

* Karma singleRun: true so that Travis doesn't stall
This commit is contained in:
Thomas Hunter 2022-08-03 16:22:42 +01:00 committed by GitHub
parent 30eebfa1e2
commit 38cae75476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 39 deletions

View File

@ -85,6 +85,11 @@ jobs:
script: npm ci && ng test aca-settings script: npm ci && ng test aca-settings
cache: false cache: false
- stage: Quality and Unit tests
name: 'Unit tests: aca-folder-rules'
script: npm ci && ng test aca-folder-rules
cache: false
- stage: Quality and Unit tests - stage: Quality and Unit tests
name: 'Unit tests: ACA' name: 'Unit tests: ACA'
script: script:

View File

@ -26,7 +26,7 @@ module.exports = function (config) {
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
autoWatch: true, autoWatch: true,
browsers: ['Chrome'], browsers: ['Chrome'],
singleRun: false, singleRun: true,
restartOnFileChange: true restartOnFileChange: true
}); });
}; };

View File

@ -24,9 +24,9 @@
*/ */
import { AcaRuleContext } from '@alfresco/aca-shared/rules'; import { AcaRuleContext } from '@alfresco/aca-shared/rules';
import { isFolderRulesEnabled, canCreateFolderRule, canLinkFolderRule } from './folder-rules.rules'; import { isFolderRulesEnabled, canManageFolderRules } from './folder-rules.rules';
describe('Folder Rules', () => { describe('Folder Rules Visibility Rules', () => {
describe('isFolderRulesEnabled', () => { describe('isFolderRulesEnabled', () => {
it('should have the feature enabled', () => { it('should have the feature enabled', () => {
const context: any = { const context: any = {
@ -51,7 +51,7 @@ describe('Folder Rules', () => {
}); });
}); });
describe('canCreateFolderRule', () => { describe('canManageFolderRules', () => {
let context: AcaRuleContext; let context: AcaRuleContext;
beforeEach(() => { beforeEach(() => {
@ -72,47 +72,14 @@ describe('Folder Rules', () => {
}); });
it('should allow creating a rule for the selected folder', () => { it('should allow creating a rule for the selected folder', () => {
const result = canCreateFolderRule(context); const result = canManageFolderRules(context);
expect(result).toEqual(true); expect(result).toEqual(true);
}); });
it('should not allow creating a rule if no folder selected', () => { it('should not allow creating a rule if no folder selected', () => {
context.selection.folder = null; context.selection.folder = null;
const result = canCreateFolderRule(context); const result = canManageFolderRules(context);
expect(result).toEqual(false);
});
});
describe('canLinkFolderRule', () => {
let context: AcaRuleContext;
beforeEach(() => {
context = {
appConfig: {
get: () => true
},
selection: {
folder: {} as any
},
navigation: {
url: '/personal-files'
},
permissions: {
check: () => true
}
} as any;
});
it('should allow linking rule for the selected folder', () => {
const result = canLinkFolderRule(context);
expect(result).toEqual(true);
});
it('should not allow linking rule if no folder selected', () => {
context.selection.folder = null;
const result = canLinkFolderRule(context);
expect(result).toEqual(false); expect(result).toEqual(false);
}); });
}); });