From 0499c4727036446f5c8a5722bbd9c4018dae146f Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Wed, 10 Nov 2010 16:08:54 -0800
Subject: added ng:switch-when-default; changed $watch to always fire on init.
 (may be backward incompatible)
---
 test/BinderTest.js     |  8 ++++----
 test/CompilerSpec.js   |  3 ++-
 test/directivesSpec.js |  4 ++--
 test/widgetsSpec.js    | 28 ++++++++++++++++++++++++++--
 4 files changed, 34 insertions(+), 9 deletions(-)
(limited to 'test')
diff --git a/test/BinderTest.js b/test/BinderTest.js
index 06f0a449..71b2f6b6 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -607,13 +607,13 @@ BinderTest.prototype.testItShouldListenOnRightScope = function() {
       '
');
     scope.$eval();
     scope.$eval();
-    expect(scope.$get('count')).toEqual(0);
+    expect(scope.$get('count')).toEqual(1);
 
     scope.$set('i', 0);
     scope.$eval();
     scope.$eval();
-    expect(scope.$get('count')).toEqual(1);
+    expect(scope.$get('count')).toEqual(2);
   });
 
   describe('ng:click', function(){
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 2d1aef1a..34ea6b1d 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -430,7 +430,11 @@ describe("widget", function(){
 
   describe('ng:switch', function(){
     it('should switch on value change', function(){
-      compile('
first:{{name}}
second:{{name}}
');
+      compile('
' +
+          'first:{{name}}
' +
+          'second:{{name}}
' +
+          'true:{{name}}
' +
+        '');
       expect(element.html()).toEqual('');
       scope.select = 1;
       scope.$eval();
@@ -444,8 +448,28 @@ describe("widget", function(){
       scope.name = 'misko';
       scope.$eval();
       expect(element.text()).toEqual('second:misko');
+      scope.select = true;
+      scope.$eval();
+      expect(element.text()).toEqual('true:misko');
+    });
+    
+    it("should compare stringified versions", function(){
+      var switchWidget = angular.widget('ng:switch');
+      expect(switchWidget.equals(true, 'true')).toEqual(true);
     });
 
+    it('should switch on switch-when-default', function(){
+      compile('
' +
+          'one
' +
+          'other
' +
+        '');
+      scope.$eval();
+      expect(element.text()).toEqual('other');
+      scope.select = 1;
+      scope.$eval();
+      expect(element.text()).toEqual('one');
+    });
+    
     it("should match urls", function(){
       var scope = angular.compile('
{{params.name}}
');
       scope.url = '/Book/Moby';
@@ -459,7 +483,7 @@ describe("widget", function(){
       expect(match).toBeFalsy();
     });
 
-    it('should call init on switch', function(){
+    it('should call change on switch', function(){
       var scope = angular.compile('
{{name}}
');
       var cleared = false;
       scope.url = 'a';
-- 
cgit v1.2.3