1
0

Preliminary completed customer model.

This commit is contained in:
Michael Hierweck
2019-04-24 13:08:27 +02:00
parent c6be30895e
commit 2a4ee0507c
178 changed files with 17031 additions and 10 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,142 @@
/* 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, currentDate, AssetAction.PAYMENT, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: 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,
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: 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(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
amount: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: 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(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
amount: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: 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 { 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,174 @@
/* 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 { CustomerService } from 'app/entities/customer/customer.service';
import { ICustomer, Customer, CustomerKind, VatRegion } from 'app/shared/model/customer.model';
describe('Service Tests', () => {
describe('Customer Service', () => {
let injector: TestBed;
let service: CustomerService;
let httpMock: HttpTestingController;
let elemDefault: ICustomer;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(CustomerService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Customer(
0,
0,
'AAAAAAA',
'AAAAAAA',
CustomerKind.NATURAL,
currentDate,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
VatRegion.DOMESTIC,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA'
);
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
birthDate: 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 Customer', async () => {
const returnedFromService = Object.assign(
{
id: 0,
birthDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
birthDate: currentDate
},
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(
{
reference: 1,
prefix: 'BBBBBB',
name: 'BBBBBB',
kind: 'BBBBBB',
birthDate: currentDate.format(DATE_FORMAT),
birthPlace: 'BBBBBB',
registrationCourt: 'BBBBBB',
registrationNumber: 'BBBBBB',
vatRegion: 'BBBBBB',
vatNumber: 'BBBBBB',
contractualSalutation: 'BBBBBB',
contractualAddress: 'BBBBBB',
billingSalutation: 'BBBBBB',
billingAddress: 'BBBBBB',
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
birthDate: 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 Customer', async () => {
const returnedFromService = Object.assign(
{
reference: 1,
prefix: 'BBBBBB',
name: 'BBBBBB',
kind: 'BBBBBB',
birthDate: currentDate.format(DATE_FORMAT),
birthPlace: 'BBBBBB',
registrationCourt: 'BBBBBB',
registrationNumber: 'BBBBBB',
vatRegion: 'BBBBBB',
vatNumber: 'BBBBBB',
contractualSalutation: 'BBBBBB',
contractualAddress: 'BBBBBB',
billingSalutation: 'BBBBBB',
billingAddress: 'BBBBBB',
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
birthDate: 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 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,152 @@
/* 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, currentDate, currentDate, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: 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,
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
admissionDocumentDate: currentDate,
cancellationDocumentDate: currentDate,
memberFromDate: currentDate,
memberUntilDate: 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(
{
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
admissionDocumentDate: currentDate,
cancellationDocumentDate: currentDate,
memberFromDate: currentDate,
memberUntilDate: 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(
{
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
admissionDocumentDate: currentDate,
cancellationDocumentDate: currentDate,
memberFromDate: currentDate,
memberUntilDate: 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 { SepaMandateDeleteDialogComponent } from 'app/entities/sepa-mandate/sepa-mandate-delete-dialog.component';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
describe('Component Tests', () => {
describe('SepaMandate Management Delete Component', () => {
let comp: SepaMandateDeleteDialogComponent;
let fixture: ComponentFixture<SepaMandateDeleteDialogComponent>;
let service: SepaMandateService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateDeleteDialogComponent]
})
.overrideTemplate(SepaMandateDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(SepaMandateService);
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 { SepaMandateDetailComponent } from 'app/entities/sepa-mandate/sepa-mandate-detail.component';
import { SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Component Tests', () => {
describe('SepaMandate Management Detail Component', () => {
let comp: SepaMandateDetailComponent;
let fixture: ComponentFixture<SepaMandateDetailComponent>;
const route = ({ data: of({ sepaMandate: new SepaMandate(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(SepaMandateDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.sepaMandate).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 { SepaMandateUpdateComponent } from 'app/entities/sepa-mandate/sepa-mandate-update.component';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
import { SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Component Tests', () => {
describe('SepaMandate Management Update Component', () => {
let comp: SepaMandateUpdateComponent;
let fixture: ComponentFixture<SepaMandateUpdateComponent>;
let service: SepaMandateService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateUpdateComponent]
})
.overrideTemplate(SepaMandateUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(SepaMandateService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new SepaMandate(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.sepaMandate = 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 SepaMandate();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.sepaMandate = 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 { SepaMandateComponent } from 'app/entities/sepa-mandate/sepa-mandate.component';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
import { SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Component Tests', () => {
describe('SepaMandate Management Component', () => {
let comp: SepaMandateComponent;
let fixture: ComponentFixture<SepaMandateComponent>;
let service: SepaMandateService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(SepaMandateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(SepaMandateService);
});
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 SepaMandate(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.sepaMandates[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 SepaMandate(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.sepaMandates[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 SepaMandate(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.sepaMandates[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,176 @@
/* 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 { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
import { ISepaMandate, SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Service Tests', () => {
describe('SepaMandate Service', () => {
let injector: TestBed;
let service: SepaMandateService;
let httpMock: HttpTestingController;
let elemDefault: ISepaMandate;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(SepaMandateService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new SepaMandate(
0,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
currentDate,
currentDate,
currentDate,
currentDate,
currentDate,
'AAAAAAA'
);
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: 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 SepaMandate', async () => {
const returnedFromService = Object.assign(
{
id: 0,
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
grantingDocumentDate: currentDate,
revokationDocumentDate: currentDate,
validFromDate: currentDate,
validUntilDate: currentDate,
lastUsedDate: currentDate
},
returnedFromService
);
service
.create(new SepaMandate(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 SepaMandate', async () => {
const returnedFromService = Object.assign(
{
reference: 'BBBBBB',
iban: 'BBBBBB',
bic: 'BBBBBB',
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
grantingDocumentDate: currentDate,
revokationDocumentDate: currentDate,
validFromDate: currentDate,
validUntilDate: currentDate,
lastUsedDate: 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 SepaMandate', async () => {
const returnedFromService = Object.assign(
{
reference: 'BBBBBB',
iban: 'BBBBBB',
bic: 'BBBBBB',
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
grantingDocumentDate: currentDate,
revokationDocumentDate: currentDate,
validFromDate: currentDate,
validUntilDate: currentDate,
lastUsedDate: 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 SepaMandate', 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,142 @@
/* 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, currentDate, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: 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,
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: 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(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
quantity: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: 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(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
quantity: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: 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();
});
});
});