angularjs - adding variables together in expect statement -


i have strings have extracted using protractor/jasmine/angularjs , converted integers. trying add these , compare in expect statement. getting promise errors in doing so.

var result0 = element.all(by.binding('inboxes.inbox.count')).first().gettext().then(parsefloat);     result0.then((value) => console.log("count: ", value));      var result1 = element.all(by.binding('inboxitem.count')).get(0).gettext().then(parsefloat);     result1.then((value) => console.log("count: ", value));      var result2 = element.all(by.binding('inboxitem.count')).get(1).gettext().then(parsefloat);     result2.then((value) => console.log("count: ", value));      var result3 = element.all(by.binding('inboxitem.count')).get(2).gettext().then(parsefloat);     result3.then((value) => console.log("count: ", value)).then(expect(result1 + result2 + result3).toequal(result0));      //compare badge counts inbox badge count     expect(result1 + result2 + result3).toequal(result0);   });  }); });  

i getting following promise errors. thought since promises had been satisfied , counts below print out (41, 7, 14 , 20) add bottom 3(reulst1-3) , compare result0 total of result1-3. having time these promises since new , don't quite understand them well.

started count:  41 count:  7 count:  14 count:  20 f  failures: 1) workflow application when selecting alerts panel should expand inbox panel , postings   message:   expected 'managedpromise::859 {[[promisestatus]]:  "pending"}managedpromise::896 {[[promisestatus]]: "pending"}managedpromise::933 {[[promisestatus]]: "pending"}' equal managedpromise::822 {[[promisestatus]]: "pending"}. 

you trying add promises together, not actual resolved values.

in case, solve using protractor.promise.all() resolve promises needed make expectation, @ once:

protractor.promise.all([result0, result1, result2, result3]).then(function (values) {     expect(values[1] + values[2] + values[3]).toequal(values[0]); }); 

and, simplify that, can spread() resolved values "then" function arguments:

protractor.promise.all([result0, result1, result2, result3]).then(spread(function (value0, value1, value2, value3) {     expect(value1 + value2 + value3).toequal(value0); })); 

note that, unlike q, protractor.promise not have spread() built-in , have have custom one.