aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng')
-rw-r--r--test/ng/parseSpec.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js
index 5e985f1f..4599c033 100644
--- a/test/ng/parseSpec.js
+++ b/test/ng/parseSpec.js
@@ -977,6 +977,55 @@ describe('parser', function() {
expect($parse('"name" + id').constant).toBe(false);
}));
});
+
+ describe('nulls in expressions', function() {
+ // simpleGetterFn1
+ it('should return null for `a` where `a` is null', inject(function($rootScope) {
+ $rootScope.a = null;
+ expect($rootScope.$eval('a')).toBe(null);
+ }));
+
+ it('should return undefined for `a` where `a` is undefined', inject(function($rootScope) {
+ expect($rootScope.$eval('a')).toBeUndefined();
+ }));
+
+ // simpleGetterFn2
+ it('should return undefined for properties of `null` constant', inject(function($rootScope) {
+ expect($rootScope.$eval('null.a')).toBeUndefined();
+ }));
+
+ it('should return undefined for properties of `null` values', inject(function($rootScope) {
+ $rootScope.a = null;
+ expect($rootScope.$eval('a.b')).toBeUndefined();
+ }));
+
+ it('should return null for `a.b` where `b` is null', inject(function($rootScope) {
+ $rootScope.a = { b: null };
+ expect($rootScope.$eval('a.b')).toBe(null);
+ }));
+
+ // cspSafeGetter && pathKeys.length < 6 || pathKeys.length > 2
+ it('should return null for `a.b.c.d.e` where `e` is null', inject(function($rootScope) {
+ $rootScope.a = { b: { c: { d: { e: null } } } };
+ expect($rootScope.$eval('a.b.c.d.e')).toBe(null);
+ }));
+
+ it('should return undefined for `a.b.c.d.e` where `d` is null', inject(function($rootScope) {
+ $rootScope.a = { b: { c: { d: null } } };
+ expect($rootScope.$eval('a.b.c.d.e')).toBeUndefined();
+ }));
+
+ // cspSafeGetter || pathKeys.length > 6
+ it('should return null for `a.b.c.d.e.f.g` where `g` is null', inject(function($rootScope) {
+ $rootScope.a = { b: { c: { d: { e: { f: { g: null } } } } } };
+ expect($rootScope.$eval('a.b.c.d.e.f.g')).toBe(null);
+ }));
+
+ it('should return undefined for `a.b.c.d.e.f.g` where `f` is null', inject(function($rootScope) {
+ $rootScope.a = { b: { c: { d: { e: { f: null } } } } };
+ expect($rootScope.$eval('a.b.c.d.e.f.g')).toBeUndefined();
+ }));
+ });
});
});
});