diff --git a/blocks/test/fixtures/core__cover-text.json b/blocks/test/fixtures/core__cover-text.json
index b6e9e0d51346f3..74bf459027e959 100644
--- a/blocks/test/fixtures/core__cover-text.json
+++ b/blocks/test/fixtures/core__cover-text.json
@@ -1,12 +1,14 @@
[
{
"uid": "_uid_0",
- "isValid": false,
"name": "core/cover-text",
+ "isValid": false,
"attributes": {
"backgroundColor": "#fcb900",
"content": [
- [ "Text with color." ]
+ [
+ "Text with color."
+ ]
]
},
"originalContent": "
"
diff --git a/blocks/test/fixtures/core__latest-posts.html b/blocks/test/fixtures/core__latest-posts.html
index d3128a66820632..99d215f58affad 100644
--- a/blocks/test/fixtures/core__latest-posts.html
+++ b/blocks/test/fixtures/core__latest-posts.html
@@ -1 +1 @@
-
+
diff --git a/blocks/test/fixtures/core__latest-posts.json b/blocks/test/fixtures/core__latest-posts.json
index 303d110f0f9215..c1e9e6f8d44334 100644
--- a/blocks/test/fixtures/core__latest-posts.json
+++ b/blocks/test/fixtures/core__latest-posts.json
@@ -4,10 +4,10 @@
"name": "core/latest-posts",
"isValid": true,
"attributes": {
- "columns": 3,
"postsToShow": 5,
- "displayPostDate": true,
- "layout": "list"
+ "displayPostDate": false,
+ "layout": "list",
+ "columns": 3
}
}
]
diff --git a/blocks/test/fixtures/core__latest-posts.parsed.json b/blocks/test/fixtures/core__latest-posts.parsed.json
index c0b53e30ca56b6..ac3a8dba1cc674 100644
--- a/blocks/test/fixtures/core__latest-posts.parsed.json
+++ b/blocks/test/fixtures/core__latest-posts.parsed.json
@@ -3,7 +3,7 @@
"blockName": "core/latest-posts",
"attrs": {
"postsToShow": 5,
- "displayPostDate": true
+ "displayPostDate": false
},
"rawContent": ""
},
diff --git a/blocks/test/fixtures/core__latest-posts.serialized.html b/blocks/test/fixtures/core__latest-posts.serialized.html
index ab37368489fdaf..6c80203bbda2b7 100644
--- a/blocks/test/fixtures/core__latest-posts.serialized.html
+++ b/blocks/test/fixtures/core__latest-posts.serialized.html
@@ -1 +1 @@
-
+
diff --git a/blocks/test/fixtures/core__latest-posts__displayPostDate.html b/blocks/test/fixtures/core__latest-posts__displayPostDate.html
new file mode 100644
index 00000000000000..d3128a66820632
--- /dev/null
+++ b/blocks/test/fixtures/core__latest-posts__displayPostDate.html
@@ -0,0 +1 @@
+
diff --git a/blocks/test/fixtures/core__latest-posts__displayPostDate.json b/blocks/test/fixtures/core__latest-posts__displayPostDate.json
new file mode 100644
index 00000000000000..238718c80ea868
--- /dev/null
+++ b/blocks/test/fixtures/core__latest-posts__displayPostDate.json
@@ -0,0 +1,13 @@
+[
+ {
+ "uid": "_uid_0",
+ "name": "core/latest-posts",
+ "isValid": true,
+ "attributes": {
+ "postsToShow": 5,
+ "displayPostDate": true,
+ "layout": "list",
+ "columns": 3
+ }
+ }
+]
diff --git a/blocks/test/fixtures/core__latest-posts__displayPostDate.parsed.json b/blocks/test/fixtures/core__latest-posts__displayPostDate.parsed.json
new file mode 100644
index 00000000000000..c0b53e30ca56b6
--- /dev/null
+++ b/blocks/test/fixtures/core__latest-posts__displayPostDate.parsed.json
@@ -0,0 +1,14 @@
+[
+ {
+ "blockName": "core/latest-posts",
+ "attrs": {
+ "postsToShow": 5,
+ "displayPostDate": true
+ },
+ "rawContent": ""
+ },
+ {
+ "attrs": {},
+ "rawContent": "\n"
+ }
+]
diff --git a/blocks/test/fixtures/core__latest-posts__displayPostDate.serialized.html b/blocks/test/fixtures/core__latest-posts__displayPostDate.serialized.html
new file mode 100644
index 00000000000000..ab37368489fdaf
--- /dev/null
+++ b/blocks/test/fixtures/core__latest-posts__displayPostDate.serialized.html
@@ -0,0 +1 @@
+
diff --git a/blocks/test/fixtures/core__text__align-right.json b/blocks/test/fixtures/core__text__align-right.json
index 73496b8ab977a3..176a94f69cbdfd 100644
--- a/blocks/test/fixtures/core__text__align-right.json
+++ b/blocks/test/fixtures/core__text__align-right.json
@@ -4,13 +4,13 @@
"name": "core/text",
"isValid": true,
"attributes": {
+ "dropCap": false,
"align": "right",
"content": [
[
"... like this one, which is separate from the above and right aligned."
]
- ],
- "dropCap": false
+ ]
}
}
]
diff --git a/blocks/test/full-content.js b/blocks/test/full-content.js
index e13392673411b7..daf002e8c9ccc1 100644
--- a/blocks/test/full-content.js
+++ b/blocks/test/full-content.js
@@ -3,7 +3,7 @@
*/
import fs from 'fs';
import path from 'path';
-import { uniq, isObject, omit, startsWith } from 'lodash';
+import { uniq, isObject, omit, startsWith, get } from 'lodash';
import { format } from 'util';
/**
@@ -172,7 +172,7 @@ describe( 'full post content fixture', () => {
if ( ! serializedExpected ) {
if ( process.env.GENERATE_MISSING_FIXTURES ) {
- serializedExpected = serializedActual + '\n';
+ serializedExpected = serializedActual;
writeFixtureFile( f + '.serialized.html', serializedExpected );
} else {
throw new Error(
@@ -204,15 +204,23 @@ describe( 'full post content fixture', () => {
startsWith( basename, nameToFilename + '__' )
) )
.map( basename => {
- const filename = basename + '.html';
- const parsedBlockFilename = basename + '.json';
+ // The file that contains the input HTML for this test.
+ const inputFilename = basename + '.html';
+ // The parser output for this test. For missing files,
+ // JSON.parse( null ) === null.
+ const parserOutput = JSON.parse(
+ readFixtureFile( basename + '.json' )
+ );
+ // The name of the first block that this fixture file
+ // contains (if any).
+ const firstBlock = get( parserOutput, [ '0', 'name' ], null );
return {
- filename,
- contents: readFixtureFile( filename ),
- parsed: JSON.parse( readFixtureFile( parsedBlockFilename ) )[ 0 ],
+ filename: inputFilename,
+ parserOutput,
+ firstBlock,
};
} )
- .filter( fixture => fixture.contents !== null );
+ .filter( fixture => fixture.parserOutput !== null );
if ( ! foundFixtures.length ) {
errors.push( format(
@@ -223,7 +231,7 @@ describe( 'full post content fixture', () => {
}
foundFixtures.forEach( fixture => {
- if ( name !== fixture.parsed.name ) {
+ if ( name !== fixture.firstBlock ) {
errors.push( format(
'Expected fixture file \'%s\' to test the \'%s\' block.',
fixture.filename,
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 00000000000000..ba6f0b2b6e5eac
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,2 @@
+comment:
+ require_changes: true
diff --git a/package.json b/package.json
index e46a7a5b6b05c1..709bf7f3788497 100644
--- a/package.json
+++ b/package.json
@@ -127,6 +127,9 @@
"dev": "cross-env BABEL_ENV=default webpack --watch",
"test": "npm run lint && npm run test-unit",
"ci": "concurrently \"npm run lint && npm run build\" \"npm run test-unit:coverage-ci\"",
+ "fixtures:clean": "rimraf \"blocks/test/fixtures/*.+(json|serialized.html)\"",
+ "fixtures:generate": "GENERATE_MISSING_FIXTURES=y npm run test-unit",
+ "fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate",
"package-plugin": "./bin/build-plugin-zip.sh",
"docs-start": "./docutron/bin/cli.js start",
"docs-build": "./docutron/bin/cli.js build",