mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[MIGRATION] - Added injectionContext to avoid error NG0203 for unit tests
This commit is contained in:
+12
@@ -36,6 +36,7 @@ describe('SearchHeaderQueryBuilderService', () => {
|
||||
};
|
||||
|
||||
it('should load the configuration from app config', () => {
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
|
||||
@@ -55,8 +56,10 @@ describe('SearchHeaderQueryBuilderService', () => {
|
||||
expect(builder.categories.length).toBe(2);
|
||||
expect(builder.filterQueries.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the category assigned to a column key', () => {
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [
|
||||
{ id: 'cat1', columnKey: 'fake-key-1', enabled: true } as any,
|
||||
@@ -73,14 +76,18 @@ describe('SearchHeaderQueryBuilderService', () => {
|
||||
expect(category).not.toBeUndefined();
|
||||
expect(category.columnKey).toBe('fake-key-1');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have empty user query by default', () => {
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
const builder = new SearchHeaderQueryBuilderService(buildConfig({}), alfrescoApiService, null);
|
||||
expect(builder.userQuery).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
it('should add the extra filter for the parent node', () => {
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
|
||||
@@ -95,8 +102,10 @@ describe('SearchHeaderQueryBuilderService', () => {
|
||||
|
||||
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not add again the parent filter if that node is already added', () => {
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const expectedResult = [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id"' }];
|
||||
|
||||
const config: SearchConfiguration = {
|
||||
@@ -111,8 +120,10 @@ describe('SearchHeaderQueryBuilderService', () => {
|
||||
|
||||
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not add duplicate column names in activeFilters', () => {
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const activeFilter = 'FakeColumn';
|
||||
|
||||
const config: SearchConfiguration = {
|
||||
@@ -131,3 +142,4 @@ describe('SearchHeaderQueryBuilderService', () => {
|
||||
expect(searchHeaderService.activeFilters.length).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user