1
1
describe ( 'datetimepicker' , function ( ) {
2
- it ( 'should fail' , function ( ) {
3
- expect ( true ) . toBe ( false ) ;
2
+ describe ( 'utility functions' , function ( ) {
3
+ var util = $ . timepicker . util ;
4
+
5
+ describe ( 'extendRemove' , function ( ) {
6
+ var target ,
7
+ props ;
8
+
9
+ beforeEach ( function ( ) {
10
+ target = { } ;
11
+ props = { } ;
12
+ } ) ;
13
+
14
+ it ( 'should add a nonexistent property to the target' , function ( ) {
15
+ var expectedValue = "set" ,
16
+ propertyName = "prop" ;
17
+ props [ propertyName ] = expectedValue ;
18
+
19
+ var newTarget = util . _extendRemove ( target , props ) ;
20
+
21
+ expect ( target [ propertyName ] ) . toBe ( expectedValue ) ;
22
+ expect ( newTarget ) . toBe ( target ) ;
23
+ } ) ;
24
+
25
+ it ( 'should change the value of an existing property' , function ( ) {
26
+ var expectedValue = "new" ,
27
+ originalValue = "old" ,
28
+ propertyName = "prop" ;
29
+ target [ propertyName ] = originalValue ;
30
+ props [ propertyName ] = expectedValue ;
31
+
32
+ util . _extendRemove ( target , props ) ;
33
+
34
+ expect ( target [ propertyName ] ) . not . toBe ( originalValue ) ;
35
+ expect ( target [ propertyName ] ) . toBe ( expectedValue ) ;
36
+ } ) ;
37
+
38
+ it ( 'should null the value of an existing property' , function ( ) {
39
+ var expectedValue = null ,
40
+ propertyName = "prop" ;
41
+ target [ propertyName ] = "original" ;
42
+ props [ propertyName ] = expectedValue ;
43
+
44
+ util . _extendRemove ( target , props ) ;
45
+
46
+ expect ( target [ propertyName ] ) . toBeNull ( ) ;
47
+ } ) ;
48
+ } ) ;
49
+
50
+ describe ( 'isEmptyObject' , function ( ) {
51
+ it ( 'should say an empty object is empty' , function ( ) {
52
+ expect ( util . _isEmptyObject ( { } ) ) . toBe ( true ) ;
53
+ } ) ;
54
+
55
+ it ( 'should say an object with a property is not empty' , function ( ) {
56
+ var testObject = { "prop" : "value" } ;
57
+
58
+ expect ( util . _isEmptyObject ( testObject ) ) . toBe ( false ) ;
59
+ } ) ;
60
+
61
+ it ( 'should say object with a supplemental prototype property is empty' , function ( ) {
62
+ var testObject = new Function ( ) ;
63
+ testObject . prototype [ "prop" ] = "something" ;
64
+
65
+ expect ( util . _isEmptyObject ( testObject ) ) . toBe ( true ) ;
66
+ } )
67
+ } ) ;
4
68
} ) ;
5
69
} ) ;
0 commit comments