adventures-in / chat_app

A group effort to build a chat app and learn as we go.
18 stars 0 forks source link

Decouple the ConversationsList widget from the Firestore instance #168

Open gaslitbytech opened 4 years ago

gaslitbytech commented 4 years ago

To help with unit testing we need to decouple the ConversationsList widget from the Firestore instance. We can just move the Firestore call into the DatabaseService alongside the other Firebase calls then in the widget use the Provider to get the DatabaseService.

In a widget test we can then wrap the ConversationsList widget in a Provider that provides a mocked DatabaseService (that returns a stream with whatever test data we want the widget to receive)

nickmeinhold commented 4 years ago

@tourdownunder in case it's helpful - one trick I like (when the SUT gets input from a stream) is to create a Fake that takes a StreamController in it's constructor, then in the test you can push events into the stream with the controller.

nickmeinhold commented 4 years ago

@tourdownunder can we close this issue? I think maybe it was part of #180 ?