This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains tests for the APIRef macro. I'm writing tests as part of mdn/sprints#1313: after this is merged the next step would be to update the macro (and its tests) to handle the way we are now representing events.
I don't think this tests every edge case. But APIRef's behavior is quite complex especially as it's very dependent on various data sources (subpages, GroupData, InterfaceData, L10n-Common). So I've tried to cover the main cases while trying to keep the size of test under control.
I've been guided by this comment: #1080 (comment) in writing this test, so I thought it might be worth going through that here:
Tested: we set this as the slug and check the result.
Tested: we try setting the slug to a subpage and check the result.
Tested: we have test data with no ctors, one property, three methods. We have tests for no badges, on badge, two badges, and all the badges.
We have tests for the bit of code referred to here, as some of our example pages use
TestInterface.MethodName
in the title.Tested: the fr locale doesn't have translations, and we check that the link text includes the CTA ("[Traduire]").
Tested: we have a sample GroupData that includes interfaces, methods, and events.
Tested: we test passing a different argument, that doesn't match a GroupData entry.
Sort of tested: we only have one GroupData test file, but it contains a mix of stuff.
This isn't explicitly tested. I know that the macro will give bad output if GroupData contains bad strings. But we separately test the contents of GroupData, so it should be OK. We might want to consider fixing this, but I decided not to add it in this particular effort.
We test with a sample InterfaceData file that contains some inherited and implemented-by items.
See above. This is somewhat tested but not explicitly, just to keep this test from getting even bigger.
I've also fixed a bug in the macro that these tests found.