-
-
Couldn't load subscription status.
- Fork 624
test: unit tests for block type guards #2103
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
Conversation
… is a subset of those in the schema
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
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.
Easy enough, just a nice to have case to add
|
Also @YousefED we talked on call yesterday about whether to put additional tests in the |
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.
approved.
do the fixes to the source file mean there were bugs in the implementation btw?
(created separate ticket for testing discussion)
|
Yeah the editorHasBlockWithType(editor, "paragraph", {
textAlignment: {
default: "left",
values: ["left", "center", "right", "justify"]
}
})and now it's just: editorHasBlockWithType(editor, "paragraph", {
textAlignment: {
default: "left",
values: ["justify"]
}
}) |
|
Cool, proofs the value of investing in these tests :)
Op vr 17 okt 2025, 11:26 schreef Matthew Lipski ***@***.***>:
… *matthewlipski* left a comment (TypeCellOS/BlockNote#2103)
<#2103 (comment)>
Yeah the !== undefined additions are to fix bugs, since things like empty
strings set as default props would cause issues. Not sure if other change
with values counts as a fix or not, it just makes it easier e.g. if you
want to see if the textAlignment prop allows for "justify" alignment.
You'd previously have to check with:
editorHasBlockWithType(editor, "paragraph", {
textAlignment: {
default: "left",
values: ["left", "center", "right", "justify"]
}})
and now it's just:
editorHasBlockWithType(editor, "paragraph", {
textAlignment: {
default: "left",
values: ["justify"]
}})
—
Reply to this email directly, view it on GitHub
<#2103 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC2BWNLFGJ6N3LUYURFZV33YCY4LAVCNFSM6AAAAACJFJNP26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMJUGYZDAMBYGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Summary
This PR adds unit tests for
editorHasBlockWithType.The code for
editorHasBlockWithTypehas also been changed slightly - when checking for a block with a givenpropSchemaandvalues, thevaluescan be an unordered subset of the ones in the schema. Previously, the 2 arrays had to be identical in order for the type guard to returntrue.Rationale
Needed for #2096 and useful in general.
Changes
See above.
Impact
N/A
Testing
See above.
Screenshots/Video
N/A
Checklist
Additional Notes