Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusion regarding a line of code #1089

Closed
literalEval opened this issue Dec 29, 2021 · 11 comments
Closed

Confusion regarding a line of code #1089

literalEval opened this issue Dec 29, 2021 · 11 comments
Labels
test Testing application unapproved Unapproved, needs to be triaged

Comments

@literalEval
Copy link
Member

While writing test for custom_alert_dialog.dart, I came across a piece of code which I think might me wrong.

widgets/custom_alert_dialog.dart -> line 31
code

I think it should execute secondaryButtonTap.
So the code should be onTap: () => secondaryButtonTap(): navigationService.pop()

Or am I missing something ? Please clarify.

@github-actions github-actions bot added test Testing application unapproved Unapproved, needs to be triaged labels Dec 29, 2021
@CyberWake
Copy link
Contributor

The piece of code written over is perfect. If you see the custom alert dialog there are two buttons one for the positive response and the other for a negative so on a negative response the dialog should pop definitely whereas when there is some more logic to be added like after the negative response if something has to be done in the caller state than the secondaryButtonTap function is needed to be called with the logic to close the dialog.
Whereas if there is nothing to be done then you need not pass this function since it is nullable and if this case goes true then automatically navigationService.pop() statement is executed.
Provided that onTap: () => secondaryButtonTap(): navigationService.pop() this is a invalid dart syntax

@CyberWake
Copy link
Contributor

Let me know if your doubt is cleared if so please close the issue or we can discuss more on slack

@literalEval
Copy link
Member Author

literalEval commented Dec 29, 2021

Yeah I get that, and that's why I asked where in the file is secondaryButtonTap called ? Nowhere I guess. So I thought this was it's place (for obvious reasons).

And about syntax, I wrote just a pseudo-code, like if secondaryButtonTap is defined, call it, otherwise pop. That's not dart, I know. :)

So the question remains, where is secondaryButtonTap supposed to be called ?

@literalEval
Copy link
Member Author

I think this is the required behavior.

navigator

@literalEval
Copy link
Member Author

If someone can help in this, I have to write tests for this file.

@CyberWake
Copy link
Contributor

I think this is the required behavior.

navigator

using this would be a more prone method since this will require not to write the dialog closing logic making it less robust. If there needs to be a logic or a negative response and the method is passed for the same then closing logic should also be handled explicitly.

@literalEval
Copy link
Member Author

So what's the solution ? The method needs to be called somewhere (which isn't being done). Or it doesn't ?

@CyberWake
Copy link
Contributor

if the function is passed than dialog closing logic should be handled explicitly in the method passed else is the method isn't passed then nothing needs to be done.

@literalEval
Copy link
Member Author

So basically there should be no else block, only the if block. Right ?

I think this is the required behavior.

navigator

@CyberWake
Copy link
Contributor

there is no change needed.

@literalEval
Copy link
Member Author

Okay. Fine.

Ayush0Chaudhary pushed a commit to Ayush0Chaudhary/talawa that referenced this issue Mar 29, 2023
* test: testing for all cls-hooked functions

* tests for requestContext done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Testing application unapproved Unapproved, needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants