From 0af172040e03811c59d01682968241e3df226774 Mon Sep 17 00:00:00 2001 From: Lucas Galfasó Date: Wed, 6 Feb 2013 10:08:40 -0300 Subject: feat(ngSwitch): support multiple matches on ngSwitchWhen and ngSwitchDefault Closes #1074 --- test/ng/directive/ngSwitchSpec.js | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test/ng/directive') diff --git a/test/ng/directive/ngSwitchSpec.js b/test/ng/directive/ngSwitchSpec.js index ee91f79d..b817386c 100644 --- a/test/ng/directive/ngSwitchSpec.js +++ b/test/ng/directive/ngSwitchSpec.js @@ -36,6 +36,36 @@ describe('ngSwitch', function() { })); + it('should show all switch-whens that match the current value', inject(function($rootScope, $compile) { + element = $compile( + '')($rootScope); + expect(element.html()).toEqual('' + + '' + + '' + + ''); + $rootScope.select = 1; + $rootScope.$apply(); + expect(element.text()).toEqual('first:, first too:'); + $rootScope.name="shyam"; + $rootScope.$apply(); + expect(element.text()).toEqual('first:shyam, first too:shyam'); + $rootScope.select = 2; + $rootScope.$apply(); + expect(element.text()).toEqual('second:shyam'); + $rootScope.name = 'misko'; + $rootScope.$apply(); + expect(element.text()).toEqual('second:misko'); + $rootScope.select = true; + $rootScope.$apply(); + expect(element.text()).toEqual('true:misko'); + })); + + it('should switch on switch-when-default', inject(function($rootScope, $compile) { element = $compile( '' + @@ -50,6 +80,21 @@ describe('ngSwitch', function() { })); + it('should show all switch-when-default', inject(function($rootScope, $compile) { + element = $compile( + '')($rootScope); + $rootScope.$apply(); + expect(element.text()).toEqual('other, other too'); + $rootScope.select = 1; + $rootScope.$apply(); + expect(element.text()).toEqual('one'); + })); + + it('should call change on switch', inject(function($rootScope, $compile) { element = $compile( '' + -- cgit v1.2.3