-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [MNT-23821] Filter custom aspects * [MNT-23821] getCustomAspects initialization * [MNT-23821] Added aspect list service tests * [MNT-23821] getCustomAspects - whiteList argument as optional. Added tests. * [MNT-23821] Changed from double to single quotes * [MNT-23821] Lint
- Loading branch information
1 parent
9a349f2
commit b58e6f6
Showing
3 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
lib/content-services/src/lib/aspect-list/services/aspect-list.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/*! | ||
* @license | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { TestBed } from '@angular/core/testing'; | ||
import { AlfrescoApiService, CoreTestingModule } from '@alfresco/adf-core'; | ||
import { AspectListService } from './aspect-list.service'; | ||
import { AspectPaging, AspectsApi, AspectEntry } from '@alfresco/js-api'; | ||
|
||
const stdAspect1: AspectEntry = { entry: { id: 'std:standardAspectOne', description: 'Standard Aspect One', title: 'StandardAspectOne' } }; | ||
const stdAspect2: AspectEntry = { entry: { id: 'std:standardAspectTwo', description: 'Standard Aspect Two', title: 'StandardAspectTwo' } }; | ||
const stdAspect3: AspectEntry = { entry: { id: 'std:standardAspectThree', description: 'Standard Aspect Three', title: 'StandardAspectThree' } }; | ||
const standardAspectPagingMock: AspectPaging = { list: { entries: [ stdAspect1, stdAspect2, stdAspect3 ] } }; | ||
|
||
const cstAspect1: AspectEntry = { entry: { id: 'cst:customAspectOne', description: 'Custom Aspect One', title: 'CustomAspectOne' } }; | ||
const cstAspect2: AspectEntry = { entry: { id: 'cst:customAspectTwo', description: 'Custom Aspect Two', title: 'CustomAspectTwo' } }; | ||
const cstAspect3: AspectEntry = { entry: { id: 'cst:customAspectThree', description: 'Custom Aspect Three', title: 'CustomAspectThree' } }; | ||
const customAspectPagingMock: AspectPaging = { list: { entries: [ cstAspect1, cstAspect2, cstAspect3 ] } }; | ||
|
||
describe('AspectListService', () => { | ||
|
||
let aspectListService: AspectListService; | ||
let apiService: AlfrescoApiService; | ||
let aspectsApi: AspectsApi; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
CoreTestingModule | ||
] | ||
}); | ||
|
||
aspectListService = TestBed.inject(AspectListService); | ||
apiService = TestBed.inject(AlfrescoApiService); | ||
aspectsApi = new AspectsApi(apiService.getInstance()); | ||
spyOnProperty(aspectListService, 'aspectsApi', 'get').and.returnValue(aspectsApi); | ||
}); | ||
|
||
it('should get one standard aspect', (done) => { | ||
const visibleAspects = ['std:standardAspectOne']; | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(standardAspectPagingMock)); | ||
aspectListService.getStandardAspects(visibleAspects).subscribe((response) => { | ||
expect(response).toEqual([stdAspect1]); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should get two standard aspects', (done) => { | ||
const visibleAspects = ['std:standardAspectTwo', 'std:standardAspectThree']; | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(standardAspectPagingMock)); | ||
aspectListService.getStandardAspects(visibleAspects).subscribe((response) => { | ||
expect(response).toEqual([stdAspect2, stdAspect3]); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should get one custom aspect', (done) => { | ||
const visibleAspects = ['cst:customAspectTwo']; | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(customAspectPagingMock)); | ||
aspectListService.getCustomAspects(visibleAspects).subscribe((response) => { | ||
expect(response).toEqual([cstAspect2]); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should get two custom aspects', (done) => { | ||
const visibleAspects = ['cst:customAspectOne', 'cst:customAspectThree']; | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(customAspectPagingMock)); | ||
aspectListService.getCustomAspects(visibleAspects).subscribe((response) => { | ||
expect(response).toEqual([cstAspect1, cstAspect3]); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should get all custom aspects (visible aspects as undefined)', (done) => { | ||
const visibleAspects = undefined; | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(customAspectPagingMock)); | ||
aspectListService.getCustomAspects(visibleAspects).subscribe((response) => { | ||
expect(response).toEqual([cstAspect1, cstAspect2, cstAspect3]); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should get all custom aspects (visible aspects as empty array)', (done) => { | ||
const visibleAspects = []; | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(customAspectPagingMock)); | ||
aspectListService.getCustomAspects(visibleAspects).subscribe((response) => { | ||
expect(response).toEqual([cstAspect1, cstAspect2, cstAspect3]); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should get all custom aspects (visible aspects not supplied)', (done) => { | ||
spyOn(aspectsApi, 'listAspects').and.returnValue(Promise.resolve(customAspectPagingMock)); | ||
aspectListService.getCustomAspects().subscribe((response) => { | ||
expect(response).toEqual([cstAspect1, cstAspect2, cstAspect3]); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters