[wp-trac] [WordPress Trac] #39264: Add WP-API JS Client unit tests to core
WordPress Trac
noreply at wordpress.org
Tue Feb 21 13:10:49 UTC 2017
#39264: Add WP-API JS Client unit tests to core
-----------------------------+------------------------------
Reporter: adamsilverstein | Owner: adamsilverstein
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.7.3
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: fixed-major | Focuses: javascript
-----------------------------+------------------------------
Comment (by adamsilverstein):
Replying to [comment:46 jnylen0]:
> @adamsilverstein I prefer my approach in
https://core.trac.wordpress.org/attachment/ticket/39264/39264.13.diff for
this. When a new core endpoint is added, the endpoint should be added to
this list and to the client fixture file. The easiest way to ensure this
is to make the test fail, which will happen with a strict equality check
but not with a foreach check.
Sounds reasonable, my tests would only fail if an endpoint were removed.
>
> I'm also curious why we need `assert && assert.equal` in your patch?
I added the asset && because if you load the qunit test screen via the
browser, and select a "module" such as wpapi, the nav-menus.js test file
still loads, and the value for `assert` is not set up, leaving to a JS
error:
[[Image(https://cl.ly/391h3r1s1V2c/Image%202017-02-21%20at%208.08.51%20AM.png)]]
Adding the assert check ensures this error doesn't occur. When I added the
nav-menus tests, I didn’t consider that the file could load without having
the tests run.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39264#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list