Skip to content

Commit

Permalink
Adjustments to three tests due to change in StyleContextStack.autopus…
Browse files Browse the repository at this point in the history
…h() behavior for speed.
  • Loading branch information
estanglerbm committed Jun 17, 2024
1 parent 38169bd commit d0f6560
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions tests/styleContextStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ describe('StyleContextStack', function () {

var defaultStyle = { fontSize: 12, bold: false, font: 'Helvetica' };

var styleProperties = [
'font',
'fontSize',
'fontFeatures',
'bold',
'italics',
'alignment',
'color',
'columnGap',
'fillColor',
'fillOpacity',
'decoration',
'decorationStyle',
'decorationColor',
'background',
'lineHeight',
'characterSpacing',
'noWrap',
'markerColor',
'leadingIndent',
'sup',
'sub'
//'tableCellPadding'
// 'cellBorder',
// 'headerCellBorder',
// 'oddRowCellBorder',
// 'evenRowCellBorder',
// 'tableBorder'
];

var stackWithDefaultStyle;
var fullStack;

Expand Down Expand Up @@ -113,21 +143,25 @@ describe('StyleContextStack', function () {
});

describe('autopush', function () {
it('should not push anything if no style nor style-property is defined', function () {
assert.equal(fullStack.autopush({ anotherProperty: 'test' }), 0);
it('should not push any style if no style nor style-property is defined', function () {
assert.equal(fullStack.autopush({ anotherProperty: 'test' }), 1);
assert.equal(fullStack.styleOverrides.length, 1);
styleProperties.forEach(function(key) {
assert.equal(fullStack.styleOverrides[0][key], undefined);
});
});

it('should push style name if object specifies it in the style property', function () {
assert.equal(fullStack.styleOverrides.length, 0);
assert.equal(fullStack.autopush({ anotherProperty: 'test', style: 'header' }), 1);
assert.equal(fullStack.styleOverrides.length, 1);
assert.equal(fullStack.autopush({ anotherProperty: 'test', style: 'header' }), 2);
assert.equal(fullStack.styleOverrides.length, 2);
assert.equal(fullStack.styleOverrides[0], 'header');
});

it('should push all style names if object specifies them as an array in the style property', function () {
assert.equal(fullStack.styleOverrides.length, 0);
assert.equal(fullStack.autopush({ anotherProperty: 'test', style: ['header', 'small'] }), 2);
assert.equal(fullStack.styleOverrides.length, 2);
assert.equal(fullStack.autopush({ anotherProperty: 'test', style: ['header', 'small'] }), 3);
assert.equal(fullStack.styleOverrides.length, 3);
assert.equal(fullStack.styleOverrides[0], 'header');
assert.equal(fullStack.styleOverrides[1], 'small');
});
Expand Down

0 comments on commit d0f6560

Please sign in to comment.