From bbf7d603026d47d1619dd4b8764baea4cf1a0452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sun, 11 Mar 2018 17:13:32 +0100 Subject: [PATCH] Docs: Fixed the fancy-heading sample and added integration test for it. --- .../features/custom-heading-elements.js | 7 ++-- docs/features/headings.md | 10 ++--- tests/integration.js | 39 +++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/docs/_snippets/features/custom-heading-elements.js b/docs/_snippets/features/custom-heading-elements.js index 62ceac1..1ad615f 100644 --- a/docs/_snippets/features/custom-heading-elements.js +++ b/docs/_snippets/features/custom-heading-elements.js @@ -16,10 +16,11 @@ ClassicEditor model: 'headingFancy', view: { name: 'h2', - class: 'fancy', - priority: 'high' + class: 'fancy' }, - title: 'Heading 2 (fancy)', class: 'ck-heading_heading2_fancy' + title: 'Heading 2 (fancy)', + class: 'ck-heading_heading2_fancy', + priority: 'high' } ] }, diff --git a/docs/features/headings.md b/docs/features/headings.md index a83cb6c..83ad635 100644 --- a/docs/features/headings.md +++ b/docs/features/headings.md @@ -85,13 +85,13 @@ ClassicEditor model: 'headingFancy', view: { name: 'h2', - class: 'fancy', - - // It needs to be converted before the standard 'heading2'. - priority: 'high' + class: 'fancy' }, title: 'Heading 2 (fancy)', - class: 'ck-heading_heading2_fancy' + class: 'ck-heading_heading2_fancy', + + // It needs to be converted before the standard 'heading2'. + priority: 'high' } ] } diff --git a/tests/integration.js b/tests/integration.js index b70bfc0..b9eed11 100644 --- a/tests/integration.js +++ b/tests/integration.js @@ -109,4 +109,43 @@ describe( 'Heading integration', () => { expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false; } ); } ); + + // Remember to sync docs/_snippets/features/custom-heading-elements.js and docs/features/headings.md + // with this test when changing it. + describe( 'fancy heading sample in the docs', () => { + it( 'upcasts the

and

elements when configured to do so', () => { + const element = document.createElement( 'div' ); + document.body.appendChild( element ); + + return ClassicTestEditor + .create( element, { + plugins: [ Paragraph, Heading ], + heading: { + options: [ + { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' }, + { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }, + { + model: 'headingFancy', + view: { + name: 'h2', + class: 'fancy' + }, + title: 'Heading 2 (fancy)', + class: 'ck-heading_heading2_fancy', + priority: 'high' + } + ] + } + } ) + .then( editor => { + editor.setData( '

Heading 2

Fancy Heading 2

' ); + + expect( editor.getData() ) + .to.equal( '

Heading 2

Fancy Heading 2

' ); + + editor.destroy(); + element.remove(); + } ); + } ); + } ); } );