Skip to content

Commit

Permalink
Proves #381: Failing testcase for repeated TableCellIterator.next()
Browse files Browse the repository at this point in the history
  • Loading branch information
dmukhg committed Jan 8, 2016
1 parent 94885ca commit 07b6195
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -30,3 +30,6 @@ node_modules
dist
dist/doc
tmp

# IDE / Editor genereated files
.idea
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions test/unit/packages/table/TableCellIterator.test.js
@@ -0,0 +1,66 @@
'use strict';

require('../../qunit_extensions');
var SampleArticle = require('../../../fixtures/sample1.js');
var uuid = require('../../../../util/uuid');

var TableCellIterator = require('../../../../packages/table/TableCellIterator');

QUnit.module('packages/table/TableCellIterator');

QUnit.test('Iterator should return as many cells as were created', function (assert) {
var article = SampleArticle();

var newTableId = uuid('table');
var newSectionId = uuid('table-section');
var newRowId = uuid('table-row');

article.FORCE_TRANSACTIONS = false;
var newCell1 = article.create({
id: uuid('table-cell'),
type: 'table-cell',
parent: newRowId,
content: 'cell 0',
cellType: 'data'
});

var newCell2 = article.create({
id: uuid('table-cell'),
type: 'table-cell',
parent: newRowId,
content: 'cell 1',
cellType: 'data'
});

var newRow = article.create({
id: newRowId,
type: 'table-row',
parent: newSectionId,
cells: [newCell1.id, newCell2.id]
});

var newSection = article.create({
id: newSectionId,
type: 'table-section',
parent: newTableId,
sectionType: 'body',
rows: [newRow.id]
});

var newTable = article.create({
id: newTableId,
type: 'table',
sections: [newSection.id]
});

var table = article.get(newTableId);
var iterator = new TableCellIterator(table);

var cellNode;
var cellNodeCount = 0;
while ((cellNode = iterator.next()) !== null) {
cellNodeCount++;
}

assert.equal(cellNodeCount, 2);
});

0 comments on commit 07b6195

Please sign in to comment.