@@ -24,5 +24,74 @@ feel more connected, bringing delight in big and \
2424small ways, and empowering them to affect change."' ;
2525
2626const fontStyle = text1 . textRange . characterAttributes ;
27- fontStyle . textFont = app . textFonts . getByName ( "Courier " ) ;
27+ fontStyle . textFont = app . textFonts . getByName ( "MyriadPro-Bold " ) ;
2828fontStyle . size = 2.5 ;
29+
30+ // Tests for Array methods
31+
32+ lib . write ( '### TESTING ARRAY METHODS ###' ) ;
33+
34+ lib . write ( 'Testing map function' ) ;
35+ const testArray = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 1 ] ;
36+ testArray . map ( number => lib . write ( `map = ${ number } out of ${ testArray . length - 1 } = ${ number * 4 } ` ) ) ;
37+
38+ const reduceResult = testArray . reduce ( ( acc , curr ) => acc + curr , 0 ) ;
39+ lib . write ( `Testing reduce function = ${ reduceResult } ` ) ;
40+
41+ lib . write ( 'Testing forEach function' ) ;
42+ testArray . forEach ( value => lib . write ( `forEach = ${ value } ` ) ) ;
43+
44+
45+ lib . write ( 'Testing filter function' ) ;
46+
47+ const filteredArray = testArray . filter ( ( number ) => {
48+ if ( number % 2 === 0 ) {
49+ return true ;
50+ }
51+ return false ;
52+ } ) ;
53+
54+ filteredArray . forEach ( number => lib . write ( `Filter = ${ number } ` ) ) ;
55+
56+ lib . write ( 'Testing every function' ) ;
57+ testArray . every ( number => {
58+ if ( number < 3 ) {
59+ lib . write ( `Every = ${ number } ` ) ;
60+ return true ;
61+ }
62+ return false ;
63+ } ) ;
64+
65+ lib . write ( 'Testing indexOf function' ) ;
66+ lib . write ( testArray . indexOf ( 4 ) ) ;
67+
68+ lib . write ( 'Testing isArray function' ) ;
69+ const notArray = 10 ;
70+ lib . write ( Array . isArray ( notArray ) ) ;
71+ lib . write ( Array . isArray ( testArray ) ) ;
72+
73+ lib . write ( 'Testing lastIndexOf function' ) ;
74+ lib . write ( testArray . lastIndexOf ( 1 ) ) ;
75+
76+ lib . write ( 'Testing reduceRight function' ) ;
77+ const reduceRightResult = testArray . reduceRight ( ( acc , curr ) => acc + curr , 0 ) ;
78+ lib . write ( `Testing reduce function = ${ reduceRightResult } ` ) ;
79+
80+
81+ // Tests for Date methods
82+ lib . write ( '### TESTING Date METHODS ###' ) ;
83+
84+ const today = new Date ( ) ;
85+ lib . write ( today . toISOString ( ) ) ;
86+
87+ // Tests for Date methods
88+ lib . write ( '### TESTING Function METHODS ###' ) ;
89+ lib . write ( '### TESTING Object METHODS ###' ) ;
90+
91+ //TODO implement testing Fuction and Object methods
92+
93+ lib . write ( '### TESTING String METHODS ###' ) ;
94+ const newString = ' ThisIsSomeWordToTrim ' ;
95+
96+ lib . write ( `Before trimming: ${ newString } ` ) ;
97+ lib . write ( `After trimming: ${ newString . trim ( ) } ` ) ;
0 commit comments