mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Fix toEqual matcher to use angular.equals instead of simple == comparison, which breaks down for arrays and objects
This commit is contained in:
parent
04e92a8753
commit
cf33105011
4 changed files with 20 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ Matcher.addMatcher = function(name, matcher) {
|
|||
};
|
||||
};
|
||||
|
||||
Matcher.addMatcher('toEqual', function(a,b) { return a == b; });
|
||||
Matcher.addMatcher('toEqual', angular.equals);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
@ -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
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue