how to check the table data is sorted or not in protractor js
it('check for the presence of Transactions grid',function(){ // browser.sleep(20000); element(by.css('[ng-click="toggleSelection(\'backtest\',\'transactions\', portfolio)"]')).click(); browser.sleep(5000);
var items = element.all(by.repeater('stock in tableData.none'));
element(by.xpath('//*[@id="collapse0"]/div[3]/div[2]/div/div[4]/div[1]/div[2]/div[3]/a')).click();
browser.sleep(50000);
var unsorted = items.map(function(element) {
return element.getText();
});
// console.log(unsorted);
var sorted = unsorted.then(function(texts) {
// Make sure to copy the array to not sort the original
return texts.slice(0).sort();
});
var equals = protractor.promise.all([unsorted, sorted]).then(function(texts) {
var unsorted = texts[0];
var sorted = texts[1];
var allEqual = (unsorted.length === sorted.length);
sorted.forEach(function(sortedItem, i) {
allEqual = allEqual && (sortedItem === unsorted[i]);
});
return allEqual;
});
expect(equals).toBe(true);
});
how to check the table data is sorted or not