# all files / test/base/editing/ Table.spec.js

100% Statements 435/435
100% Branches 0/0
100% Functions 28/28
100% Lines 435/435

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554

    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

     /**
     * Table.spec.js
     * (c) 2015~ Summernote Team
     * summernote may be freely distributed under the MIT license./
     */
    import chai from 'chai';
    import $ from 'jquery';
    import range from '../../../src/js/base/core/range';
    import Table from '../../../src/js/base/editing/Table';

    var expect = chai.expect;

    describe('base:editing.Table', () => {
      var table = new Table();
      describe('tableWorker', () => {
        it('should create simple 1x1 table', () => {
          var resultTable = table.createTable(1, 1);
          expect(1).to.deep.equal(resultTable.rows.length);
          expect(1).to.deep.equal(resultTable.rows[0].cells.length);
        });

        it('should delete simple 1x1 table', () => {
          var $cont = $('<div class="note-editable"><table><tr><td>content</td></tr></table></div>');
          var $cell = $cont.find('td');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteTable(rng);
          expect('').to.deep.equal($cont.html());
        });

        it('should add simple row to table on top', () => {
          var $cont = $('<div class="note-editable"><table><tr><td>content</td></tr></table></div>');
          var $cell = $cont.find('td');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'top');
          expect('<table><tbody><tr><td><br></td></tr><tr><td>content</td></tr></tbody></table>').to.equalsIgnoreCase($cont.html());
        });

        it('should add simple row to table on bottom', () => {
          var $cont = $('<div class="note-editable"><table><tr><td>content</td></tr></table></div>');
          var $cell = $cont.find('td');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'bottom');
          expect('<table><tbody><tr><td>content</td></tr><tr><td><br></td></tr></tbody></table>').to.equalsIgnoreCase($cont.html());
        });

        it('should add simple row to table on top between two rows', () => {
          var htmlContent = '<div class="note-editable"><table><tr><td>content1</td></tr><tr><td id="td2">content2</td></tr></table></div>';
          var $cont = $(htmlContent);
          var $cell = $cont.find('#td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'top');
          var resultTable = $('<table><tbody><tr><td>content1</td></tr></tbody></table>');
          $(resultTable).append('<tr><td><br/></td></tr>');
          $(resultTable).append('<tr><td id="td2">content2</td></tr>');
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';
          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add simple row to table on bottom between two rows', () => {
          var baseTable = $('<table><tbody><tr><td id="td1">content1</td></tr></tbody></table>');
          $(baseTable).append('<tr><td id="td2">content2</td></tr>');
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);
          var $cell = $cont.find('#td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'bottom');

          var resultTable = $('<table><tbody><tr><td id="td1">content1</td></tr></tbody></table>');
          $(resultTable).append('<tr><td><br/></td></tr>');
          $(resultTable).append('<tr><td id="td2">content2</td></tr>');
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add simple col to table on left between two cols', () => {
          var baseTable = $('<table><tbody></tbody></table>');
          var baseTr = '<tr><td id="td1">content1</td><td id="td2">content2</td></tr>';
          baseTable.append(baseTr);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);
          var $cell = $cont.find('#td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.addCol(rng, 'left');

          var resultTable = $('<table><tbody></tbody></table>');
          $(resultTable).append('<tr><td id="td1">content1</td><td><br/></td><td id="td2">content2</td></tr>');
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add simple col to table on right between two cols', () => {
          var baseTable = $('<table><tbody></tbody></table>');
          var baseTr = '<tr><td id="td1">content1</td><td id="td2">content2</td></tr>';
          baseTable.append(baseTr);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);
          var $cell = $cont.find('#td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addCol(rng, 'right');

          var resultTable = $('<table><tbody></tbody></table>');
          $(resultTable).append('<tr><td id="td1">content1</td><td><br/></td><td id="td2">content2</td></tr>');
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete row to table between two other rows', () => {
          var baseTable = $('<table><tbody></tbody></table>');
          var baseTr = '<tr><td id="td1">content1</td></tr>';
          baseTr += '<td id="td2">content2</td></tr>';
          baseTr += '<td id="td3">content3</td></tr>';
          baseTable.append(baseTr);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);
          var $cell = $cont.find('#td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteRow(rng);

          var resultTable = $('<table><tbody></tbody></table>');
          $(resultTable).append('<tr><td id="td1">content1</td></tr><tr><td id="td3">content3</td></tr>');
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete col to table between two other cols', () => {
          var baseTable = $('<table><tbody></tbody></table>');
          var baseTr = '<tr><td id="td1">content1</td><td id="td2">content2</td><td id="td3">content3</td></tr>';
          baseTable.append(baseTr);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);
          var $cell = $cont.find('#td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table>');
          $(resultTable).append('<tr><td id="td1">content1</td><td id="td3">content3</td></tr>');
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete first col to table with colspan in column with colspan', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td colspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td><td id="tr2td3">Col3</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td id="tr1td1"></td><td id="tr1td2">Col2</td></tr>';
          var resultTr2 = '<tr><td id="tr2td2">Col2</td><td id="tr2td3">Col3</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete second col to table with colspan in column', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td colspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td><td id="tr2td3">Col3</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr2td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var resultTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td3">Col3</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete second col to table with colspan in 3 columns', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td colspan="3" id="tr1td1">Col1-Span</td><td id="tr1td4">Col4</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td><td id="tr2td3">Col3</td><td id="tr2td4">Col4</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr2td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td colspan="2" id="tr1td1">Col1-Span</td><td id="tr1td4">Col4</td></tr>';
          var resultTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td3">Col3</td><td id="tr2td4">Col4</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete first row to table with rowspan in line with rowspan', () => {
          var baseTable = $('<table><tbody></tbody></table>');
          var baseTr1 = '<tr><td class="test" rowspan="2" id="tr1td1">Row1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col2</td></tr>';
          var baseTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteRow(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1AndTr2 = '<tr><td class="test" id="tr1td1"></td><td id="tr2td2">Col2</td></tr>';
          var resultTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          resultTable.append(resultTr1AndTr2);
          resultTable.append(resultTr3);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete second row to table with rowspan in line without rowspan', () => {
          var baseTable = $('<table><tbody></tbody></table>');
          var baseTr1 = '<tr><td rowspan="3" id="tr1td1">Row1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col2</td></tr>';
          var baseTr3 = '<tr><td id="tr3td2">Col2</td></tr>';
          var baseTr4 = '<tr><td id="tr4td1">Col1</td><td id="tr4td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          baseTable.append(baseTr4);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr2td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteRow(rng);

          var resultTable = $('<table><tbody></tbody></table>');
          var resultTr1 = '<tr><td rowspan="2" id="tr1td1">Row1-Span</td><td id="tr1td2">Col2</td></tr>';
          var resultTr3 = '<tr><td id="tr3td2">Col2</td></tr>';
          var resultTr4 = '<tr><td id="tr4td1">Col1</td><td id="tr4td2">Col2</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr3);
          resultTable.append(resultTr4);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete second col to table with rowspan in 2 rows', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col2</td></tr>';
          var baseTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td></tr>';
          var resultTr2 = '<tr></tr>';
          var resultTr3 = '<tr><td id="tr3td1">Col1</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          resultTable.append(resultTr3);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should delete second col to table with rowspan in 2 rows on second row', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col2</td></tr>';
          var baseTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr2td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td></tr>';
          var resultTr2 = '<tr></tr>';
          var resultTr3 = '<tr><td id="tr3td1">Col1</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          resultTable.append(resultTr3);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add row on bottom rowspan cell.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col2</td></tr>';
          var baseTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr2td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td rowspan="3" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var resultTr2 = '<tr><td id="tr2td2">Col2</td></tr>';
          var resultTr3 = '<tr><td><br></td></tr>';
          var resultTr4 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          resultTable.append(resultTr3);
          resultTable.append(resultTr4);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add row on bottom colspan cell.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td colspan="2" id="tr1td1">Col1-Span</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td></tr>';
          var baseTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'bottom');

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td colspan="2" id="tr1td1">Col1-Span</td></tr>';
          var resultTr2 = '<tr><td colspan="2"><br></td></tr>';
          var resultTr3 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td></tr>';
          var resultTr4 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          resultTable.append(resultTr3);
          resultTable.append(resultTr4);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add row above rowspan cell.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col1</td></tr>';
          var baseTr3 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          baseTable.append(baseTr3);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'top');

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td><br></td><td><br></td></tr>';
          var resultTr2 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var resultTr3 = '<tr><td id="tr2td2">Col1</td></tr>';
          var resultTr4 = '<tr><td id="tr3td1">Col1</td><td id="tr3td2">Col2</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          resultTable.append(resultTr3);
          resultTable.append(resultTr4);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add row on bottom rowspan cell and with aditional column.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col1</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addRow(rng, 'bottom');

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td rowspan="3" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var resultTr2 = '<tr><td id="tr2td2">Col1</td></tr>';
          var resultTr3 = '<tr><td><br></td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          resultTable.append(resultTr3);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add column on right having rowspan cell and with aditional column.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col1</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td2');
          var rng = range.create($cell[0].firstChild, 1);
          table.addCol(rng, 'right');

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td><td><br></td></tr>';
          var resultTr2 = '<tr><td id="tr2td2">Col1</td><td><br></td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add column on right having rowspan cell and with aditional column with focus on rowspan column.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td id="tr1td2">Col2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td2">Col1</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addCol(rng, 'right');

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td rowspan="2" id="tr1td1">Col1-Span</td><td rowspan="2"><br></td><td id="tr1td2">Col2</td></tr>';
          var resultTr2 = '<tr><td id="tr2td2">Col1</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should remove column after colspan column.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td id="tr1td1">Col1</td><td colspan="2" id="tr1td2">Col2-Span</td><td id="tr1td4">Col4</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td><td id="tr2td3">Col3</td><td id="tr2td4">Col4</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td4');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td id="tr1td1">Col1</td><td colspan="2" id="tr1td2">Col2-Span</td></tr>';
          var resultTr2 = '<tr><td id="tr2td1">Col1</td><td id="tr2td2">Col2</td><td id="tr2td3">Col3</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should remove column before colspan column.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td id="tr1td1">TR1TD1</td><td id="tr1td2" colspan="2">TR1TD2-COLSPAN</td>';
          baseTr1 += '<td id="tr1td4">TR1TD4</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1">TR2TD1</td><td id="tr2td2">TR2TD2</td><td id="tr2td3">TR2TD3</td>';
          baseTr2 += '<td id="tr2td4">TR2TD4</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.deleteCol(rng);

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td id="tr1td2" colspan="2">TR1TD2-COLSPAN</td>';
          resultTr1 += '<td id="tr1td4">TR1TD4</td></tr>';
          var resultTr2 = '<tr><td id="tr2td2">TR2TD2</td><td id="tr2td3">TR2TD3</td><td id="tr2td4">TR2TD4</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });

        it('should add column before colspan column.', () => {
          var baseTable = $('<table><tbody></tbody></table> ');
          var baseTr1 = '<tr><td id="tr1td1">TR1TD1</td><td id="tr1td2">TR1TD2</td></tr>';
          var baseTr2 = '<tr><td id="tr2td1" colspan="2">TR2TD1</td></tr>';
          baseTable.append(baseTr1);
          baseTable.append(baseTr2);
          var htmlContent = '<div class="note-editable"><table>' + $(baseTable).html() + '</table></div>';
          var $cont = $(htmlContent);

          var $cell = $cont.find('#tr1td1');
          var rng = range.create($cell[0].firstChild, 1);
          table.addCol(rng, 'right');

          var resultTable = $('<table><tbody></tbody></table> ');
          var resultTr1 = '<tr><td id="tr1td1">TR1TD1</td><td><br></td><td id="tr1td2">TR1TD2</td></tr>';
          var resultTr2 = '<tr><td id="tr2td1" colspan="3">TR2TD1</td></tr>';
          resultTable.append(resultTr1);
          resultTable.append(resultTr2);
          var expectedResult = '<table>' + $(resultTable).html() + '</table>';

          expect(expectedResult).to.equalsIgnoreCase($cont.html());
        });
      });
    });