11//make sure you import mocha-config before @angular/core
22import { assert } from "./test-config" ;
3- import { bootstrap } from "nativescript-angular/application" ;
4- import { Component } from "@angular/core" ;
53import { View } from "ui/core/view" ;
64import { ViewUtil } from "nativescript-angular/view-util" ;
75import { NgView , ViewExtensions , ViewClassMeta } from "nativescript-angular/element-registry" ;
86import { Red } from "color/known-colors" ;
9- import { device , Device , platformNames } from "platform" ;
7+ import { device , platformNames } from "platform" ;
108import { createDevice } from "./test-utils" ;
119
1210class TestView extends View implements ViewExtensions {
1311 public nodeName : string = "TestView" ;
1412 public templateParent : NgView = null ;
1513 public meta : ViewClassMeta = { skipAddToDom : false } ;
16- public cssClasses : Map < string , boolean > = new Map < string , boolean > ( ) ;
14+ public ngCssClasses : Map < string , boolean > = new Map < string , boolean > ( ) ;
1715
1816 public stringValue : string = "" ;
1917 public numValue : number = 0 ;
@@ -26,91 +24,91 @@ const iosDevice = createDevice(platformNames.ios);
2624const androidDevice = createDevice ( platformNames . android ) ;
2725
2826describe ( 'setting View properties' , ( ) => {
29- var viewUtil : ViewUtil ;
27+ let viewUtil : ViewUtil ;
3028 before ( ( ) => {
3129 viewUtil = new ViewUtil ( device ) ;
32- } )
30+ } ) ;
3331
3432 it ( 'preserves string values' , ( ) => {
3533 let view = new TestView ( ) ;
36- viewUtil . setProperty ( view , "stringValue" , "blah" )
34+ viewUtil . setProperty ( view , "stringValue" , "blah" ) ;
3735 assert . equal ( "blah" , view . stringValue ) ;
3836 } ) ;
3937
4038 it ( 'converts number values' , ( ) => {
4139 let view = new TestView ( ) ;
42- viewUtil . setProperty ( view , "numValue" , "42" )
40+ viewUtil . setProperty ( view , "numValue" , "42" ) ;
4341 assert . strictEqual ( 42 , view . numValue ) ;
44- viewUtil . setProperty ( view , "numValue" , 0 )
42+ viewUtil . setProperty ( view , "numValue" , 0 ) ;
4543 assert . strictEqual ( 0 , view . numValue ) ;
4644 } ) ;
4745
4846 it ( 'converts boolean values' , ( ) => {
4947 let view = new TestView ( ) ;
50- viewUtil . setProperty ( view , "boolValue" , "true" )
48+ viewUtil . setProperty ( view , "boolValue" , "true" ) ;
5149 assert . strictEqual ( true , view . boolValue ) ;
52- viewUtil . setProperty ( view , "boolValue" , "false" )
50+ viewUtil . setProperty ( view , "boolValue" , "false" ) ;
5351 assert . strictEqual ( false , view . boolValue ) ;
5452 } ) ;
5553
5654 it ( 'sets style values' , ( ) => {
5755 let view = new TestView ( ) ;
58- viewUtil . setProperty ( view , "style" , "color: red" )
56+ viewUtil . setProperty ( view , "style" , "color: red" ) ;
5957 assert . equal ( Red , view . style . color . hex ) ;
6058 } ) ;
6159
6260 it ( 'doesn\'t convert blank strings' , ( ) => {
6361 let view = new TestView ( ) ;
64- viewUtil . setProperty ( view , "stringValue" , "" )
62+ viewUtil . setProperty ( view , "stringValue" , "" ) ;
6563 assert . strictEqual ( "" , view . stringValue ) ;
6664 } ) ;
6765
6866 it ( 'doesn\'t convert booleans' , ( ) => {
6967 let view = new TestView ( ) ;
70- viewUtil . setProperty ( view , "boolValue" , true )
68+ viewUtil . setProperty ( view , "boolValue" , true ) ;
7169 assert . strictEqual ( true , view . boolValue ) ;
72- viewUtil . setProperty ( view , "boolValue" , false )
70+ viewUtil . setProperty ( view , "boolValue" , false ) ;
7371 assert . strictEqual ( false , view . boolValue ) ;
7472 } ) ;
7573
7674 it ( 'preserves objects' , ( ) => {
7775 let value = { name : "Jim" , age : 23 } ;
7876 let view = new TestView ( ) ;
79- viewUtil . setProperty ( view , "anyValue" , value )
77+ viewUtil . setProperty ( view , "anyValue" , value ) ;
8078 assert . deepEqual ( value , view . anyValue ) ;
8179 } ) ;
8280
8381 it ( 'sets nested properties' , ( ) => {
8482 let view = new TestView ( ) ;
85- viewUtil . setProperty ( view , "nested.property" , "blah" )
83+ viewUtil . setProperty ( view , "nested.property" , "blah" ) ;
8684 assert . strictEqual ( "blah" , view . nested . property ) ;
8785 } ) ;
8886
8987 it ( 'sets ios property in ios' , ( ) => {
9088 let view = new TestView ( ) ;
9189 let testUtil = new ViewUtil ( iosDevice ) ;
92- testUtil . setProperty ( view , "@ios:anyValue" , "blah" )
90+ testUtil . setProperty ( view , "@ios:anyValue" , "blah" ) ;
9391 assert . strictEqual ( "blah" , view . anyValue ) ;
9492 } ) ;
9593
9694 it ( 'doesn\'t set android property in ios' , ( ) => {
9795 let view = new TestView ( ) ;
9896 let testUtil = new ViewUtil ( iosDevice ) ;
99- testUtil . setProperty ( view , "@android:anyValue" , "blah" )
97+ testUtil . setProperty ( view , "@android:anyValue" , "blah" ) ;
10098 assert . isUndefined ( view . anyValue ) ;
10199 } ) ;
102100
103101 it ( 'sets android property in android' , ( ) => {
104102 let view = new TestView ( ) ;
105103 let testUtil = new ViewUtil ( androidDevice ) ;
106- testUtil . setProperty ( view , "@android:anyValue" , "blah" )
104+ testUtil . setProperty ( view , "@android:anyValue" , "blah" ) ;
107105 assert . strictEqual ( "blah" , view . anyValue ) ;
108106 } ) ;
109107
110108 it ( 'doesn\'t set ios property in android' , ( ) => {
111109 let view = new TestView ( ) ;
112110 let testUtil = new ViewUtil ( androidDevice ) ;
113- testUtil . setProperty ( view , "@ios:anyValue" , "blah" )
111+ testUtil . setProperty ( view , "@ios:anyValue" , "blah" ) ;
114112 assert . isUndefined ( view . anyValue ) ;
115113 } ) ;
116114} ) ;
0 commit comments