I have this widget that I want to test:
StreamBuilder(
key: Key("usernameField"),
stream: _bloc.usernameField,
builder: (context, snapshot) {
return TextField(
onChanged: (val) => _bloc.usernameAddition.add(val),
decoration: InputDecoration(
prefixIcon: Icon(Icons.person),
labelText: 'Username',
errorText: snapshot.error));
},
but I don´t know how to simulate the insertion of text by the user. I tried to insert the values directly to _bloc, but the test fails (and also is not what I want to achieve, but was just a try):
_bloc.usernameAddition.add("a");
await tester.pump();
_bloc.usernameAddition.add("");
await tester.pump();
expect(find.text("Insert username"), findsOneWidget);
Aucun commentaire:
Enregistrer un commentaire