-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have StringCalculatorPage use host document
StringCalculatorPage no longer creates its own DocumentFragment with a new top level app element (<div id="app">). The constructor now takes the top level app element as its first argument, and an optional Document as its second argument. This enables it to continue wrapping documents created via the PageLoader from test/helpers.js, as used in main.test.js. The new static factory, StringCalculatorPage.new(), creates a new <div> with the specified ID, appends it document.body, and returns a new StaticCalculatorPage wrapping that app element. This tries to ensure that the <div>s created by tests don't collide with existing <div>s in the document (short of randomly generating its own IDs). StringCalculatorPage.new() also keeps track of instances it creates, and clients should call StringCalculatorPage.cleanup() in their afterEach() handlers. This ensures the host document returns to its original state after each test. --- As mentioned in the previous couple of commits, a <form> element attached to a DocumentFragment would exhibit inconsistent behavior across jsdom, Chrome, and Firefox. This new implementation solves that problem (as will be seen in the upcoming Calculator component tests). It would've been nice to use a DocumentFragment for all our tests instead of modifying the global document in any way. However, this way we can be more confident that our components will exhibit consistent behavior regardless of the test environment.
- Loading branch information
Showing
4 changed files
with
24 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters