aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTobias Bosch2013-11-11 15:54:24 -0800
committerTobias Bosch2013-11-11 17:05:43 -0800
commit4612705ec297bc6ba714cb7a98f1be6aff77c4b8 (patch)
treedf6c86676b318c1ac5e9566259549805751bb5cd /test
parent9577702e8d2519c1a60f5ac4058e63bd7b919815 (diff)
downloadangular.js-4612705ec297bc6ba714cb7a98f1be6aff77c4b8.tar.bz2
fix(ngIf): don't create multiple elements when changing from a truthy to another thruthy value.
Fixes #4852.
Diffstat (limited to 'test')
-rwxr-xr-xtest/ng/directive/ngIfSpec.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ng/directive/ngIfSpec.js b/test/ng/directive/ngIfSpec.js
index ce4de98c..3173f476 100755
--- a/test/ng/directive/ngIfSpec.js
+++ b/test/ng/directive/ngIfSpec.js
@@ -28,6 +28,22 @@ describe('ngIf', function () {
expect(element.children().length).toBe(1);
});
+ it('should not add the element twice if the condition goes from true to true', function () {
+ $scope.hello = 'true1';
+ makeIf('hello');
+ expect(element.children().length).toBe(1);
+ $scope.$apply('hello = "true2"');
+ expect(element.children().length).toBe(1);
+ });
+
+ it('should not recreate the element if the condition goes from true to true', function () {
+ $scope.hello = 'true1';
+ makeIf('hello');
+ element.children().data('flag', true);
+ $scope.$apply('hello = "true2"');
+ expect(element.children().data('flag')).toBe(true);
+ });
+
it('should create then remove the element if condition changes', function () {
$scope.hello = true;
makeIf('hello');