@@ -16,6 +16,7 @@ class TestView extends View implements ViewExtensions {
16
16
public stringValue : string = "" ;
17
17
public numValue : number = 0 ;
18
18
public boolValue : boolean = undefined ;
19
+ public anyValue : any = undefined ;
19
20
}
20
21
21
22
describe ( 'setting View properties' , ( ) => {
@@ -29,6 +30,8 @@ describe('setting View properties', () => {
29
30
let view = new TestView ( ) ;
30
31
setProperty ( view , "numValue" , "42" )
31
32
assert . strictEqual ( 42 , view . numValue ) ;
33
+ setProperty ( view , "numValue" , 0 )
34
+ assert . strictEqual ( 0 , view . numValue ) ;
32
35
} ) ;
33
36
34
37
it ( 'converts boolean values' , ( ) => {
@@ -44,4 +47,25 @@ describe('setting View properties', () => {
44
47
setProperty ( view , "style" , "color: red" )
45
48
assert . equal ( Red , view . style . color . hex ) ;
46
49
} ) ;
50
+
51
+ it ( 'doesn\'t convert blank strings' , ( ) => {
52
+ let view = new TestView ( ) ;
53
+ setProperty ( view , "stringValue" , "" )
54
+ assert . strictEqual ( "" , view . stringValue ) ;
55
+ } ) ;
56
+
57
+ it ( 'doesn\'t convert booleans' , ( ) => {
58
+ let view = new TestView ( ) ;
59
+ setProperty ( view , "boolValue" , true )
60
+ assert . strictEqual ( true , view . boolValue ) ;
61
+ setProperty ( view , "boolValue" , false )
62
+ assert . strictEqual ( false , view . boolValue ) ;
63
+ } ) ;
64
+
65
+ it ( 'preserves objects' , ( ) => {
66
+ let value = { name : "Jim" , age : 23 } ;
67
+ let view = new TestView ( ) ;
68
+ setProperty ( view , "anyValue" , value )
69
+ assert . deepEqual ( value , view . anyValue ) ;
70
+ } ) ;
47
71
} ) ;
0 commit comments