mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix(scenario): include "not " in error messages if test is inverted
Closes #3840
This commit is contained in:
parent
be0b485669
commit
3589f17824
1 changed files with 4 additions and 6 deletions
|
|
@ -74,18 +74,16 @@ angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
|
|||
*/
|
||||
angular.scenario.matcher = angular.scenario.matcher || function(name, fn) {
|
||||
angular.scenario.matcher[name] = function(expected) {
|
||||
var prefix = 'expect ' + this.future.name + ' ';
|
||||
if (this.inverse) {
|
||||
prefix += 'not ';
|
||||
}
|
||||
var prefix = 'expect ' + this.future.name + ' ',
|
||||
not = this.inverse && 'not ';
|
||||
var self = this;
|
||||
this.addFuture(prefix + name + ' ' + angular.toJson(expected),
|
||||
this.addFuture(prefix + not + name + ' ' + angular.toJson(expected),
|
||||
function(done) {
|
||||
var error;
|
||||
self.actual = self.future.value;
|
||||
if ((self.inverse && fn.call(self, expected)) ||
|
||||
(!self.inverse && !fn.call(self, expected))) {
|
||||
error = 'expected ' + angular.toJson(expected) +
|
||||
error = 'expected ' + not + name + ' ' + angular.toJson(expected) +
|
||||
' but was ' + angular.toJson(self.actual);
|
||||
}
|
||||
done(error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue