gurleensethi / sailor

Easy page navigation and management in Flutter apps.
https://pub.dev/packages/sailor
MIT License
145 stars 24 forks source link

Mocking for Sailor.args #19

Open Zerstoren opened 4 years ago

Zerstoren commented 4 years ago

I started using Sailor to implement routing, but I encountered a problem in tests. If Sailor can still be instantiated in Dependenct Injection and using Mockito for check the result of widgets including navigation, but methods for getting arguments are impossible mock. In order not to violate the area of responsibility, I can not move the receipt of arguments.

The simplest solution: in the instance Sailor add the same method args that will reference to the static method.

gurleensethi commented 4 years ago

Hi @Zerstoren Can you please provide more details along with code samples (as many as possible) of what you are having trouble with and what you are trying to achieve.

Zerstoren commented 4 years ago

As example

Bloc provider show page, but for loading data i need to get args

    return BlocProvider(
      builder: (_) {
        widget.blocInstance.add(
          ShowBoardEvent(
            accountName:
                Sailor.args<BoardPageArgs>(context).accountName,
          ),
        );

        return widget.blocInstance;
      },

But in tests I can't mock this static method

Sailor.args<BoardPageArgs>(context)