Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
  • Loading branch information
georgehrke committed Jan 10, 2018
1 parent 37069d1 commit fd29650
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/js/unit/controllers/calendarlistcontrollerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
describe('CalendarListController', function() {
'use strict';

var controller, $scope, $rootScope, Calendar, CalendarService, $window, calendar, deferred;
var controller, $scope, $rootScope, Calendar, CalendarService, ColorUtility, $window, calendar, deferred;

beforeEach(module('Calendar', function($provide) {
$provide.value('Calendar', {});
Expand Down Expand Up @@ -54,6 +54,9 @@ describe('CalendarListController', function() {
unpublish: jasmine.createSpy()
};
};
ColorUtility = {
randomColor: () => {}
};

deferred = $q.defer();
deferred.resolve(new Calendar());
Expand All @@ -62,21 +65,18 @@ describe('CalendarListController', function() {

it ('should create a calendar', function() {
spyOn(CalendarService, 'create').and.returnValue(deferred.promise);
spyOn(ColorUtility, 'randomColor').and.returnValue('#ffffff');

controller = controller('CalendarListController', {
$scope: $scope,
CalendarService: CalendarService
CalendarService: CalendarService,
ColorUtility: ColorUtility
});

$scope.newCalendarInputVal = 'Sample Calendar';
$scope.newCalendarColorVal = '#ffffff';

$scope.create($scope.newCalendarInputVal, $scope.newCalendarColorVal);
$scope.create($scope.newCalendarInputVal);
expect(CalendarService.create).toHaveBeenCalledWith('Sample Calendar', '#ffffff');

//make sure values are reset
expect($scope.newCalendarInputVal).toBe('');
expect($scope.newCalendarColorVal).toBe('');
});

it ('should delete the selected calendar', function () {
Expand Down

0 comments on commit fd29650

Please sign in to comment.