Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Tests: Added a test for #6265.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Mar 27, 2020
1 parent afdbc2d commit ebbebe4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/tableproperties/tablepropertiesediting-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-util
import TableEditing from '../../src/tableediting';
import TablePropertiesEditing from '../../src/tableproperties/tablepropertiesediting';

import TableCellPropertiesEditing from '../../src/tablecellproperties/tablecellpropertiesediting';

import AlignmentEditing from '@ckeditor/ckeditor5-alignment/src/alignmentediting';
import UndoEditing from '@ckeditor/ckeditor5-undo/src/undoediting';

import { assertTableStyle } from '../_utils/utils';

describe( 'table properties', () => {
Expand Down Expand Up @@ -39,6 +43,44 @@ describe( 'table properties', () => {
} );
} );

describe( 'Undo', () => {
let table;

beforeEach( async () => {
editor = await createEditorWithAdditionalPlugins( [ UndoEditing, TableCellPropertiesEditing ] );

model = editor.model;

table = createEmptyTable();
} );

// See https://github.com/ckeditor/ckeditor5/issues/6265.
it( 'should correctly undo setting table and then cell style', () => {
const firstCell = table.getChild( 0 ).getChild( 0 );

editor.model.change( writer => {
writer.setSelection( firstCell, 0 );
} );

editor.execute( 'tableBackgroundColor', { value: 'red' } );

editor.execute( 'tableCellBackgroundColor', { value: 'green' } );

expect( table.getAttribute( 'backgroundColor' ) ).to.equal( 'red' );
expect( firstCell.getAttribute( 'backgroundColor' ) ).to.equal( 'green' );

editor.execute( 'undo' );

expect( table.getAttribute( 'backgroundColor' ) ).to.equal( 'red' );
expect( firstCell.getAttribute( 'backgroundColor' ) ).to.be.undefined;

editor.execute( 'undo' );

expect( table.getAttribute( 'backgroundColor' ) ).to.be.undefined;
expect( firstCell.getAttribute( 'backgroundColor' ) ).to.be.undefined;
} );
} );

function createEmptyTable() {
setModelData(
model,
Expand Down

0 comments on commit ebbebe4

Please sign in to comment.