Last active
December 31, 2015 19:39
-
-
Save rodyhaddad/8035190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('nulls in expressions', function() { | |
var props = ['b', 'c', 'd']; | |
var contexts = [ | |
{ 'b': null }, | |
{ 'b': { 'c': null } }, | |
{ 'b': { 'c': { 'd': null } } } | |
]; | |
forEach(props, function (prop, index) { | |
var expr = props.slice(0, index+1).join('.'); | |
forEach(contexts, function (a, expectIndex) { | |
expectIndex = parseInt(expectIndex, 10); | |
if (index < expectIndex) { // will be an object | |
it('blabla', inject(function($rootScope) { | |
$rootScope.a = a; | |
expect(typeof $rootScope.$eval('a.' + expr)).toBe('object'); | |
$rootScope.a = valueFn(a); | |
expect(typeof $rootScope.$eval('a().' + expr)).toBe('object'); | |
})); | |
} else { | |
var result = (index == expectIndex ? null : undefined); | |
it('blabla', inject(function($rootScope) { | |
$rootScope.a = a; | |
expect($rootScope.$eval('a.' + expr)).toBe(result); | |
$rootScope.a = valueFn(a); | |
expect($rootScope.$eval('a().' + expr)).toBe(result); | |
})); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment