This repository has been archived by the owner on Aug 17, 2024. It is now read-only.
Building some command-line tests for blocks #41
Merged
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.
Testing things by mousing and clicking is annoying, so I built a command-line widget to load the blocks code and generate some text (but not eval it, yet).
This depends on #39 and #40 - please merge those first.
npm run test
in the project's root directory to run it.tests/test.js
reads./index.html
from standard input, finds all the blocks scripts, and eval's them.In order for those eval's to work,
tests/test.js
defines simplified placeholders for the things the blocks need as they load up. (I figured this out by looking at "cannot find" error messages as blocks loaded and implementing each thing one by one.)There is then an object
Tests
that has a bunch of tests, each written as a single function of no arguments with a meaningful name as its key. We loop over those, calling each function in turn; those functions create blocks, and we display the text they would generate.This still requires manual inspection of output, but it's a step toward being able to check blocks without having to reload, drag, and click. The next steps will be to implement tests for the other blocks in
generators/js/*.js
and then add checks inside the tests to compare the actually-generated code with what we're expecting.