This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Fixed resizer initial percentage values for sie images #308
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a842435
Tests: Added some integration tests for percent-based resizing.
mlewand c8f9181
Tests: Added test for other fixed case.
mlewand e5e9f02
Merge branch 'master' into t/306
mlewand f2ad315
Merge branch 'master' into t/306
Reinmar bc1c6d2
Tests: Avoid creating multiple editors.
mlewand 729047f
Test: Corrected variable name.
mlewand a8bdc86
Tests: Removed duplicated code.
mlewand c771a72
Tests: Extracted common code.
mlewand 1838622
Tests: Removed stray assignment.
mlewand 90cee77
Tests: Editor is now created for 2st level test suites.
mlewand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -435,6 +435,90 @@ describe( 'ImageResize', () => { | |
} | ||
} ); | ||
|
||
describe( 'percent resizing', () => { | ||
describe( 'standard image', () => { | ||
beforeEach( async () => { | ||
await editor.destroy(); | ||
|
||
editor = await ClassicEditor | ||
.create( editorElement, { | ||
plugins: [ Image, ImageStyle, Paragraph, Undo, Table, ImageResize ] | ||
} ); | ||
|
||
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }"></image>]` ); | ||
|
||
view = editor.editing.view; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This duplicates the code from the topmost |
||
viewDocument = view.document; | ||
widget = viewDocument.getRoot().getChild( 1 ); | ||
} ); | ||
|
||
it( 'shrinks correctly with left-bottom handler', generateResizeTest( { | ||
expectedWidth: 16, | ||
modelRegExp: /<paragraph>foo<\/paragraph><image src=".+?" width="([\d]{2}(?:\.[\d]{1,2}))%"><\/image>/, | ||
pointerOffset: { | ||
x: 10, | ||
y: -10 | ||
}, | ||
resizerPosition: 'bottom-left' | ||
} ) ); | ||
|
||
it( 'enlarges correctly with right-bottom handler', generateResizeTest( { | ||
expectedWidth: 22, | ||
modelRegExp: /<paragraph>foo<\/paragraph><image src=".+?" width="([\d]{2}(?:\.[\d]{1,2}))%"><\/image>/, | ||
pointerOffset: { | ||
x: 0, | ||
y: 5 | ||
}, | ||
resizerPosition: 'bottom-right' | ||
} ) ); | ||
|
||
it( 'enlarges correctly an image with unsupported width unit', async () => { | ||
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }" width="50pt"></image>]` ); | ||
|
||
view = editor.editing.view; | ||
viewDocument = view.document; | ||
widget = viewDocument.getRoot().getChild( 1 ); | ||
|
||
await generateResizeTest( { | ||
expectedWidth: 15, | ||
modelRegExp: /<paragraph>foo<\/paragraph><image src=".+?" width="([\d]{2}(?:\.[\d]{1,2}))%"><\/image>/, | ||
pointerOffset: { | ||
x: 0, | ||
y: 5 | ||
}, | ||
resizerPosition: 'bottom-right' | ||
} )(); | ||
} ); | ||
} ); | ||
|
||
describe( 'side image', () => { | ||
beforeEach( async () => { | ||
await editor.destroy(); | ||
|
||
editor = await ClassicEditor | ||
.create( editorElement, { | ||
plugins: [ Image, ImageStyle, Paragraph, Undo, Table, ImageResize ] | ||
} ); | ||
|
||
setData( editor.model, `<paragraph>foo</paragraph>[<image imageStyle="side" src="${ IMAGE_SRC_FIXTURE }"></image>]` ); | ||
|
||
view = editor.editing.view; | ||
viewDocument = view.document; | ||
widget = viewDocument.getRoot().getChild( 1 ); | ||
} ); | ||
|
||
it( 'shrinks correctly with left-bottom handler', generateResizeTest( { | ||
expectedWidth: 18, | ||
modelRegExp: /<paragraph>foo<\/paragraph><image imageStyle="side" src=".+?" width="([\d]{2}(?:\.[\d]{1,2}))%"><\/image>/, | ||
pointerOffset: { | ||
x: 10, | ||
y: -10 | ||
}, | ||
resizerPosition: 'bottom-left' | ||
} ) ); | ||
} ); | ||
} ); | ||
|
||
describe( 'undo integration', () => { | ||
beforeEach( () => { | ||
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }"></image>]` ); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is odd. Please create the right editor for the specific describe block. Creating 2 editors for no reason is both confusing and slows down the tests.