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

Mock resources #215

Merged
merged 7 commits into from
Jul 14, 2020
Merged

Mock resources #215

merged 7 commits into from
Jul 14, 2020

Conversation

kilchenmann
Copy link
Contributor

@kilchenmann kilchenmann commented Jul 9, 2020

This PR contains:

  • refactor file names for mocked test data
  • export of additional mocked test data: list of resources as ReadResourceSequence; needed for PR #122 in ui-lib

@kilchenmann kilchenmann marked this pull request as draft July 9, 2020 13:50
@kilchenmann kilchenmann self-assigned this Jul 9, 2020
@tobiasschweizer
Copy link
Contributor

@kilchenmann What is this PR about?

@tobiasschweizer
Copy link
Contributor

Would you like to resolve #62?

@kilchenmann
Copy link
Contributor Author

kilchenmann commented Jul 9, 2020

Would you like to resolve #62?

Not primary. I wanted to add a resources-mock file in test/data and saw the different names for the other mock-files. So, the first two commits here were only to make the mock data file names more consistent.

What is this PR about?

I have to mock a ReadResourceSequence to use for the tests in ui-lib. I will add a description to the PR soon.
Let me know if this is the wrong way. We talked about it in the scrum meeting today.

@tobiasschweizer
Copy link
Contributor

Would you like to resolve #62?

Not primary. I wanted to add a resources-mock file in test/data and saw the different names for the other mock-files. So, the first two commits here were only to make the mock data file names more consistent.

What is this PR about?

I have to mock a ReadResourceSequence to use for the tests in ui-lib. I will add a description to the PR soon.
Let me know if this is the wrong way. We talked about it in the scrum meeting today.

I understand. Sorry, I didn't get it in the first place. Maybe you could just make a mock that returns a ReadResourceSequence and internally calls MockResourcegetTestthing(). Just make sure that the sequence contains different instances of testthing (objects are reference types). Just call MockResource.getTestthing() as many times as there are elements in the mocked ReadResourceSequence .

Otherwise I can help you with that next week.

@kilchenmann kilchenmann marked this pull request as ready for review July 14, 2020 09:52
test/data/api/v2/mock-resources.ts Outdated Show resolved Hide resolved
@@ -59,4 +59,22 @@ export namespace MockResource {

};

export const getTesthings = (length = 25): Observable<ReadResourceSequence> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want, you could pass a Boolean arg that would set mayHaveMoreResults. Maybe that could be useful for testing the search result component?

Copy link
Contributor Author

@kilchenmann kilchenmann Jul 14, 2020

Choose a reason for hiding this comment

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

Yes, why not!?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in
af0d0d6

Comment on lines +62 to +73
export const getTesthings = (length = 25, mayHaveMoreResults = false): Observable<ReadResourceSequence> => {

const resources: Array<Observable<ReadResource>> = new Array(length).fill(0).map(
() => {
return getTestthing();
}
);

return forkJoin(resources).pipe(
map(
(res: ReadResource[]) => {
return new ReadResourceSequence(res, mayHaveMoreResults);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tobiasschweizer That should work like this, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think so.

Copy link
Contributor

@tobiasschweizer tobiasschweizer left a comment

Choose a reason for hiding this comment

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

I think this PR is good to go now.

@kilchenmann
Copy link
Contributor Author

I think this PR is good to go now.

Thanks

@kilchenmann kilchenmann merged commit 80aaef3 into master Jul 14, 2020
@kilchenmann kilchenmann deleted the wip/export-mock-resources branch July 14, 2020 15:11
@kilchenmann kilchenmann added the enhancement Improve existing code or new feature label Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing code or new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants