Model customers.
This commit is contained in:
@@ -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();
|
||||
})
|
||||
));
|
||||
});
|
||||
});
|
||||
});
|
@@ -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 }));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -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);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
@@ -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']);
|
||||
});
|
||||
});
|
||||
});
|
@@ -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(
|
||||
{
|
||||
documentDate: currentDate.format(DATE_FORMAT),
|
||||
validFrom: currentDate.format(DATE_FORMAT),
|
||||
validUntil: currentDate.format(DATE_FORMAT),
|
||||
lastUsed: currentDate.format(DATE_FORMAT),
|
||||
cancellationDate: 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,
|
||||
documentDate: currentDate.format(DATE_FORMAT),
|
||||
validFrom: currentDate.format(DATE_FORMAT),
|
||||
validUntil: currentDate.format(DATE_FORMAT),
|
||||
lastUsed: currentDate.format(DATE_FORMAT),
|
||||
cancellationDate: currentDate.format(DATE_FORMAT)
|
||||
},
|
||||
elemDefault
|
||||
);
|
||||
const expected = Object.assign(
|
||||
{
|
||||
documentDate: currentDate,
|
||||
validFrom: currentDate,
|
||||
validUntil: currentDate,
|
||||
lastUsed: currentDate,
|
||||
cancellationDate: 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',
|
||||
documentDate: currentDate.format(DATE_FORMAT),
|
||||
validFrom: currentDate.format(DATE_FORMAT),
|
||||
validUntil: currentDate.format(DATE_FORMAT),
|
||||
lastUsed: currentDate.format(DATE_FORMAT),
|
||||
cancellationDate: currentDate.format(DATE_FORMAT),
|
||||
remark: 'BBBBBB'
|
||||
},
|
||||
elemDefault
|
||||
);
|
||||
|
||||
const expected = Object.assign(
|
||||
{
|
||||
documentDate: currentDate,
|
||||
validFrom: currentDate,
|
||||
validUntil: currentDate,
|
||||
lastUsed: currentDate,
|
||||
cancellationDate: 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',
|
||||
documentDate: currentDate.format(DATE_FORMAT),
|
||||
validFrom: currentDate.format(DATE_FORMAT),
|
||||
validUntil: currentDate.format(DATE_FORMAT),
|
||||
lastUsed: currentDate.format(DATE_FORMAT),
|
||||
cancellationDate: currentDate.format(DATE_FORMAT),
|
||||
remark: 'BBBBBB'
|
||||
},
|
||||
elemDefault
|
||||
);
|
||||
const expected = Object.assign(
|
||||
{
|
||||
documentDate: currentDate,
|
||||
validFrom: currentDate,
|
||||
validUntil: currentDate,
|
||||
lastUsed: currentDate,
|
||||
cancellationDate: 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();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user