Model customers.
This commit is contained in:
@@ -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']);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user