Skip to content

Commit

Permalink
Fix warnings during tests and prevent them from reoccurring (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen authored Jul 10, 2017
1 parent 19e84ca commit 4e0ea5c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 124 deletions.
47 changes: 1 addition & 46 deletions blocks/test/fixtures/core__table.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,4 @@
<!-- wp:core/table -->
<table>
<thead>
<tr>
<th>Version</th>
<th>Musician</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://wordpress.org/news/2003/05/wordpress-now-available/">.70</a></td>
<td>No musician chosen.</td>
<td>May 27, 2003</td>
</tr>
<tr>
<td><a href="https://wordpress.org/news/2004/01/wordpress-10/">1.0</a></td>
<td>Miles Davis</td>
<td>January 3, 2004</td>
</tr>
<tr>
<td>Lots of versions skipped, see <a href="https://codex.wordpress.org/WordPress_Versions">the full list</a></td>
<td>&hellip;</td>
<td>&hellip;</td>
</tr>
<tr>
<td><a href="https://wordpress.org/news/2015/12/clifford/">4.4</a></td>
<td>Clifford Brown</td>
<td>December 8, 2015</td>
</tr>
<tr>
<td><a href="https://wordpress.org/news/2016/04/coleman/">4.5</a></td>
<td>Coleman Hawkins</td>
<td>April 12, 2016</td>
</tr>
<tr>
<td><a href="https://wordpress.org/news/2016/08/pepper/">4.6</a></td>
<td>Pepper Adams</td>
<td>August 16, 2016</td>
</tr>
<tr>
<td><a href="https://wordpress.org/news/2016/12/vaughan/">4.7</a></td>
<td>Sarah Vaughan</td>
<td>December 6, 2016</td>
</tr>
</tbody>
</table>
<table><thead><tr><th>Version</th><th>Musician</th><th>Date</th></tr></thead><tbody><tr><td><a href="https://wordpress.org/news/2003/05/wordpress-now-available/">.70</a></td><td>No musician chosen.</td><td>May 27, 2003</td></tr><tr><td><a href="https://wordpress.org/news/2004/01/wordpress-10/">1.0</a></td><td>Miles Davis</td><td>January 3, 2004</td></tr><tr><td>Lots of versions skipped, see <a href="https://codex.wordpress.org/WordPress_Versions">the full list</a></td><td>&hellip;</td><td>&hellip;</td></tr><tr><td><a href="https://wordpress.org/news/2015/12/clifford/">4.4</a></td><td>Clifford Brown</td><td>December 8, 2015</td></tr><tr><td><a href="https://wordpress.org/news/2016/04/coleman/">4.5</a></td><td>Coleman Hawkins</td><td>April 12, 2016</td></tr><tr><td><a href="https://wordpress.org/news/2016/08/pepper/">4.6</a></td><td>Pepper Adams</td><td>August 16, 2016</td></tr><tr><td><a href="https://wordpress.org/news/2016/12/vaughan/">4.7</a></td><td>Sarah Vaughan</td><td>December 6, 2016</td></tr></tbody></table>
<!-- /wp:core/table -->

99 changes: 26 additions & 73 deletions blocks/test/fixtures/core__table.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,32 @@
"name": "core/table",
"attributes": {
"content": [
"\n ",
{
"type": "thead",
"children": [
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "th",
"children": "Version"
},
"\n ",
{
"type": "th",
"children": "Musician"
},
"\n ",
{
"type": "th",
"children": "Date"
},
"\n "
]
},
"\n "
]
"children": {
"type": "tr",
"children": [
{
"type": "th",
"children": "Version"
},
{
"type": "th",
"children": "Musician"
},
{
"type": "th",
"children": "Date"
}
]
}
},
"\n ",
{
"type": "tbody",
"children": [
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": {
Expand All @@ -52,24 +40,19 @@
"children": ".70"
}
},
"\n ",
{
"type": "td",
"children": "No musician chosen."
},
"\n ",
{
"type": "td",
"children": "May 27, 2003"
},
"\n "
}
]
},
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": {
Expand All @@ -80,24 +63,19 @@
"children": "1.0"
}
},
"\n ",
{
"type": "td",
"children": "Miles Davis"
},
"\n ",
{
"type": "td",
"children": "January 3, 2004"
},
"\n "
}
]
},
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": [
Expand All @@ -111,24 +89,19 @@
}
]
},
"\n ",
{
"type": "td",
"children": ""
},
"\n ",
{
"type": "td",
"children": ""
},
"\n "
}
]
},
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": {
Expand All @@ -139,24 +112,19 @@
"children": "4.4"
}
},
"\n ",
{
"type": "td",
"children": "Clifford Brown"
},
"\n ",
{
"type": "td",
"children": "December 8, 2015"
},
"\n "
}
]
},
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": {
Expand All @@ -167,24 +135,19 @@
"children": "4.5"
}
},
"\n ",
{
"type": "td",
"children": "Coleman Hawkins"
},
"\n ",
{
"type": "td",
"children": "April 12, 2016"
},
"\n "
}
]
},
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": {
Expand All @@ -195,24 +158,19 @@
"children": "4.6"
}
},
"\n ",
{
"type": "td",
"children": "Pepper Adams"
},
"\n ",
{
"type": "td",
"children": "August 16, 2016"
},
"\n "
}
]
},
"\n ",
{
"type": "tr",
"children": [
"\n ",
{
"type": "td",
"children": {
Expand All @@ -223,23 +181,18 @@
"children": "4.7"
}
},
"\n ",
{
"type": "td",
"children": "Sarah Vaughan"
},
"\n ",
{
"type": "td",
"children": "December 6, 2016"
},
"\n "
}
]
},
"\n "
}
]
},
"\n"
}
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__table.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"blockName": "core/table",
"attrs": null,
"rawContent": "\n<table>\n <thead>\n <tr>\n <th>Version</th>\n <th>Musician</th>\n <th>Date</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><a href=\"https://wordpress.org/news/2003/05/wordpress-now-available/\">.70</a></td>\n <td>No musician chosen.</td>\n <td>May 27, 2003</td>\n </tr>\n <tr>\n <td><a href=\"https://wordpress.org/news/2004/01/wordpress-10/\">1.0</a></td>\n <td>Miles Davis</td>\n <td>January 3, 2004</td>\n </tr>\n <tr>\n <td>Lots of versions skipped, see <a href=\"https://codex.wordpress.org/WordPress_Versions\">the full list</a></td>\n <td>&hellip;</td>\n <td>&hellip;</td>\n </tr>\n <tr>\n <td><a href=\"https://wordpress.org/news/2015/12/clifford/\">4.4</a></td>\n <td>Clifford Brown</td>\n <td>December 8, 2015</td>\n </tr>\n <tr>\n <td><a href=\"https://wordpress.org/news/2016/04/coleman/\">4.5</a></td>\n <td>Coleman Hawkins</td>\n <td>April 12, 2016</td>\n </tr>\n <tr>\n <td><a href=\"https://wordpress.org/news/2016/08/pepper/\">4.6</a></td>\n <td>Pepper Adams</td>\n <td>August 16, 2016</td>\n </tr>\n <tr>\n <td><a href=\"https://wordpress.org/news/2016/12/vaughan/\">4.7</a></td>\n <td>Sarah Vaughan</td>\n <td>December 6, 2016</td>\n </tr>\n </tbody>\n</table>\n"
"rawContent": "\n<table><thead><tr><th>Version</th><th>Musician</th><th>Date</th></tr></thead><tbody><tr><td><a href=\"https://wordpress.org/news/2003/05/wordpress-now-available/\">.70</a></td><td>No musician chosen.</td><td>May 27, 2003</td></tr><tr><td><a href=\"https://wordpress.org/news/2004/01/wordpress-10/\">1.0</a></td><td>Miles Davis</td><td>January 3, 2004</td></tr><tr><td>Lots of versions skipped, see <a href=\"https://codex.wordpress.org/WordPress_Versions\">the full list</a></td><td>&hellip;</td><td>&hellip;</td></tr><tr><td><a href=\"https://wordpress.org/news/2015/12/clifford/\">4.4</a></td><td>Clifford Brown</td><td>December 8, 2015</td></tr><tr><td><a href=\"https://wordpress.org/news/2016/04/coleman/\">4.5</a></td><td>Coleman Hawkins</td><td>April 12, 2016</td></tr><tr><td><a href=\"https://wordpress.org/news/2016/08/pepper/\">4.6</a></td><td>Pepper Adams</td><td>August 16, 2016</td></tr><tr><td><a href=\"https://wordpress.org/news/2016/12/vaughan/\">4.7</a></td><td>Sarah Vaughan</td><td>December 6, 2016</td></tr></tbody></table>\n"
},
{
"attrs": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__table.serialized.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
</tr>
</tbody>
</table>
<!-- /wp:core/table -->
<!-- /wp:core/table -->
2 changes: 1 addition & 1 deletion blocks/test/full-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function normalizeParsedBlocks( blocks ) {

describe( 'full post content fixture', () => {
beforeAll( () => {
// Registers all blocks
// Register all blocks.
require( 'blocks' );
} );

Expand Down
4 changes: 2 additions & 2 deletions editor/test/state.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { values } from 'lodash';
import { values, noop } from 'lodash';
import deepFreeze from 'deep-freeze';

/**
Expand Down Expand Up @@ -29,7 +29,7 @@ import {
describe( 'state', () => {
describe( 'editor()', () => {
beforeAll( () => {
registerBlockType( 'core/test-block', {} );
registerBlockType( 'core/test-block', { save: noop } );
} );

afterAll( () => {
Expand Down
12 changes: 12 additions & 0 deletions test/setup-globals.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Turn various warnings into errors
/* eslint-disable no-console */
console._errorOriginal = console.error;
console.error = ( ...args ) => {
const util = require( 'util' );
throw new Error(
'Warning caught via console.error: ' +
util.format.apply( util, args )
);
};
/* eslint-enable no-console */

// These are necessary to load TinyMCE successfully
global.URL = window.URL;
global.window.tinyMCEPreInit = {
Expand Down

0 comments on commit 4e0ea5c

Please sign in to comment.