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

Inline assertions on facets #64

Merged
merged 5 commits into from
Dec 23, 2023
Merged

Inline assertions on facets #64

merged 5 commits into from
Dec 23, 2023

Conversation

nedtwigg
Copy link
Member

@nedtwigg nedtwigg commented Dec 22, 2023

We should be able to do inline assertions on facets too. There are a few subtleties here worth mentioning:

  • expectSelfie(blah).facet("md").toBe("blah blah") is pretty straightforward
  • expectSelfie(blah).facets("links", "md").toBe... is also straightforward, but with a twist, we need to do the escaping from a SnapshotFile so that the facets are unambiguous from each other:
    • ╔═ [links] ═╗
      https://foo.com
      https://bar.com
      ╔═ [md] ═╗
      # This is not a great example
      ...but it *does* get a little bit across.
      
  • likewise, if we switch the order and ask for "md", "links", the order the facets are printed should be swapped
  • when we ask for the subject and some facets, we either preface it with ╔═ ═╗ (weird) or nothing. With the one odd side effect that we are sort of requiring the root snapshot to be first in the list, which is okay.

Right now, we have one constraint which is that the facets must be displayed in alpha order, because we don't have access to SnapshotFile's internals, and it always sorts its keys. To fix this, we'll need to move the Selfie API into the common project, which is already a good idea for other reasons.

@nedtwigg nedtwigg merged commit 972d8f9 into main Dec 23, 2023
6 checks passed
@nedtwigg nedtwigg deleted the feat/inline-facet-assertion branch December 23, 2023 01:58
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.

1 participant