Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proves #381: Failing testcase for repeated TableCellIterator.next()
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
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 |
---|---|---|
|
@@ -30,3 +30,6 @@ node_modules | |
dist | ||
dist/doc | ||
tmp | ||
|
||
# IDE / Editor genereated files | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -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); | ||
}); |