import Bank from '../index'

describe('connected Bank', () => {
  const connectedTestbed = createTestbed(
    withContext(Bank, { banks: {
      1: { title: 'Very distinctive name', updatedAt: Date.now() }
    }, bankSearch: { interactionTypes: [] }, qtiImports: {} }), {
      bankId: '1',
      isCompact: true,
      navigateToBanks: () => {},
      navigateToBankEntry: () => {}
    })

  const fetchStub = sinon.stub()

  useFakeFetching({
    dispatchStub: sinon.stub(),
    getStateStub: sinon.stub(),
    fetchStub
  })

  it('fetches bank on mount', () => {
    connectedTestbed.render()
    expect(fetchStub).to.have.been.calledWith('/api/banks/1')
  })

  it('finds bank in store', () => {
    connectedTestbed.render()
    expect(connectedTestbed.getText()).to.include('Very distinctive name')
  })
})
