Skip to content

Commit

Permalink
Fix tasks unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcanonieto committed Jun 30, 2020
1 parent 683f7ff commit 1c72040
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h3>Tasks</h3>

<adf-cloud-task-list #taskList [sorting]="taskListSorting" (rowClick)="onTaskRowClick($event)">
</adf-cloud-task-list>
<adf-pagination [target]="taskList" [supportedPageSizes]="[5,10,15,20]" [pagination]="10">
<adf-pagination [target]="taskList" [supportedPageSizes]="[5,10,15,20]">
</adf-pagination>

<h3>Processes</h3>
Expand All @@ -17,5 +17,5 @@ <h3>Processes</h3>

<adf-cloud-process-list #processList [appName]="''" [sorting]="processListSorting" (rowClick)="onProcessRowClick($event)">
</adf-cloud-process-list>
<adf-pagination [target]="processList" [supportedPageSizes]="[5,10,15,20]" [pagination]="10">
<adf-pagination [target]="processList" [supportedPageSizes]="[5,10,15,20]">
</adf-pagination>
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ContentModule } from '@alfresco/adf-content-services';
import { ProcessServicesCloudModule } from '@alfresco/adf-process-services-cloud';
import { CoreModule, AppConfigService, AppConfigServiceMock, TranslateLoaderService } from '@alfresco/adf-core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { ProcessServicesCloudModule, TaskListCloudService } from '@alfresco/adf-process-services-cloud';
import { CoreModule, AppConfigService, AppConfigServiceMock, TranslationService, TranslationMock } from '@alfresco/adf-core';
import { TasksComponent } from './tasks.component';
import { AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';

describe('TasksComponent', () => {
let component: TasksComponent;
let fixture: ComponentFixture<TasksComponent>;
let alfrescoApiService: AlfrescoApiService;
let taskListCloudService: TaskListCloudService;

const fakeTaskCloudList = {
list: {
entries: [],
pagination: {
skipCount: 0,
maxItems: 10,
maxItems: 15,
count: 0,
hasMoreItems: false,
totalItems: 0
}
}
};

const mock = {
const oauth2AuthMock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeTaskCloudList)
}
callCustomApi: () => {
return Promise.resolve({});
}
},
isEcmBpmConfiguration: () => false,
isEcmConfiguration: () => false
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
BrowserAnimationsModule,
NoopAnimationsModule,
TranslateModule.forRoot(),
CoreModule.forRoot(),
ContentModule.forRoot(),
ProcessServicesCloudModule,
TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: TranslateLoaderService }
})
ProcessServicesCloudModule
],
declarations: [TasksComponent],
providers: [
{ provide: AppConfigService, useClass: AppConfigServiceMock },
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: AppConfigService, useClass: AppConfigServiceMock }
{ provide: TranslationService, useClass: TranslationMock }
]
});

fixture = TestBed.createComponent(TasksComponent);
alfrescoApiService = TestBed.get(AlfrescoApiService);
taskListCloudService = TestBed.get(TaskListCloudService);
component = fixture.componentInstance;
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock);

spyOn(alfrescoApiService, 'getInstance').and.returnValue(oauth2AuthMock);
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeTaskCloudList));
fixture.detectChanges();
});

afterEach(() => {
fixture.destroy();
});

it('should create', () => {
expect(component).toBeDefined();
});
Expand Down

0 comments on commit 1c72040

Please sign in to comment.