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

Endpoints name #4

Merged
merged 3 commits into from
Jul 23, 2024
Merged

Endpoints name #4

merged 3 commits into from
Jul 23, 2024

Conversation

Florencia-97
Copy link
Contributor

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.

Copy link

@jburella jburella left a 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];

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 () => {

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)

Copy link
Contributor Author

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 😃

const apiClient = new ApiClient(requester);

// I can create two get endpoint
const getEndpoint = endpointWithResponses([TestSuccessfulApiResponse]);

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me parece bien, cambiado!

@Florencia-97 Florencia-97 merged commit 8b8d7aa into main Jul 23, 2024
4 checks passed
@Florencia-97 Florencia-97 deleted the endpoint-equality branch July 23, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants