簡體   English   中英

Flutter bloc emmitInOrder 不會發出初始 state,但會發出

[英]Flutter bloc emmitInOrder doesn't emit initial state, but it does

所以我正在嘗試對一個集團進行單元測試

我的測試很簡單

test("When loading patients, bloc should emmit [Loading], [OwnersLoaded]", (){
      //arrange
      var owners = [Owner(id: "TestId")];
      when (mockPatientsRepository.getOwnersForCurrentPractice()).thenAnswer((_)=>Future.value(owners));
      final List<PatientsState> expected = [patientsBloc.initialState, Loading(), OwnersLoaded(owners)];

      //assert later
      expectLater(patientsBloc, emitsInOrder(expected));

      //act
      useCase.getPatients();
    }); 

所有者確實覆蓋等於和 hash

我的錯誤信息

Expected: should do the following in order:
          • emit an event that <Instance of 'InitialPatientsState'>
          • emit an event that <Instance of 'Loading'>
          • emit an event that <Instance of 'OwnersLoaded'>
  Actual: <Instance of 'PatientsBloc'>
   Which: emitted • Instance of 'InitialPatientsState'
                  • Instance of 'Loading'
                  • Instance of 'OwnersLoaded'
            which didn't emit an event that <Instance of 'InitialPatientsState'> 

所以它說它發出了最初的 state,但不是嗎?

我們有同樣的錯誤。 它是通過使用 equatable 修復的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM