1
0

import of initial customer.jdl including related entities

This commit is contained in:
Michael Hoennig
2019-04-03 10:56:31 +02:00
parent acd28d679c
commit 1e7b801e22
205 changed files with 15363 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetDeleteDialogComponent } from 'app/entities/asset/asset-delete-dialog.component';
import { AssetService } from 'app/entities/asset/asset.service';
describe('Component Tests', () => {
describe('Asset Management Delete Component', () => {
let comp: AssetDeleteDialogComponent;
let fixture: ComponentFixture<AssetDeleteDialogComponent>;
let service: AssetService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetDeleteDialogComponent]
})
.overrideTemplate(AssetDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(AssetService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetDetailComponent } from 'app/entities/asset/asset-detail.component';
import { Asset } from 'app/shared/model/asset.model';
describe('Component Tests', () => {
describe('Asset Management Detail Component', () => {
let comp: AssetDetailComponent;
let fixture: ComponentFixture<AssetDetailComponent>;
const route = ({ data: of({ asset: new Asset(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(AssetDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.asset).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetUpdateComponent } from 'app/entities/asset/asset-update.component';
import { AssetService } from 'app/entities/asset/asset.service';
import { Asset } from 'app/shared/model/asset.model';
describe('Component Tests', () => {
describe('Asset Management Update Component', () => {
let comp: AssetUpdateComponent;
let fixture: ComponentFixture<AssetUpdateComponent>;
let service: AssetService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetUpdateComponent]
})
.overrideTemplate(AssetUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(AssetService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Asset(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.asset = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Asset();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.asset = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetComponent } from 'app/entities/asset/asset.component';
import { AssetService } from 'app/entities/asset/asset.service';
import { Asset } from 'app/shared/model/asset.model';
describe('Component Tests', () => {
describe('Asset Management Component', () => {
let comp: AssetComponent;
let fixture: ComponentFixture<AssetComponent>;
let service: AssetService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(AssetComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(AssetService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Asset(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Asset(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Asset(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@ -0,0 +1,135 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { AssetService } from 'app/entities/asset/asset.service';
import { IAsset, Asset, AssetAction } from 'app/shared/model/asset.model';
describe('Service Tests', () => {
describe('Asset Service', () => {
let injector: TestBed;
let service: AssetService;
let httpMock: HttpTestingController;
let elemDefault: IAsset;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(AssetService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Asset(0, currentDate, AssetAction.PAYMENT, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
date: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Asset', async () => {
const returnedFromService = Object.assign(
{
id: 0,
date: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
date: currentDate
},
returnedFromService
);
service
.create(new Asset(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Asset', async () => {
const returnedFromService = Object.assign(
{
date: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
amount: 1,
comment: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
date: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Asset', async () => {
const returnedFromService = Object.assign(
{
date: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
amount: 1,
comment: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
date: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Asset', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { ContactDeleteDialogComponent } from 'app/entities/contact/contact-delete-dialog.component';
import { ContactService } from 'app/entities/contact/contact.service';
describe('Component Tests', () => {
describe('Contact Management Delete Component', () => {
let comp: ContactDeleteDialogComponent;
let fixture: ComponentFixture<ContactDeleteDialogComponent>;
let service: ContactService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ContactDeleteDialogComponent]
})
.overrideTemplate(ContactDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ContactDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ContactService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ContactDetailComponent } from 'app/entities/contact/contact-detail.component';
import { Contact } from 'app/shared/model/contact.model';
describe('Component Tests', () => {
describe('Contact Management Detail Component', () => {
let comp: ContactDetailComponent;
let fixture: ComponentFixture<ContactDetailComponent>;
const route = ({ data: of({ contact: new Contact(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ContactDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(ContactDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ContactDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.contact).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ContactUpdateComponent } from 'app/entities/contact/contact-update.component';
import { ContactService } from 'app/entities/contact/contact.service';
import { Contact } from 'app/shared/model/contact.model';
describe('Component Tests', () => {
describe('Contact Management Update Component', () => {
let comp: ContactUpdateComponent;
let fixture: ComponentFixture<ContactUpdateComponent>;
let service: ContactService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ContactUpdateComponent]
})
.overrideTemplate(ContactUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ContactUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ContactService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Contact(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.contact = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Contact();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.contact = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { ContactComponent } from 'app/entities/contact/contact.component';
import { ContactService } from 'app/entities/contact/contact.service';
import { Contact } from 'app/shared/model/contact.model';
describe('Component Tests', () => {
describe('Contact Management Component', () => {
let comp: ContactComponent;
let fixture: ComponentFixture<ContactComponent>;
let service: ContactService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ContactComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(ContactComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ContactComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ContactService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Contact(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.contacts[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Contact(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.contacts[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Contact(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.contacts[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@ -0,0 +1,108 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import { ContactService } from 'app/entities/contact/contact.service';
import { IContact, Contact } from 'app/shared/model/contact.model';
describe('Service Tests', () => {
describe('Contact Service', () => {
let injector: TestBed;
let service: ContactService;
let httpMock: HttpTestingController;
let elemDefault: IContact;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(ContactService);
httpMock = injector.get(HttpTestingController);
elemDefault = new Contact(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign({}, elemDefault);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Contact', async () => {
const returnedFromService = Object.assign(
{
id: 0
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.create(new Contact(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Contact', async () => {
const returnedFromService = Object.assign(
{
firstName: 'BBBBBB',
lastName: 'BBBBBB',
email: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Contact', async () => {
const returnedFromService = Object.assign(
{
firstName: 'BBBBBB',
lastName: 'BBBBBB',
email: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Contact', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerContactDeleteDialogComponent } from 'app/entities/customer-contact/customer-contact-delete-dialog.component';
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
describe('Component Tests', () => {
describe('CustomerContact Management Delete Component', () => {
let comp: CustomerContactDeleteDialogComponent;
let fixture: ComponentFixture<CustomerContactDeleteDialogComponent>;
let service: CustomerContactService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerContactDeleteDialogComponent]
})
.overrideTemplate(CustomerContactDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerContactDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerContactService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerContactDetailComponent } from 'app/entities/customer-contact/customer-contact-detail.component';
import { CustomerContact } from 'app/shared/model/customer-contact.model';
describe('Component Tests', () => {
describe('CustomerContact Management Detail Component', () => {
let comp: CustomerContactDetailComponent;
let fixture: ComponentFixture<CustomerContactDetailComponent>;
const route = ({ data: of({ customerContact: new CustomerContact(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerContactDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(CustomerContactDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerContactDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.customerContact).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerContactUpdateComponent } from 'app/entities/customer-contact/customer-contact-update.component';
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
import { CustomerContact } from 'app/shared/model/customer-contact.model';
describe('Component Tests', () => {
describe('CustomerContact Management Update Component', () => {
let comp: CustomerContactUpdateComponent;
let fixture: ComponentFixture<CustomerContactUpdateComponent>;
let service: CustomerContactService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerContactUpdateComponent]
})
.overrideTemplate(CustomerContactUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerContactUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerContactService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new CustomerContact(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.customerContact = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new CustomerContact();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.customerContact = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerContactComponent } from 'app/entities/customer-contact/customer-contact.component';
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
import { CustomerContact } from 'app/shared/model/customer-contact.model';
describe('Component Tests', () => {
describe('CustomerContact Management Component', () => {
let comp: CustomerContactComponent;
let fixture: ComponentFixture<CustomerContactComponent>;
let service: CustomerContactService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerContactComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(CustomerContactComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerContactComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerContactService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new CustomerContact(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.customerContacts[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new CustomerContact(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.customerContacts[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new CustomerContact(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.customerContacts[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@ -0,0 +1,104 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
import { ICustomerContact, CustomerContact, CustomerContactRole } from 'app/shared/model/customer-contact.model';
describe('Service Tests', () => {
describe('CustomerContact Service', () => {
let injector: TestBed;
let service: CustomerContactService;
let httpMock: HttpTestingController;
let elemDefault: ICustomerContact;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(CustomerContactService);
httpMock = injector.get(HttpTestingController);
elemDefault = new CustomerContact(0, CustomerContactRole.CONTRACTUAL);
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign({}, elemDefault);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a CustomerContact', async () => {
const returnedFromService = Object.assign(
{
id: 0
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.create(new CustomerContact(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a CustomerContact', async () => {
const returnedFromService = Object.assign(
{
role: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of CustomerContact', async () => {
const returnedFromService = Object.assign(
{
role: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a CustomerContact', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerDeleteDialogComponent } from 'app/entities/customer/customer-delete-dialog.component';
import { CustomerService } from 'app/entities/customer/customer.service';
describe('Component Tests', () => {
describe('Customer Management Delete Component', () => {
let comp: CustomerDeleteDialogComponent;
let fixture: ComponentFixture<CustomerDeleteDialogComponent>;
let service: CustomerService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerDeleteDialogComponent]
})
.overrideTemplate(CustomerDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerDetailComponent } from 'app/entities/customer/customer-detail.component';
import { Customer } from 'app/shared/model/customer.model';
describe('Component Tests', () => {
describe('Customer Management Detail Component', () => {
let comp: CustomerDetailComponent;
let fixture: ComponentFixture<CustomerDetailComponent>;
const route = ({ data: of({ customer: new Customer(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(CustomerDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.customer).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerUpdateComponent } from 'app/entities/customer/customer-update.component';
import { CustomerService } from 'app/entities/customer/customer.service';
import { Customer } from 'app/shared/model/customer.model';
describe('Component Tests', () => {
describe('Customer Management Update Component', () => {
let comp: CustomerUpdateComponent;
let fixture: ComponentFixture<CustomerUpdateComponent>;
let service: CustomerService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerUpdateComponent]
})
.overrideTemplate(CustomerUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Customer(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.customer = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Customer();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.customer = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerComponent } from 'app/entities/customer/customer.component';
import { CustomerService } from 'app/entities/customer/customer.service';
import { Customer } from 'app/shared/model/customer.model';
describe('Component Tests', () => {
describe('Customer Management Component', () => {
let comp: CustomerComponent;
let fixture: ComponentFixture<CustomerComponent>;
let service: CustomerService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(CustomerComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Customer(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Customer(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Customer(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@ -0,0 +1,106 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import { CustomerService } from 'app/entities/customer/customer.service';
import { ICustomer, Customer } from 'app/shared/model/customer.model';
describe('Service Tests', () => {
describe('Customer Service', () => {
let injector: TestBed;
let service: CustomerService;
let httpMock: HttpTestingController;
let elemDefault: ICustomer;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(CustomerService);
httpMock = injector.get(HttpTestingController);
elemDefault = new Customer(0, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign({}, elemDefault);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Customer', async () => {
const returnedFromService = Object.assign(
{
id: 0
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.create(new Customer(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Customer', async () => {
const returnedFromService = Object.assign(
{
number: 1,
prefix: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Customer', async () => {
const returnedFromService = Object.assign(
{
number: 1,
prefix: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Customer', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipDeleteDialogComponent } from 'app/entities/membership/membership-delete-dialog.component';
import { MembershipService } from 'app/entities/membership/membership.service';
describe('Component Tests', () => {
describe('Membership Management Delete Component', () => {
let comp: MembershipDeleteDialogComponent;
let fixture: ComponentFixture<MembershipDeleteDialogComponent>;
let service: MembershipService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipDeleteDialogComponent]
})
.overrideTemplate(MembershipDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(MembershipService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipDetailComponent } from 'app/entities/membership/membership-detail.component';
import { Membership } from 'app/shared/model/membership.model';
describe('Component Tests', () => {
describe('Membership Management Detail Component', () => {
let comp: MembershipDetailComponent;
let fixture: ComponentFixture<MembershipDetailComponent>;
const route = ({ data: of({ membership: new Membership(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(MembershipDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.membership).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipUpdateComponent } from 'app/entities/membership/membership-update.component';
import { MembershipService } from 'app/entities/membership/membership.service';
import { Membership } from 'app/shared/model/membership.model';
describe('Component Tests', () => {
describe('Membership Management Update Component', () => {
let comp: MembershipUpdateComponent;
let fixture: ComponentFixture<MembershipUpdateComponent>;
let service: MembershipService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipUpdateComponent]
})
.overrideTemplate(MembershipUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(MembershipService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Membership(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.membership = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Membership();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.membership = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipComponent } from 'app/entities/membership/membership.component';
import { MembershipService } from 'app/entities/membership/membership.service';
import { Membership } from 'app/shared/model/membership.model';
describe('Component Tests', () => {
describe('Membership Management Component', () => {
let comp: MembershipComponent;
let fixture: ComponentFixture<MembershipComponent>;
let service: MembershipService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(MembershipComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(MembershipService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Membership(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Membership(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Membership(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@ -0,0 +1,136 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { MembershipService } from 'app/entities/membership/membership.service';
import { IMembership, Membership } from 'app/shared/model/membership.model';
describe('Service Tests', () => {
describe('Membership Service', () => {
let injector: TestBed;
let service: MembershipService;
let httpMock: HttpTestingController;
let elemDefault: IMembership;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(MembershipService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Membership(0, currentDate, currentDate);
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
sinceDate: currentDate.format(DATE_FORMAT),
untilDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Membership', async () => {
const returnedFromService = Object.assign(
{
id: 0,
sinceDate: currentDate.format(DATE_FORMAT),
untilDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
sinceDate: currentDate,
untilDate: currentDate
},
returnedFromService
);
service
.create(new Membership(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Membership', async () => {
const returnedFromService = Object.assign(
{
sinceDate: currentDate.format(DATE_FORMAT),
untilDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
sinceDate: currentDate,
untilDate: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Membership', async () => {
const returnedFromService = Object.assign(
{
sinceDate: currentDate.format(DATE_FORMAT),
untilDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
sinceDate: currentDate,
untilDate: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Membership', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareDeleteDialogComponent } from 'app/entities/share/share-delete-dialog.component';
import { ShareService } from 'app/entities/share/share.service';
describe('Component Tests', () => {
describe('Share Management Delete Component', () => {
let comp: ShareDeleteDialogComponent;
let fixture: ComponentFixture<ShareDeleteDialogComponent>;
let service: ShareService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareDeleteDialogComponent]
})
.overrideTemplate(ShareDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ShareService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareDetailComponent } from 'app/entities/share/share-detail.component';
import { Share } from 'app/shared/model/share.model';
describe('Component Tests', () => {
describe('Share Management Detail Component', () => {
let comp: ShareDetailComponent;
let fixture: ComponentFixture<ShareDetailComponent>;
const route = ({ data: of({ share: new Share(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(ShareDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.share).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareUpdateComponent } from 'app/entities/share/share-update.component';
import { ShareService } from 'app/entities/share/share.service';
import { Share } from 'app/shared/model/share.model';
describe('Component Tests', () => {
describe('Share Management Update Component', () => {
let comp: ShareUpdateComponent;
let fixture: ComponentFixture<ShareUpdateComponent>;
let service: ShareService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareUpdateComponent]
})
.overrideTemplate(ShareUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ShareService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Share(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.share = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Share();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.share = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareComponent } from 'app/entities/share/share.component';
import { ShareService } from 'app/entities/share/share.service';
import { Share } from 'app/shared/model/share.model';
describe('Component Tests', () => {
describe('Share Management Component', () => {
let comp: ShareComponent;
let fixture: ComponentFixture<ShareComponent>;
let service: ShareService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(ShareComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ShareService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Share(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Share(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Share(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@ -0,0 +1,135 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { ShareService } from 'app/entities/share/share.service';
import { IShare, Share, ShareAction } from 'app/shared/model/share.model';
describe('Service Tests', () => {
describe('Share Service', () => {
let injector: TestBed;
let service: ShareService;
let httpMock: HttpTestingController;
let elemDefault: IShare;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(ShareService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Share(0, currentDate, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
date: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Share', async () => {
const returnedFromService = Object.assign(
{
id: 0,
date: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
date: currentDate
},
returnedFromService
);
service
.create(new Share(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Share', async () => {
const returnedFromService = Object.assign(
{
date: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
quantity: 1,
comment: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
date: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Share', async () => {
const returnedFromService = Object.assign(
{
date: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
quantity: 1,
comment: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
date: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Share', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});