Skip to content
Snippets Groups Projects
Commit 86157fe3 authored by kbeyro's avatar kbeyro
Browse files

add test

parent b0d1599e
No related branches found
No related tags found
1 merge request!21fix logic
...@@ -12,17 +12,44 @@ import {FormsModule} from '@angular/forms'; ...@@ -12,17 +12,44 @@ import {FormsModule} from '@angular/forms';
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {MockAuthService} from '../../appmarket.component.spec'; import {MockAuthService} from '../../appmarket.component.spec';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ApplicationBase } from '../../../model/application-base';
import { ApplicationState } from '../../../model/application-state';
import { Rate } from '../../../model';
import { RemovalConfirmationModalComponent } from '../../domains/modals/removal-confirmation-modal/removal-confirmation-modal.component';
describe('AppManagementListComponent', () => { describe('AppManagementListComponent', () => {
let component: AppManagementListComponent; let component: AppManagementListComponent;
let fixture: ComponentFixture<AppManagementListComponent>; let fixture: ComponentFixture<AppManagementListComponent>;
let confirmRemovalModal: ModalComponent = jasmine.createSpyObj('confirmRemovalModal', ['show'])
const appBase: ApplicationBase = {
id: 1,
name: 'app',
owner: 'admin',
license: undefined,
licenseUrl: undefined,
wwwUrl: undefined,
sourceUrl: undefined,
issuesUrl: undefined,
nmaasDocumentationUrl: undefined,
descriptions: [],
tags: [],
versions: [
{id: 1, version: '1.0.0', state: ApplicationState.ACTIVE, appVersionId: 1},
{id: 2, version: '1.0.1', state: ApplicationState.ACTIVE, appVersionId: 2},
{id: 3, version: '1.0.3', state: ApplicationState.NEW, appVersionId: 3}
],
rate: new Rate(4, 4.5, new Map([[5, 1], [4, 1]]))
}
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
AppManagementListComponent, AppManagementListComponent,
AppChangeStateModalComponent, AppChangeStateModalComponent,
ModalComponent ModalComponent,
RemovalConfirmationModalComponent
], ],
providers: [ providers: [
AppsService, AppsService,
...@@ -55,4 +82,19 @@ describe('AppManagementListComponent', () => { ...@@ -55,4 +82,19 @@ describe('AppManagementListComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
it('should not be able to remove app', () => {
component.openRemovalModal(appBase);
expect(component.appToRemove).toEqual(appBase);
expect(component.hasRunningInstances).toBeTruthy;
})
it('should be able to remove app', () => {
appBase.versions.forEach(ver => {
ver.state = ApplicationState.DELETED
})
component.openRemovalModal(appBase);
expect(component.appToRemove).toEqual(appBase);
expect(component.hasRunningInstances).toBeFalsy;
})
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment