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

Problems mocking MockConnection error response #7471

Closed
denchdev opened this issue Mar 7, 2016 · 7 comments
Closed

Problems mocking MockConnection error response #7471

denchdev opened this issue Mar 7, 2016 · 7 comments
Labels
needs reproduction This issue needs a reproduction in order for the team to investigate further

Comments

@denchdev
Copy link

denchdev commented Mar 7, 2016

I'm testing http service in Angular2. I want to test the server, the server responds 'Unauthorized Error'. In test I used this code:

this.backend.connections.subscribe(
            (connection: MockConnection) => {
                console.log("Connection");
                connection.mockError(<any>new Response(new ResponseOptions({status: 401, body: 'error'})));
            }
        );

In test I used handleError from angular.io..

It is the wrong decision. Tell me how to test this situation.

@RomanKisilenko
Copy link

Hi,

So the problem is that MockConnection method to mock error response accepts an instance of Error which does not allow to pass response object to error handler. Cast to any allows to bypass type checks so we can finally pass the response, but to me it looks like a dirty hack.

Is this a bug in MockConnection API or do we do something wrong?

Thank you,
Roman

@denchdev denchdev changed the title how to create a mockError with a parameter Response Problems mocking MockConnection error response Mar 9, 2016
@leovrf
Copy link

leovrf commented Mar 15, 2016

+1 interested on this.

@cbomkamp
Copy link

Anyone have a solution to this yet?

@dkro
Copy link

dkro commented Sep 23, 2016

+1 ... bump

@vicb
Copy link
Contributor

vicb commented Oct 4, 2016

Could somebody add a minimal repro ? thanks

@IgorMinar IgorMinar added needs reproduction This issue needs a reproduction in order for the team to investigate further and removed needs reproduction This issue needs a reproduction in order for the team to investigate further need: repro labels Oct 4, 2016
@pkozlowski-opensource
Copy link
Member

Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Please check out our submission guidelines to understand why we can't act on issues that are lacking important information.

If the problem still persists, please file a new issue and ensure you provide all of the required information when filling out the issue template.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs reproduction This issue needs a reproduction in order for the team to investigate further
Projects
None yet
Development

No branches or pull requests

8 participants