fix tests

This commit is contained in:
alicia pritchett 2022-03-23 14:12:05 -04:00
parent fad0368626
commit 3386d27921

View File

@ -15,19 +15,22 @@ import {of} from 'rxjs';
import { import {
ApiErrorsComponent, ApiErrorsComponent,
ApiService, ApiService,
MockEnvironment, mockWorkflowMeta1, MockEnvironment,
mockWorkflowMeta1,
mockWorkflowSpec0, mockWorkflowSpec0,
mockWorkflowSpec1, mockWorkflowSpec1,
mockWorkflowSpec2, mockWorkflowSpec3, mockWorkflowSpec3,
mockWorkflowSpecCategories, mockWorkflowSpecCategories,
mockWorkflowSpecCategory0, mockWorkflowSpecCategory0,
mockWorkflowSpecCategory1, mockWorkflowSpecCategory1,
mockWorkflowSpecCategory2,
mockWorkflowSpecs, mockWorkflowSpecs,
WorkflowSpec WorkflowSpec
} from 'sartography-workflow-lib'; } from 'sartography-workflow-lib';
import {GitRepo} from "sartography-workflow-lib/lib/types/git";
import {ApiError} from 'sartography-workflow-lib/lib/types/api'; import {ApiError} from 'sartography-workflow-lib/lib/types/api';
import {DeleteWorkflowSpecDialogComponent} from '../_dialogs/delete-workflow-spec-dialog/delete-workflow-spec-dialog.component'; import {
DeleteWorkflowSpecDialogComponent
} from '../_dialogs/delete-workflow-spec-dialog/delete-workflow-spec-dialog.component';
import { import {
DeleteWorkflowSpecCategoryDialogData, DeleteWorkflowSpecCategoryDialogData,
DeleteWorkflowSpecDialogData, DeleteWorkflowSpecDialogData,
@ -37,7 +40,6 @@ import {
import {GetIconCodePipe} from '../_pipes/get-icon-code.pipe'; import {GetIconCodePipe} from '../_pipes/get-icon-code.pipe';
import {FileListComponent} from '../file-list/file-list.component'; import {FileListComponent} from '../file-list/file-list.component';
import {WorkflowSpecCategoryGroup, WorkflowSpecListComponent} from './workflow-spec-list.component'; import {WorkflowSpecCategoryGroup, WorkflowSpecListComponent} from './workflow-spec-list.component';
import {GitRepoDialogComponent} from "../git-repo-dialog/git-repo-dialog.component";
export class MdDialogMock { export class MdDialogMock {
@ -517,15 +519,25 @@ describe('WorkflowSpecListComponent', () => {
}); });
it('should call gitPush', () => { it('should call gitPush', () => {
const mockComment = 'my comment'; const mockComment = '';
const gitPushSpy = spyOn((component as any), 'gitPush').and.stub(); component.gitRepo = {branch: "", directory: "", merge_branch: "", display_merge: true, display_push: true};
const gitPushSpy = spyOn((component as any), 'gitPush').and.callThrough();
const dialogSpy = spyOn(component.dialog, 'open') const dialogSpy = spyOn(component.dialog, 'open')
.and.returnValue({afterClosed: () => of (mockComment)} as any); .and.returnValue({afterClosed: () => of (mockComment)} as any);
component.gitPush(); component.gitPush();
expect(gitPushSpy).toHaveBeenCalled(); expect(gitPushSpy).toHaveBeenCalled();
expect(dialogSpy).toHaveBeenCalled(); expect(dialogSpy).toHaveBeenCalled();
}); });
it('should call git merge', () => {
component.gitRepo = {branch: "", directory: "", merge_branch: "all", display_merge: true, display_push: true};
const gitMergeSpy = spyOn((component as any), 'gitMerge').and.callThrough();
const dialogSpy = spyOn(component.dialog, 'open')
.and.returnValue({afterClosed: () => of ()} as any);
component.gitMerge();
expect(gitMergeSpy).toHaveBeenCalled();
expect(dialogSpy).toHaveBeenCalled();
});
}); });