import { TestBed } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import { CustomersState } from './customers.state';
import { CustomersStateFacade } from './customers.facade';
import { of } from 'rxjs';
import * as CustomersSelectors from './customers.selectors';

fdescribe('#CustomersStateFacade', () => {
  let facade: CustomersStateFacade;
  let store: jasmine.SpyObj<Store<CustomersState>>;

  const id = 123;

  beforeEach(async () => {
    TestBed.configureTestingModule({
      providers: [
        CustomersStateFacade,
        {
          provide: Store,
          useValue: jasmine.createSpyObj<Store<CustomersState>>('store', {
            select: of({}),
          }),
        },
      ],
    });
  });

  beforeEach(() => {
    facade = TestBed.inject(CustomersStateFacade);
    store = TestBed.inject(Store);
  });

  it('should be created', () => {
    expect(facade instanceof CustomersStateFacade).toBeTruthy();
  });

  describe('#getGeneralAddress$', () => {
    it('should select the general address from store', () => {
      facade.getGeneralAddress$(id);

      expect(store.select).toHaveBeenCalledWith(CustomersSelectors.selectGeneralAddress, id);
    });
  });
});
