mirror of
https://github.com/thangisme/notes.git
synced 2025-09-24 19:34:13 -04:00
Initial commit
This commit is contained in:
119
node_modules/table/test/mapDataUsingRowHeightIndex.js
generated
vendored
Normal file
119
node_modules/table/test/mapDataUsingRowHeightIndex.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import mapDataUsingRowHeightIndex from './../src/mapDataUsingRowHeightIndex';
|
||||
|
||||
describe('mapDataUsingRowHeightIndex', () => {
|
||||
context('no data spans multiple rows', () => {
|
||||
it('maps data to a single cell', () => {
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = [
|
||||
1
|
||||
];
|
||||
|
||||
const data = [
|
||||
[
|
||||
'aa'
|
||||
]
|
||||
];
|
||||
|
||||
const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);
|
||||
|
||||
expect(mappedData).to.deep.equal([
|
||||
[
|
||||
'aa'
|
||||
]
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
context('single cell spans multiple rows', () => {
|
||||
it('maps data to multiple rows', () => {
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = [
|
||||
5
|
||||
];
|
||||
|
||||
const data = [
|
||||
[
|
||||
'aabbccddee'
|
||||
]
|
||||
];
|
||||
|
||||
const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);
|
||||
|
||||
expect(mappedData).to.deep.equal([
|
||||
['aa'],
|
||||
['bb'],
|
||||
['cc'],
|
||||
['dd'],
|
||||
['ee']
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
context('multiple cells spans multiple rows', () => {
|
||||
it('maps data to multiple rows', () => {
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2
|
||||
},
|
||||
1: {
|
||||
width: 4
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = [
|
||||
5
|
||||
];
|
||||
|
||||
const data = [
|
||||
[
|
||||
'aabbccddee',
|
||||
'00001111'
|
||||
]
|
||||
];
|
||||
|
||||
const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);
|
||||
|
||||
expect(mappedData).to.deep.equal([
|
||||
[
|
||||
'aa',
|
||||
'0000'
|
||||
],
|
||||
[
|
||||
'bb',
|
||||
'1111'
|
||||
],
|
||||
[
|
||||
'cc',
|
||||
''
|
||||
],
|
||||
[
|
||||
'dd',
|
||||
''
|
||||
],
|
||||
[
|
||||
'ee',
|
||||
''
|
||||
]
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user