-
Notifications
You must be signed in to change notification settings - Fork 0
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
Endpoints name #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excelente Flor! deje algunas sugerencias :)
} | ||
|
||
_getResponseClassFor(endpoint) { | ||
return this._expectedResponses[endpoint.constructor.name]; | ||
return this._expectedResponses[endpoint.name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si JS no permite redefinir el ==
una opción es definir un método equals
, pero bueno no podrias usar aca []
tendrias que hacer algo de la pinta Object.keys(this._expectedResponses).find( eachEndpoint) => eachEndpoint.equals(endpoint))
@@ -369,4 +369,29 @@ test('When using fake requester default response can be overwritten', async () = | |||
|
|||
// Then the response is handled by the custom response handler | |||
expect(response).toBe(AnotherTestSuccessfulApiResponse.defaultResponse()); | |||
}); | |||
|
|||
test('When using fake requester only endpoint added to Fakerequester is overwritten', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solo para molestar :). Quitas estaria bueno tener un test que ejercite que se puede tener una respuesta diferente para la misma url pero diferente method (get vs post o post vs put)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noo está perfecto, sumado! como lo habíamos hablado lo sume de una pero tiene sentido que este el test 😃
test/errorHandling.test.js
Outdated
const apiClient = new ApiClient(requester); | ||
|
||
// I can create two get endpoint | ||
const getEndpoint = endpointWithResponses([TestSuccessfulApiResponse]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aca le pondria el parametro de la url de forma explicita para que se vea a primera vista que son diferentes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
me parece bien, cambiado!
Changes
Now endpoints can be used in fakeRequester even if they are created from constructor.
Before all of them were named the same, so it would change response for all of them.