-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(block-tools): add tests for gdocs pre-processsing
- Loading branch information
1 parent
f30b869
commit 45683f1
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/@sanity/block-tools/test/tests/HtmlDeserializer/gdocs/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {BlockTestFn} from '../types' | ||
import defaultSchema from '../../../fixtures/defaultSchema' | ||
|
||
const blockContentType = defaultSchema | ||
.get('blogPost') | ||
.fields.find((field: any) => field.name === 'body').type | ||
|
||
const testFn: BlockTestFn = (html, blockTools, commonOptions) => { | ||
return blockTools.htmlToBlocks(html, blockContentType, commonOptions) | ||
} | ||
|
||
export default testFn |
5 changes: 5 additions & 0 deletions
5
packages/@sanity/block-tools/test/tests/HtmlDeserializer/gdocs/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<!--StartFragment--><meta charset="utf-8"><b style="font-weight:normal;" id="docs-internal-guid-21a47c78-7fff-15da-47f1-302ae3839dbc"><h1 dir="ltr" style="line-height:1.2;margin-right: -1.5pt;margin-top:16pt;margin-bottom:0pt;"><span style="font-size:13.999999999999998pt;font-family:'Playfair Display',serif;color:#f75d5d;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Skills</span></h1><p dir="ltr" style="line-height:1.56;margin-top:10pt;margin-bottom:0pt;"><span style="font-size:10pt;font-family:Lato,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ac interdum nisi. Sed in consequat mi. Sed pulvinar lacinia felis eu finibus.</span></p></b><br class="Apple-interchange-newline"><!--EndFragment--> | ||
</body> | ||
</html> |
30 changes: 30 additions & 0 deletions
30
packages/@sanity/block-tools/test/tests/HtmlDeserializer/gdocs/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"_key": "randomKey0", | ||
"_type": "block", | ||
"children": [{"_key": "randomKey00", "_type": "span", "marks": ["strong"], "text": "Skills"}], | ||
"markDefs": [], | ||
"style": "h1" | ||
}, | ||
{ | ||
"_key": "randomKey1", | ||
"_type": "block", | ||
"children": [ | ||
{ | ||
"_key": "randomKey10", | ||
"_type": "span", | ||
"marks": [], | ||
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ac interdum nisi. Sed in consequat mi. Sed pulvinar lacinia felis eu finibus." | ||
} | ||
], | ||
"markDefs": [], | ||
"style": "normal" | ||
}, | ||
{ | ||
"_key": "randomKey2", | ||
"_type": "block", | ||
"children": [{"_key": "randomKey20", "_type": "span", "marks": [], "text": "\n"}], | ||
"markDefs": [], | ||
"style": "normal" | ||
} | ||
] |
45683f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
performance-studio – ./
performance-studio-git-next.sanity.build
performance-studio.sanity.build
45683f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
test-studio – ./
test-studio-git-next.sanity.build
test-studio.sanity.build