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