<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[40109] trunk: REST API: JS client - QUnit tests for custom namespace route discovery.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/40109">40109</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/40109","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>adamsilverstein</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-02-24 18:39:39 +0000 (Fri, 24 Feb 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: JS client - QUnit tests for custom namespace route discovery.

Add QUnit tests for the parsing of custom namespace routes. Add a custom schema fixture based on the `wp-js-widgets` plugin. Test that the client can parse the widget namespace in the schema and correctly construct the expected group of models and collections. Also includes a small unrelated QUnit fix to ensure nav-menu test passes when it is loaded without its tests executing as well as a small jshint fix, adding a missing semicolon since <a href="https://core.trac.wordpress.org/changeset/40107">[40107]</a>.

Props jnylen0.
Fixes <a href="https://core.trac.wordpress.org/ticket/39561">#39561</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjsthemejs">trunk/src/wp-admin/js/theme.js</a></li>
<li><a href="#trunktestsqunitfixtureswpapijs">trunk/tests/qunit/fixtures/wp-api.js</a></li>
<li><a href="#trunktestsqunitindexhtml">trunk/tests/qunit/index.html</a></li>
<li><a href="#trunktestsqunitwpadminjsnavmenujs">trunk/tests/qunit/wp-admin/js/nav-menu.js</a></li>
<li><a href="#trunktestsqunitwpincludesjswpapijs">trunk/tests/qunit/wp-includes/js/wp-api.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsqunitfixturesjswidgetsendpointjs">trunk/tests/qunit/fixtures/js-widgets-endpoint.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjsthemejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/theme.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/theme.js    2017-02-24 18:14:21 UTC (rev 40108)
+++ trunk/src/wp-admin/js/theme.js      2017-02-24 18:39:39 UTC (rev 40109)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1928,7 +1928,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // Open the theme preview.
</span><span class="cx" style="display: block; padding: 0 10px">                                self.view.collection.once( 'query:success', function() {
</span><span class="cx" style="display: block; padding: 0 10px">                                        $( 'div[data-slug="' + slug + '"]' ).trigger( 'click' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                })
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         });
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                });
</span></span></pre></div>
<a id="trunktestsqunitfixturesjswidgetsendpointjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/qunit/fixtures/js-widgets-endpoint.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/js-widgets-endpoint.js                         (rev 0)
+++ trunk/tests/qunit/fixtures/js-widgets-endpoint.js   2017-02-24 18:39:39 UTC (rev 40109)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,562 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* jshint -W109 */
+/* jshint unused:false */
+var jsWidgetsEndpointSchema =
+{
+    "namespace": "js-widgets\/v1",
+    "routes": {
+        "\/js-widgets\/v1": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "namespace": { "required": false, "default": "js-widgets\/v1" },
+                    "context": { "required": false, "default": "view" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1" }
+        },
+        "\/js-widgets\/v1\/widgets\/pages": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "sortby": { "required": false, "default": "menu_order", "enum": ["post_title", "menu_order", "ID"], "description": "How to sort the pages.", "type": "string" },
+                    "exclude": { "required": false, "default": [], "description": "Page IDs to exclude.", "type": ["array", "string"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/pages" }
+        },
+        "\/js-widgets\/v1\/widgets\/pages\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "sortby": { "required": false, "default": "menu_order", "enum": ["post_title", "menu_order", "ID"], "description": "How to sort the pages.", "type": "string" },
+                    "exclude": { "required": false, "default": [], "description": "Page IDs to exclude.", "type": ["array", "string"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "sortby": { "required": false, "enum": ["post_title", "menu_order", "ID"], "description": "How to sort the pages.", "type": "string" },
+                    "exclude": { "required": false, "description": "Page IDs to exclude.", "type": ["array", "string"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/calendar": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/calendar" }
+        },
+        "\/js-widgets\/v1\/widgets\/calendar\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/archives": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/archives" }
+        },
+        "\/js-widgets\/v1\/widgets\/archives\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "description": "Show post counts", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/meta": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/meta" }
+        },
+        "\/js-widgets\/v1\/widgets\/meta\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/search": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/search" }
+        },
+        "\/js-widgets\/v1\/widgets\/search\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/text": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "text": { "required": false, "description": "The content for the widget.", "type": ["string", "object"] },
+                    "filter": { "required": false, "default": false, "description": "Whether paragraphs will be added for double line breaks (wpautop).", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/text" }
+        },
+        "\/js-widgets\/v1\/widgets\/text\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "text": { "required": false, "description": "The content for the widget.", "type": ["string", "object"] },
+                    "filter": { "required": false, "default": false, "description": "Whether paragraphs will be added for double line breaks (wpautop).", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "text": { "required": false, "description": "The content for the widget.", "type": ["string", "object"] },
+                    "filter": { "required": false, "description": "Whether paragraphs will be added for double line breaks (wpautop).", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/categories": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" },
+                    "hierarchical": { "required": false, "default": false, "description": "Show hierarchy", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/categories" }
+        },
+        "\/js-widgets\/v1\/widgets\/categories\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" },
+                    "hierarchical": { "required": false, "default": false, "description": "Show hierarchy", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "description": "Show post counts", "type": "boolean" },
+                    "hierarchical": { "required": false, "description": "Show hierarchy", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/recent-posts": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of posts to display.", "type": "integer" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/recent-posts" }
+        },
+        "\/js-widgets\/v1\/widgets\/recent-posts\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of posts to display.", "type": "integer" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "description": "The number of posts to display.", "type": "integer" },
+                    "show_date": { "required": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/recent-comments": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of comments to display.", "type": "integer" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/recent-comments" }
+        },
+        "\/js-widgets\/v1\/widgets\/recent-comments\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of comments to display.", "type": "integer" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "description": "The number of comments to display.", "type": "integer" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/rss": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "url": { "required": false, "default": "", "description": "The RSS feed URL.", "type": "string" },
+                    "items": { "required": false, "default": 10, "description": "The number of RSS items to display.", "type": "integer" },
+                    "show_summary": { "required": false, "default": false, "description": "Whether the summary should be shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author should be shown.", "type": "boolean" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/rss" }
+        },
+        "\/js-widgets\/v1\/widgets\/rss\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "url": { "required": false, "default": "", "description": "The RSS feed URL.", "type": "string" },
+                    "items": { "required": false, "default": 10, "description": "The number of RSS items to display.", "type": "integer" },
+                    "show_summary": { "required": false, "default": false, "description": "Whether the summary should be shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author should be shown.", "type": "boolean" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "url": { "required": false, "description": "The RSS feed URL.", "type": "string" },
+                    "items": { "required": false, "description": "The number of RSS items to display.", "type": "integer" },
+                    "show_summary": { "required": false, "description": "Whether the summary should be shown.", "type": "boolean" },
+                    "show_author": { "required": false, "description": "Whether the author should be shown.", "type": "boolean" },
+                    "show_date": { "required": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/tag_cloud": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "taxonomy": { "required": false, "default": "post_tag", "enum": ["category", "post_tag"], "description": "Taxonomy", "type": "string" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/tag_cloud" }
+        },
+        "\/js-widgets\/v1\/widgets\/tag_cloud\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "taxonomy": { "required": false, "default": "post_tag", "enum": ["category", "post_tag"], "description": "Taxonomy", "type": "string" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "taxonomy": { "required": false, "enum": ["category", "post_tag"], "description": "Taxonomy", "type": "string" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/nav_menu": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "nav_menu": { "required": false, "default": 0, "description": "Selected nav menu", "type": "integer" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/nav_menu" }
+        },
+        "\/js-widgets\/v1\/widgets\/nav_menu\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "nav_menu": { "required": false, "default": 0, "description": "Selected nav menu", "type": "integer" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "nav_menu": { "required": false, "description": "Selected nav menu", "type": "integer" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/post-collection": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" },
+                    "show_featured_image": { "required": false, "default": false, "description": "Whether the featured image is shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author is shown.", "type": "boolean" },
+                    "posts": { "required": false, "default": [], "description": "The IDs for the collected posts.", "type": "array" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/post-collection" }
+        },
+        "\/js-widgets\/v1\/widgets\/post-collection\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "default": "view", "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST", "PUT", "PATCH"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" },
+                    "show_featured_image": { "required": false, "default": false, "description": "Whether the featured image is shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author is shown.", "type": "boolean" },
+                    "posts": { "required": false, "default": [], "description": "The IDs for the collected posts.", "type": "array" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "show_date": { "required": false, "description": "Whether the date should be shown.", "type": "boolean" },
+                    "show_featured_image": { "required": false, "description": "Whether the featured image is shown.", "type": "boolean" },
+                    "show_author": { "required": false, "description": "Whether the author is shown.", "type": "boolean" },
+                    "posts": { "required": false, "description": "The IDs for the collected posts.", "type": "array" }
+                }
+            }]
+        }
+    },
+    "_links": {
+        "up": [
+            { "href": "http:\/\/newtest.localhost\/wp-json\/" }
+        ]
+    }
+};
</ins></span></pre></div>
<a id="trunktestsqunitfixtureswpapijs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/fixtures/wp-api.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/wp-api.js      2017-02-24 18:14:21 UTC (rev 40108)
+++ trunk/tests/qunit/fixtures/wp-api.js        2017-02-24 18:39:39 UTC (rev 40109)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,4 +1,4 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* global mockedApiResponse, Backbone */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* global mockedApiResponse, Backbone, jsWidgetsEndpointSchema */
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * @var mockedApiResponse defined in wp-api-generated.js
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,7 +23,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-json/wp/v2/user': mockedApiResponse.UserModel,
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-json/wp/v2/taxonomy': mockedApiResponse.TaxonomyModel,
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-json/wp/v2/status': mockedApiResponse.StatusModel,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        'wp-json/wp/v2/type': mockedApiResponse.TypeModel
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wp-json/wp/v2/type': mockedApiResponse.TypeModel,
+       'wp-json/js-widgets/v1/': jsWidgetsEndpointSchema
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsqunitindexhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/index.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/index.html      2017-02-24 18:14:21 UTC (rev 40108)
+++ trunk/tests/qunit/index.html        2017-02-24 18:39:39 UTC (rev 40109)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,6 +40,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        <script src="fixtures/customize-menus.js"></script>
</span><span class="cx" style="display: block; padding: 0 10px">                        <script src="fixtures/customize-widgets.js"></script>
</span><span class="cx" style="display: block; padding: 0 10px">                        <script src="fixtures/wp-api-generated.js"></script>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        <script src="fixtures/js-widgets-endpoint.js"></script>
</ins><span class="cx" style="display: block; padding: 0 10px">                         <script src="fixtures/wp-api.js"></script>
</span><span class="cx" style="display: block; padding: 0 10px">                </div>
</span><span class="cx" style="display: block; padding: 0 10px">                <p><a href="editor">TinyMCE tests</a></p>
</span></span></pre></div>
<a id="trunktestsqunitwpadminjsnavmenujs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/wp-admin/js/nav-menu.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/wp-admin/js/nav-menu.js 2017-02-24 18:14:21 UTC (rev 40108)
+++ trunk/tests/qunit/wp-admin/js/nav-menu.js   2017-02-24 18:39:39 UTC (rev 40109)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Fail if we don't see the expected number of events triggered in 1500 ms.
</span><span class="cx" style="display: block; padding: 0 10px">        setTimeout( function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                assert.equal(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // QUnit may load this file without running it, in which case `assert`
+               // will never be set to `assertPassed` below.
+               assert && assert.equal(
</ins><span class="cx" style="display: block; padding: 0 10px">                         eventsFired,
</span><span class="cx" style="display: block; padding: 0 10px">                        eventsExpected,
</span><span class="cx" style="display: block; padding: 0 10px">                        eventsExpected + ' wpNavMenu events should fire.'
</span></span></pre></div>
<a id="trunktestsqunitwpincludesjswpapijs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/wp-includes/js/wp-api.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/wp-includes/js/wp-api.js        2017-02-24 18:14:21 UTC (rev 40108)
+++ trunk/tests/qunit/wp-includes/js/wp-api.js  2017-02-24 18:39:39 UTC (rev 40109)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,4 +192,44 @@
</span><span class="cx" style="display: block; padding: 0 10px">                } );
</span><span class="cx" style="display: block; padding: 0 10px">        } );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Test the jswidget custom namespace and endpoints.
+wp.api.init( {
+       'versionString': 'js-widgets/v1/'
+} ).done( function() {
+               var customClasses = [
+                       'WidgetsArchives',
+                       'WidgetsCalendar',
+                       'WidgetsCategories',
+                       'WidgetsMeta',
+                       'WidgetsNav_menu',
+                       'WidgetsPages',
+                       'WidgetsPostCollection',
+                       'WidgetsRecentComments',
+                       'WidgetsRecentPosts',
+                       'WidgetsRss',
+                       'WidgetsSearch',
+                       'WidgetsTag_cloud',
+                       'WidgetsText'
+               ];
+
+               // Check that we have and can get each model type.
+               _.each( customClasses, function( className ) {
+                       QUnit.test( 'Checking ' + className + ' class name.' , function( assert ) {
+                               var done = assert.async();
+
+                               assert.expect( 2 );
+
+                               wp.api.loadPromise.done( function() {
+                                       var theModel = new wp.api.models[ className ]();
+                                       assert.ok( theModel, 'We can instantiate wp.api.models.' + className );
+                                       var theCollection = new wp.api.collections[ className ]();
+                                       assert.ok( theCollection, 'We can instantiate wp.api.collections.' + className );
+                                       // Trigger Qunit async completion.
+                                       done();
+                               } );
+                       } );
+               } );
+
+       } );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> } )( window.QUnit );
</span></span></pre>
</div>
</div>

</body>
</html>