From 4e0ea5c0d78fcd4c25e7282abcc2da9366fb7a78 Mon Sep 17 00:00:00 2001 From: James Nylen Date: Mon, 10 Jul 2017 12:02:45 +0200 Subject: [PATCH] Fix warnings during tests and prevent them from reoccurring (#1769) --- blocks/test/fixtures/core__table.html | 47 +-------- blocks/test/fixtures/core__table.json | 99 +++++-------------- blocks/test/fixtures/core__table.parsed.json | 2 +- .../test/fixtures/core__table.serialized.html | 2 +- blocks/test/full-content.js | 2 +- editor/test/state.js | 4 +- test/setup-globals.js | 12 +++ 7 files changed, 44 insertions(+), 124 deletions(-) diff --git a/blocks/test/fixtures/core__table.html b/blocks/test/fixtures/core__table.html index 60008a1566ef04..19099e249e5b7c 100644 --- a/blocks/test/fixtures/core__table.html +++ b/blocks/test/fixtures/core__table.html @@ -1,49 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
+
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/blocks/test/fixtures/core__table.json b/blocks/test/fixtures/core__table.json index 9f06df6d70e7bf..46d03ed4a7a909 100644 --- a/blocks/test/fixtures/core__table.json +++ b/blocks/test/fixtures/core__table.json @@ -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": { @@ -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": { @@ -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": [ @@ -111,24 +89,19 @@ } ] }, - "\n ", { "type": "td", "children": "…" }, - "\n ", { "type": "td", "children": "…" - }, - "\n " + } ] }, - "\n ", { "type": "tr", "children": [ - "\n ", { "type": "td", "children": { @@ -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": { @@ -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": { @@ -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": { @@ -223,23 +181,18 @@ "children": "4.7" } }, - "\n ", { "type": "td", "children": "Sarah Vaughan" }, - "\n ", { "type": "td", "children": "December 6, 2016" - }, - "\n " + } ] - }, - "\n " + } ] - }, - "\n" + } ] } } diff --git a/blocks/test/fixtures/core__table.parsed.json b/blocks/test/fixtures/core__table.parsed.json index e0bb79e7ef1890..50bf531dbf042d 100644 --- a/blocks/test/fixtures/core__table.parsed.json +++ b/blocks/test/fixtures/core__table.parsed.json @@ -2,7 +2,7 @@ { "blockName": "core/table", "attrs": null, - "rawContent": "\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n" + "rawContent": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__table.serialized.html b/blocks/test/fixtures/core__table.serialized.html index 6c201720843f70..67310f7464fd27 100644 --- a/blocks/test/fixtures/core__table.serialized.html +++ b/blocks/test/fixtures/core__table.serialized.html @@ -45,4 +45,4 @@ - + \ No newline at end of file diff --git a/blocks/test/full-content.js b/blocks/test/full-content.js index db9897cb999bb2..3b8d55f739084d 100644 --- a/blocks/test/full-content.js +++ b/blocks/test/full-content.js @@ -89,7 +89,7 @@ function normalizeParsedBlocks( blocks ) { describe( 'full post content fixture', () => { beforeAll( () => { - // Registers all blocks + // Register all blocks. require( 'blocks' ); } ); diff --git a/editor/test/state.js b/editor/test/state.js index 2b1674b2baf0a5..9e6786ba1923e9 100644 --- a/editor/test/state.js +++ b/editor/test/state.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { values } from 'lodash'; +import { values, noop } from 'lodash'; import deepFreeze from 'deep-freeze'; /** @@ -29,7 +29,7 @@ import { describe( 'state', () => { describe( 'editor()', () => { beforeAll( () => { - registerBlockType( 'core/test-block', {} ); + registerBlockType( 'core/test-block', { save: noop } ); } ); afterAll( () => { diff --git a/test/setup-globals.js b/test/setup-globals.js index 434a668cc097e6..931f6e146d7985 100644 --- a/test/setup-globals.js +++ b/test/setup-globals.js @@ -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 = {