/* 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 { FaeBooTestModule } from '../../../test.module';
import { AccountDetailsComponent } from 'app/entities/account-details/account-details.component';
import { AccountDetailsService } from 'app/entities/account-details/account-details.service';
import { AccountDetails } from 'app/shared/model/account-details.model';

describe('Component Tests', () => {
    describe('AccountDetails Management Component', () => {
        let comp: AccountDetailsComponent;
        let fixture: ComponentFixture<AccountDetailsComponent>;
        let service: AccountDetailsService;

        beforeEach(() => {
            TestBed.configureTestingModule({
                imports: [FaeBooTestModule],
                declarations: [AccountDetailsComponent],
                providers: []
            })
                .overrideTemplate(AccountDetailsComponent, '')
                .compileComponents();

            fixture = TestBed.createComponent(AccountDetailsComponent);
            comp = fixture.componentInstance;
            service = fixture.debugElement.injector.get(AccountDetailsService);
        });

        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 AccountDetails(123)],
                        headers
                    })
                )
            );

            // WHEN
            comp.ngOnInit();

            // THEN
            expect(service.query).toHaveBeenCalled();
            expect(comp.accountDetails[0]).toEqual(jasmine.objectContaining({ id: 123 }));
        });
    });
});
