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

Convert unit tests to typescript. #34

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

drgrice1
Copy link
Member

This is built on top of #33 since it would conflict rather heavily with that pull request if it didn't (and it was created after that one).

I have been meaning to do this for a while, and it did reveal some things that needed to be fixed in the code (those were added in #33).

This does not require an npm package update since it is development tools only and doesn't change any of the code.

This is a more proper way of handling this sort of thing.  This was
observed in initial work on switching to using strict type checking.
This requires a few changes, but mostly they are just typings which
don't change the actual generated code.  There several eslint-ignore
statements added for this that should be removed (with some effort).

Note that the pray and prayDirection methods has been removed.  Checking
the conditions directly in place requires about the same amount of code,
and has the benifit of revealing proper typings (not undefined mainly)
to typescript if the error is not thrown.
WeBWorK doesn't use that, and I don't want to maintain it anymore.  I
don't see the point of a MathQuill instance that doesn't do many of the
the things that make MathQuill usefull.
Typescript continually has issues with that usage.  So now instead there
are "left" and "right" properties of nodes and the cursor.  The
direction type is just a type union of the strings 'left' and 'right'.

The advantages of a numeric value had already been taken away when this
project was initially converted to typescript.  For instance, you can't
multiply an enum value by -1 (to get the opposite direction).
Switch from an aria label on the hidden text area to hidden span that
the text area is aria labelledby. This was just merged in their code.

Also add the tabbable option.
That is, when focus is lost within the window any selection is cleared.
When focus is regained the contents are all selected.  When the window
focus is lost the current state is preserved, and when focus returns it
is still in that state.

There is a new `preventBlur` option that is a method that will be passed
the blur event and the MathQuill api object.  That method should return
true if blurring the input should be prevented, and false if it should
be allowed.  Note that in this case the caller will need to ensure to
call the `blur` method of the MathQuill api object later when the input
should be blurred.  This is for PG's toolbar.  When focus leaves the
MathQuill input and goes to the toolbar, the MathQuill input remains
active.

The keyboard tab button no longer is used for navigation within an
editable MathQuill input.  It now is purely used for the usual HTML tab
order navigation.  The escape button still has the navigation behavior
it had before, and the primary navigation within an editable MathQuill
input is via the arrow keys (the same as for a native HTML input). The
`spaceBehavesLikeTab` option is now the `enableSpaceNavigation` option
and does the same thing it did before.
This is set up to emulate behavior of natively selected text.
Remove the long deprecated "edited" and "reflow" aliases of the "edit"
handler.

The upOutOf and downOutOf handlers should not accept a direction
argument, so fix that.
I don't believe that this ever really worked in a useful way.  The unit
tests were a facade since they didn't work with an actual event.  A new
test has been added that does use an event.
…rWithCursor) option.

The focus handler still needs to run after a prevented blur, but a
select all should not occur.  So a more fine grained approach is needed.
If a blur is prevented, that needs to be saved and the focus handler
acts according to that saved state.

Also fix the 'select behaves correctly after blurring and re-focusing'
test.  That still doesn't work if the document is not visible.
screen reader span.

Also add the `text-align: left` and `overflow: hidden` styles to the
`mq-aria-alert` and `mq-mathspeak` spans.  This seems to be needed to
get inline static math to be read correctly.
This is also pulled from the Desmos code.  This looks nicer than trying
to use symbols scaled to the appropriate size.  That scaling was
gnerally not the best anyway.  This has the added advantage of not
needing to compute sizes.  Natural SVG scaling just works so much
better.

Also make the index a little bit larger and improve styling so that when
an nth root is selected the index is still visible.
Also move the public/support/assert.js to test/support/assert.ts and
have it export its symbols for import in the tests instead of loading it
in the browser.
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