|
| 1 | +/*globals ddescribe, describe, beforeEach, it, expect, module, inject, jQuery, moment, spyOn */ |
| 2 | + |
| 3 | +/** |
| 4 | + * @license angular-bootstrap-datetimepicker |
| 5 | + * (c) 2014 Knight Rider Consulting, Inc. http://www.knightrider.com |
| 6 | + * License: MIT |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * |
| 11 | + * @author Dale "Ducky" Lotts |
| 12 | + * @since 11/15/2014 |
| 13 | + */ |
| 14 | + |
| 15 | +describe('dateimePickerConfig', function () { |
| 16 | + 'use strict'; |
| 17 | + var $rootScope, $compile; |
| 18 | + |
| 19 | + beforeEach(module('ui.bootstrap.datetimepicker')); |
| 20 | + |
| 21 | + beforeEach(inject(function (_$compile_, _$rootScope_) { |
| 22 | + moment.locale('en'); |
| 23 | + $compile = _$compile_; |
| 24 | + $rootScope = _$rootScope_; |
| 25 | + })); |
| 26 | + |
| 27 | + |
| 28 | + describe('retrieves information from', function () { |
| 29 | + it('function on scope', function () { |
| 30 | + |
| 31 | + var $scope = $rootScope.$new(); |
| 32 | + $scope.date = moment('2014-11-15T00:00:00.000').toDate(); |
| 33 | + $scope.configFunction = function configFunction() { |
| 34 | + return {startView: 'month'}; |
| 35 | + }; |
| 36 | + |
| 37 | + spyOn($scope, 'configFunction').and.callThrough(); |
| 38 | + |
| 39 | + var element = $compile('<datetimepicker data-ng-model="date" data-datetimepicker-config="configFunction()" ></datetimepicker>')($scope); |
| 40 | + $scope.$digest(); |
| 41 | + |
| 42 | + expect(jQuery('.switch', element).text()).toBe('2014'); |
| 43 | + expect($scope.configFunction).toHaveBeenCalled(); |
| 44 | + }); |
| 45 | + |
| 46 | + it('property on scope', function () { |
| 47 | + |
| 48 | + var $scope = $rootScope.$new(); |
| 49 | + $scope.date = moment('2014-11-15T00:00:00.000').toDate(); |
| 50 | + $scope.config = { |
| 51 | + datetimePicker: { |
| 52 | + startView: 'year' |
| 53 | + } |
| 54 | + }; |
| 55 | + |
| 56 | + spyOn($scope, 'config').and.callThrough(); |
| 57 | + |
| 58 | + var element = $compile('<datetimepicker data-ng-model="date" data-datetimepicker-config="config.datetimePicker" ></datetimepicker>')($scope); |
| 59 | + $scope.$digest(); |
| 60 | + |
| 61 | + expect(jQuery('.switch', element).text()).toBe('2010-2019'); |
| 62 | + }); |
| 63 | + }); |
| 64 | +}); |
0 commit comments