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/widgetsSpec.js | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
(limited to 'test/widgetsSpec.js')
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