mirror of
https://github.com/thangisme/notes.git
synced 2025-11-23 13:12:25 -05:00
Initial commit
This commit is contained in:
78
node_modules/table/test/calculateRowHeightIndex.js
generated
vendored
Normal file
78
node_modules/table/test/calculateRowHeightIndex.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import calculateRowHeightIndex from './../src/calculateRowHeightIndex';
|
||||
|
||||
describe('calculateRowHeightIndex', () => {
|
||||
context('single column', () => {
|
||||
context('cell content width is lesser than column width', () => {
|
||||
it('is equal to 1', () => {
|
||||
const data = [
|
||||
[
|
||||
'aaa'
|
||||
]
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 10,
|
||||
wrapWord: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = calculateRowHeightIndex(data, config);
|
||||
|
||||
expect(rowSpanIndex[0]).to.equal(1);
|
||||
});
|
||||
});
|
||||
context('cell content width is twice the size of the column width', () => {
|
||||
it('is equal to 2', () => {
|
||||
const data = [
|
||||
[
|
||||
'aaabbb'
|
||||
]
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 3,
|
||||
wrapWord: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = calculateRowHeightIndex(data, config);
|
||||
|
||||
expect(rowSpanIndex[0]).to.equal(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
context('multiple columns', () => {
|
||||
context('multiple cell content width is greater than the column width', () => {
|
||||
it('uses the largest height', () => {
|
||||
const data = [
|
||||
['aaabbb'],
|
||||
['aaabbb']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2,
|
||||
wrapWord: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = calculateRowHeightIndex(data, config);
|
||||
|
||||
expect(rowSpanIndex[0]).to.equal(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user