gpt4 book ai didi

Flutter bloc emmitInOrder 不会发出初始状态,但会发出

转载 作者:行者123 更新时间:2023-12-03 14:55:12 26 4
gpt4 key购买 nike

所以我正在尝试对一个块进行单元测试

我的测试很简单

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();
});

所有者确实覆盖了等于和哈希

我的错误信息
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'>

所以它说它发出了初始状态,但没有发出?

最佳答案

我们有同样的错误。它是通过使用 equatable 修复的。

关于Flutter bloc emmitInOrder 不会发出初始状态,但会发出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58549772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com