|
| 1 | +/*globals describe, beforeEach, it, expect, module, inject */ |
| 2 | + |
| 3 | +/** |
| 4 | + * @license angular-bootstrap-datetimepicker |
| 5 | + * Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com |
| 6 | + * License: MIT |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * |
| 11 | + * @author Dale "Ducky" Lotts |
| 12 | + * @since 7/21/13 |
| 13 | + */ |
| 14 | + |
| 15 | +describe('refreshEvent', function () { |
| 16 | + 'use strict'; |
| 17 | + var $rootScope; |
| 18 | + var $compile; |
| 19 | + beforeEach(module('ui.bootstrap.datetimepicker')); |
| 20 | + beforeEach(inject(function (_$compile_, _$rootScope_) { |
| 21 | + $compile = _$compile_; |
| 22 | + $rootScope = _$rootScope_; |
| 23 | + $rootScope.date = null; |
| 24 | + })); |
| 25 | + |
| 26 | + describe('throws exception', function () { |
| 27 | + it('if value is an empty string', function () { |
| 28 | + function compile() { |
| 29 | + $compile('<datetimepicker data-ng-model="date" data-datetimepicker-config="{ renderOn: \'\' }"></datetimepicker>')($rootScope); |
| 30 | + } |
| 31 | + |
| 32 | + expect(compile).toThrow('invalid renderOn value: '); |
| 33 | + }); |
| 34 | + it('if value is a numeric value', function () { |
| 35 | + function compile() { |
| 36 | + $compile('<datetimepicker data-ng-model="date" data-datetimepicker-config="{ minView: 0 }"></datetimepicker>')($rootScope); |
| 37 | + } |
| 38 | + |
| 39 | + expect(compile).toThrow('invalid minView value: 0'); |
| 40 | + }); |
| 41 | + it('if value is greater than startView', function () { |
| 42 | + function compile() { |
| 43 | + $compile('<datetimepicker data-ng-model="date" data-datetimepicker-config="{ startView: \'month\', minView: \'year\' }"></datetimepicker>')($rootScope); |
| 44 | + } |
| 45 | + |
| 46 | + expect(compile).toThrow('startView must be greater than minView'); |
| 47 | + }); |
| 48 | + }); |
| 49 | + describe('does NOT throw exception for valid values', function () { |
| 50 | + it('if value is between 1 and 59', function () { |
| 51 | + var validViews = ['year', 'month', 'day', 'hour', 'minute']; |
| 52 | + |
| 53 | + for (var i = 0; i < validViews.length; i += 1) { |
| 54 | + $compile('<datetimepicker data-ng-model="date" data-datetimepicker-config="{ startView: \'year\', minView: \'' + validViews[i] + '\' }"></datetimepicker>')($rootScope); |
| 55 | + } |
| 56 | + }); |
| 57 | + }); |
| 58 | +}); |
| 59 | + |
0 commit comments