Skip to content
Snippets Groups Projects

fix logic

2 files
+ 44
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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;
 
})
});
});
Loading