fix tests

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

View File

@ -1,6 +1,6 @@
import {APP_BASE_HREF} from '@angular/common'; import {APP_BASE_HREF} from '@angular/common';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import { ComponentFixture, fakeAsync, TestBed, waitForAsync } from '@angular/core/testing'; import {ComponentFixture, fakeAsync, TestBed, waitForAsync} from '@angular/core/testing';
import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetModule, MatBottomSheetRef} from '@angular/material/bottom-sheet'; import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetModule, MatBottomSheetRef} from '@angular/material/bottom-sheet';
import {MatCardModule} from '@angular/material/card'; import {MatCardModule} from '@angular/material/card';
import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from '@angular/material/dialog'; import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from '@angular/material/dialog';
@ -10,24 +10,27 @@ import {MatSnackBarModule} from '@angular/material/snack-bar';
import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing'; import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from '@angular/router/testing';
import { cloneDeep } from 'lodash'; import {cloneDeep} from 'lodash';
import {of} from 'rxjs'; 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();
});
}); });