Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
fdewas-aneo authored and GunaDinesh committed Nov 28, 2023
1 parent 37a9ed2 commit 1045c31
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/app/applications/index.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ describe('Application component', () => {
};

const mockApplicationsFilterService = {
restoreFilters: jest.fn()
restoreFilters: jest.fn(),
saveFilters: jest.fn(),
resetFilters: jest.fn(),
};

const mockTasksByStatusService = {
Expand All @@ -49,6 +51,15 @@ describe('Application component', () => {
error: jest.fn()
};

const mockGrpcApplicationsService = {
list$: jest.fn()
};

const mockAutoRefreshService = {
createInterval: jest.fn(),
autoRefreshTooltip: jest.fn()
};

beforeEach(() => {
component = TestBed.configureTestingModule({
providers: [
Expand All @@ -62,15 +73,27 @@ describe('Application component', () => {
{ provide: DATA_FILTERS_SERVICE, useValue: mockApplicationsFilterService },
{ provide: ShareUrlService, useValue: mockShareUrlService },
{ provide: ApplicationsIndexService, useValue: mockApplicationIndexService },
{ provide: ApplicationsGrpcService, useValue: {} },
{ provide: AutoRefreshService, useValue: {
createInterval: jest.fn()
} },
{ provide: ApplicationsGrpcService, useValue: mockGrpcApplicationsService },
{ provide: AutoRefreshService, useValue: mockAutoRefreshService },
]
}).inject(IndexComponent);

component.paginator.pageIndex = 1;
component.paginator.pageSize = 25;
});

it('Should run', () => {
expect(component).toBeTruthy();
});

it('should init', () => {
component.ngOnInit();
expect(mockApplicationIndexService.restoreColumns).toHaveBeenCalled();
expect(mockApplicationIndexService.restoreOptions).toHaveBeenCalled();
expect(mockApplicationsFilterService.restoreFilters).toHaveBeenCalled();
expect(mockApplicationIndexService.restoreIntervalValue).toHaveBeenCalled();
expect(mockShareUrlService.generateSharableUrl).toHaveBeenCalledWith(component.options, component.filters);
expect(mockTasksByStatusService.restoreStatuses).toHaveBeenCalledWith('applications');
expect(component.availableColumns).toEqual();
});
});

0 comments on commit 1045c31

Please sign in to comment.