diff --git a/karma.conf.js b/karma.conf.js index d5dbe2c..b95d14d 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -4,10 +4,9 @@ module.exports = function(config){ basePath : './', files : [ - //'bower_components/angular/angular.js', 'bower_components/ionic/js/ionic.bundle.js', 'bower_components/angular-mocks/angular-mocks.js', - 'src*/**/*.js', + 'dist*/**/*.js', 'tests*/**/*.js' ], @@ -29,5 +28,5 @@ module.exports = function(config){ suite: 'unit' } - }); +}); }; diff --git a/tests/ion-wizard_test.js b/tests/ion-wizard_test.js index 0389430..401f837 100644 --- a/tests/ion-wizard_test.js +++ b/tests/ion-wizard_test.js @@ -32,7 +32,7 @@ describe('Unit testing wizard directives', function() { wrappedElement = angular.element(element); })); - it('Broadcasts next event on click', function() { + it('Should broadcast next event on click', function() { // Compile a piece of HTML containing the directive element = $compile("")(scope); @@ -41,28 +41,24 @@ describe('Unit testing wizard directives', function() { }); - it('Hides next button when reaching the last wizard step', function() { + it('Should hide next button when reaching the last wizard step', function() { - spyOn($ionicSlideBoxDelegate, 'currentIndex').andReturn(2); spyOn($ionicSlideBoxDelegate, 'slidesCount').andReturn(3); // Compile a piece of HTML containing the directive $compile(wrappedElement)(scope); - $rootScope.$broadcast('wizard:IndexChanged'); - expect($rootScope.$broadcast).toHaveBeenCalledWith("wizard:IndexChanged"); + $rootScope.$broadcast('slideBox.slideChanged', 2); expect(wrappedElement.hasClass('ng-hide')).toBeTruthy(); }); - it('Does not hide next button if not the end of wizard', function() { - spyOn($ionicSlideBoxDelegate, 'currentIndex').andReturn(1); + it('Should display next button if not the end of wizard', function() { spyOn($ionicSlideBoxDelegate, 'slidesCount').andReturn(13); $compile(wrappedElement)(scope); - $rootScope.$broadcast('wizard:IndexChanged'); - expect($rootScope.$broadcast).toHaveBeenCalledWith("wizard:IndexChanged"); + $rootScope.$broadcast('slideBox.slideChanged', 1); expect(wrappedElement.hasClass('ng-hide')).toBeFalsy(); }); @@ -80,7 +76,7 @@ describe('Unit testing wizard directives', function() { wrappedElement = angular.element(element); })); - it('Broadcasts next event on click', function() { + it('Should broadcast next event on click', function() { // Compile a piece of HTML containing the directive var el = $compile(element)(scope); @@ -89,24 +85,18 @@ describe('Unit testing wizard directives', function() { }); - it('Hides previous button on first step', function() { - spyOn($ionicSlideBoxDelegate, 'currentIndex').andReturn(0); - + it('Should hide previous button on first step', function() { $compile(wrappedElement)(scope); - $rootScope.$broadcast('wizard:IndexChanged'); - expect($rootScope.$broadcast).toHaveBeenCalledWith("wizard:IndexChanged"); + $rootScope.$broadcast('slideBox.slideChanged', 0); expect(wrappedElement.hasClass('ng-hide')).toBeTruthy(); }); - it('Does not hide previous button on other steps', function() { - spyOn($ionicSlideBoxDelegate, 'currentIndex').andReturn(2); - + it('Should display previous button on every other step', function() { $compile(wrappedElement)(scope); - $rootScope.$broadcast('wizard:IndexChanged'); - expect($rootScope.$broadcast).toHaveBeenCalledWith("wizard:IndexChanged"); + $rootScope.$broadcast('slideBox.slideChanged', 5); expect(wrappedElement.hasClass('ng-hide')).toBeFalsy(); }); @@ -120,6 +110,13 @@ describe('Unit testing wizard directives', function() { beforeEach(inject(function(_$ionicSlideBoxDelegate_) { $ionicSlideBoxDelegate = _$ionicSlideBoxDelegate_; + scope.conditionStep2 = function() { + return true; + }; + scope.conditionStep3 = function() { + return false; + }; + element = angular.element("