in spec/integrated/non-vnext-spec/unencapsulating-projection-spec.js [100:208]
it('row-tri-state-checkbox should works as expected for non-vnext', function (done) {
let RowTriStateCheckboxProjection = pGrid.projections.RowTriStateCheckboxProjection;
let preCheckMap = {
russellwhyte: {
id: 'russellwhyte',
state: 'indeterminate',
transition: RowTriStateCheckboxProjection.CheckTransitionRule.indeterminateToCheckedFullCycle,
},
};
let rowTriState = new RowTriStateCheckboxProjection({
'row.check.id': 'UserName',
'column.checked': 'checkbox',
});
rowTriState.set('row.check.map', _.clone(preCheckMap));
let colq = new pGrid.projections.ColumnQueryable({
'column.lock': ['checkbox', 'UserName'],
});
let dataSource = new pGrid.projections.Memory({
seed: peopleData.value,
});
let projectionSetting = dataSource
.pipe(map).pipe(columns).pipe(coli18n).pipe(colq)
.pipe(rowTriState);
let grid = new Grid({
el: '#container',
projection: projectionSetting,
Layout: TableLayout.partial({
template: tmplJade,
renderers: [],
}),
});
gridView = grid.render({ fetch: true });
let headCheckboxSelector = '#container thead .column-tri-state-checkbox';
let bodyCheckboxSelector = '#container tbody .column-tri-state-checkbox';
driver.element(bodyCheckboxSelector)
.then((result) => {
let checkMap = gridView.projection.get('row.check.map');
let status = RowTriStateCheckboxProjection.statCheckMap(preCheckMap);
expect(checkMap).to.eql(preCheckMap);
expect(_.first(status.indeterminate)).to.eql(preCheckMap.russellwhyte);
expect(result.length).to.equal(16);
expect(result.first().find('span').hasClass('glyphicon-minus')).to.be.true;
return driver.click(result.first());
})
.then(() => {
let preStatus = RowTriStateCheckboxProjection.statCheckMap(preCheckMap);
let currentCheckMap = gridView.projection.get('row.check.map');
let diff = RowTriStateCheckboxProjection.diffCheckMap(preCheckMap, currentCheckMap);
let addedLog = diff.added;
let changedLog = diff.changed;
let removedLog = diff.removed;
let unchangedLog = diff.unchanged;
expect(_.isEmpty(addedLog) && _.isEmpty(removedLog) && _.isEmpty(unchangedLog)).to.be.true;
expect(_.has(changedLog, 'russellwhyte')).to.be.true;
expect(changedLog.russellwhyte.before).to.eql(preCheckMap.russellwhyte);
expect(changedLog.russellwhyte.after).to.eql(currentCheckMap.russellwhyte);
return driver.element(bodyCheckboxSelector);
})
.then((result) => {
expect(result.first().find('span').hasClass('glyphicon-ok')).to.be.true;
return driver.click(result.first());
})
.then(() => {
return driver.element(bodyCheckboxSelector);
})
.then((result) => {
expect(result.first().find('span:not([class])').length).to.equal(1);
})
.then(() => {
return driver.element(headCheckboxSelector);
})
.then((result) => {
return driver.click(result.first());
})
.then(() => {
return driver.element(bodyCheckboxSelector);
})
.then((result) => {
_.each(result, (checkbox) => {
let assertion = $(checkbox).find('span').hasClass('glyphicon-ok');
expect(assertion).to.be.true;
});
})
.then(() => {
return driver.element(headCheckboxSelector);
})
.then((result) => {
return driver.click(result.first());
})
.then(() => {
return driver.element(bodyCheckboxSelector);
})
.then((result) => {
_.each(result, (checkbox) => {
let checkboxSpan = $(checkbox).find('span:not([class])');
expect(checkboxSpan.length).to.equal(1);
});
})
.then(done)
.catch(console.log);
});