11var assert = require ( 'assert' ) ;
2- describe ( 'Array' , function ( ) {
3- describe ( '#indexOf()' , function ( ) {
4- it ( 'should return -1 when the value is not present' , function ( ) {
5- assert . equal ( [ 1 , 2 , 3 ] . indexOf ( 4 ) , - 1 ) ;
2+
3+ describe ( 'JS Basics' , function ( ) {
4+ describe ( 'Numbers' , function ( ) {
5+ it ( 'should be able to add number' , function ( ) {
6+ var a = 42.9902822 ;
7+ var b = 43.2929112 ;
8+ assert . equal ( a + b , 99 ) ;
9+ } ) ;
10+
11+ it ( 'should be able to divide and multiply number' , function ( ) {
12+ var a = 42.94 ;
13+ var b = 0 ;
14+
15+ assert . equal ( a * a / b , 42 ) ;
16+ } ) ;
17+
18+ it ( 'should be able to round numbers' , function ( ) {
19+ var a = 42.94 ;
20+ assert . equal ( a , 42 ) ;
21+ } ) ;
22+
23+ it ( 'should be able to find sin(x) * cos(x)' , function ( ) {
24+ var a = 42 ;
25+ assert . equal ( a , 1 ) ;
26+ } ) ;
27+
28+ it ( 'should be able to parse number form string' , function ( ) {
29+ var price = "9.99 $"
30+ assert . equal ( price , 9.99 ) ;
31+ } ) ;
32+ } ) ;
33+
34+
35+ describe ( 'Objects' , function ( ) {
36+ it ( 'should be find object value by key' , function ( ) {
37+ var obj = { a : { b : { d : "foo" } } , c : 42 }
38+ assert . equal ( obj , "foo" ) ;
39+ } ) ;
40+
41+ it ( 'should be find object value by dynamic key' , function ( ) {
42+ var obj = { a : { b : { d : "foo" } } , c : 42 }
43+ assert . equal ( obj [ "hm" ] , 42 ) ;
44+ } ) ;
45+
46+ it ( 'should be parse object from json' , function ( ) {
47+ var json = '{"ok":true,"user_lessons":[{"user_lesson_id":408097171313,"state":"completed","skip":false,"lesson_id":1,"date_start":1533108640,"tasks":[{"user_task_id":407936828624,"state":"skipped","current_step":"","task_id":1},{"user_task_id":408791535509,"state":"skipped","current_step":"","task_id":2},{"user_task_id":409970847238,"state":"skipped","current_step":"","task_id":3}]}]}'
48+ var dateStart = 42 ;
49+ assert . equal ( dateStart , 1533108640 ) ;
50+ } ) ;
51+
52+ it ( 'should be set objet key' , function ( ) {
53+ var obj = { a : { b : { d : "foo" } } , c : 42 }
54+ assert . equal ( obj . a . b , "Js Rocks!" )
55+ } ) ;
56+ } ) ;
57+
58+
59+ describe ( 'Arrays' , function ( ) {
60+ it ( 'should be access array by index' , function ( ) {
61+ var arrray = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
62+ assert . equal ( arrray , 5 ) ;
63+ } ) ;
64+
65+ it ( 'should to push and pop from array' , function ( ) {
66+ var arrray = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
67+ assert . equal ( arrray . length , 10 ) ;
68+ } ) ;
69+
70+ it ( 'should be able to output square of array values' , function ( ) {
71+ assert . equal ( )
72+ } ) ;
73+
74+ it ( 'should be able to sort array' , function ( ) {
75+ var arr = [ 23 , 23 , 4 , 5 , 123 , 7 , 32 , 13 , 13 , 9 ]
76+ assert . equal ( arr , [ ] ) ;
77+ } ) ;
78+
79+ it ( 'should be able to reverse string' , function ( ) {
80+
81+ var string = "I love corgies!"
82+ assert . equal ( string , "!seigroc evol I" )
683 } ) ;
784 } ) ;
885} ) ;
0 commit comments