Fix toEqual matcher to use angular.equals instead of simple == comparison, which breaks down for arrays and objects

This commit is contained in:
Shyam Seshadri 2010-08-12 02:42:04 +08:00 committed by Shyam Seshadri
parent 04e92a8753
commit cf33105011
4 changed files with 20 additions and 9 deletions

View file

@ -8,9 +8,9 @@ load:
- src/Angular.js
- src/JSON.js
- src/*.js
- test/testabilityPatch.js
- src/scenario/Runner.js
- src/scenario/*.js
- test/testabilityPatch.js
- test/angular-mocks.js
- test/scenario/*.js
- test/*.js

View file

@ -18,4 +18,4 @@ Matcher.addMatcher = function(name, matcher) {
};
};
Matcher.addMatcher('toEqual', function(a,b) { return a == b; });
Matcher.addMatcher('toEqual', angular.equals);

View file

@ -27,4 +27,12 @@ describe('Matcher', function () {
expect(e).toEqual('Expected 456 but was 123');
}
});
it('should correctly match arrays', function() {
var future = $scenario.addFuture('Calculate first future', function(done) {
done(['a', 'b']);
});
matcher = new Matcher(this, future);
matcher.toEqual(['a', 'b']);
executeFutures();
});
});

View file

@ -35,22 +35,25 @@ function childNode(element, index) {
}
extend(angular, {
'bind': bind,
'compile': compile,
'copy': copy,
'element': jqLite,
'compile': compile,
'scope': createScope,
'copy': copy,
'extend': extend,
'equals': equals,
'foreach': foreach,
'noop':noop,
'bind':bind,
'toJson': toJson,
'fromJson': fromJson,
'identity':identity,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isObject': isObject,
'isString': isString,
'isFunction': isFunction,
'isObject': isObject,
'isNumber': isNumber,
'isArray': isArray,
'noop':noop,
'scope': createScope
'isArray': isArray
});