@@ -27,6 +27,91 @@ describe("utils", () => {
27
27
} ) ;
28
28
} ) ;
29
29
30
+ describe ( "isParallelValid" , ( ) => {
31
+ it ( "should return false for a float value" , ( ) => {
32
+ expect ( utils . isParallelValid ( 1.2 ) ) . to . be . equal ( false ) ;
33
+ expect ( utils . isParallelValid ( "7.3" ) ) . to . be . equal ( false ) ;
34
+ expect ( utils . isParallelValid ( 7.33333 ) ) . to . be . equal ( false ) ;
35
+ expect ( utils . isParallelValid ( "1.2.2.2" ) ) . to . be . equal ( false ) ;
36
+ expect ( utils . isParallelValid ( "1.456789" ) ) . to . be . equal ( false ) ;
37
+ } ) ;
38
+
39
+ it ( "should return false for a string which is not a number" , ( ) => {
40
+ expect ( utils . isParallelValid ( "cypress" ) ) . to . be . equal ( false ) ;
41
+ expect ( utils . isParallelValid ( "browserstack" ) ) . to . be . equal ( false ) ;
42
+ } ) ;
43
+
44
+ it ( "should return false for any negative value less than -1 or zero" , ( ) => {
45
+ expect ( utils . isParallelValid ( - 200 ) ) . to . be . equal ( false ) ;
46
+ expect ( utils . isParallelValid ( "-200" ) ) . to . be . equal ( false ) ;
47
+ expect ( utils . isParallelValid ( - 1000 ) ) . to . be . equal ( false ) ;
48
+ expect ( utils . isParallelValid ( "0" ) ) . to . be . equal ( false ) ;
49
+ expect ( utils . isParallelValid ( 0 ) ) . to . be . equal ( false ) ;
50
+ } ) ;
51
+
52
+ it ( "should return true for any positive value or -1" , ( ) => {
53
+ expect ( utils . isParallelValid ( 5 ) ) . to . be . equal ( true ) ;
54
+ expect ( utils . isParallelValid ( "5" ) ) . to . be . equal ( true ) ;
55
+ expect ( utils . isParallelValid ( 10 ) ) . to . be . equal ( true ) ;
56
+ expect ( utils . isParallelValid ( "-1" ) ) . to . be . equal ( true ) ;
57
+ expect ( utils . isParallelValid ( - 1 ) ) . to . be . equal ( true ) ;
58
+ } ) ;
59
+
60
+ it ( "should return true for undefined" , ( ) => {
61
+ expect ( utils . isParallelValid ( undefined ) ) . to . be . equal ( true ) ;
62
+ } ) ;
63
+ } ) ;
64
+
65
+ describe ( "isFloat" , ( ) => {
66
+ it ( "should return true for a float value" , ( ) => {
67
+ expect ( utils . isFloat ( 1.2333 ) ) . to . be . equal ( true ) ;
68
+ expect ( utils . isFloat ( - 1.2333567 ) ) . to . be . equal ( true ) ;
69
+ expect ( utils . isFloat ( 0.123456 ) ) . to . be . equal ( true ) ;
70
+ } ) ;
71
+
72
+ it ( "should return false for a non float value" , ( ) => {
73
+ expect ( utils . isFloat ( 100 ) ) . to . be . equal ( false ) ;
74
+ expect ( utils . isFloat ( - 1000 ) ) . to . be . equal ( false ) ;
75
+ expect ( utils . isFloat ( 333 ) ) . to . be . equal ( false ) ;
76
+ } ) ;
77
+ } ) ;
78
+
79
+ describe ( "isUndefined" , ( ) => {
80
+ it ( "should return true for a undefined value" , ( ) => {
81
+ expect ( utils . isUndefined ( undefined ) ) . to . be . equal ( true ) ;
82
+ expect ( utils . isUndefined ( null ) ) . to . be . equal ( true ) ;
83
+ } ) ;
84
+
85
+ it ( "should return false for a defined value" , ( ) => {
86
+ expect ( utils . isUndefined ( 1.234 ) ) . to . be . equal ( false ) ;
87
+ expect ( utils . isUndefined ( "1.234" ) ) . to . be . equal ( false ) ;
88
+ expect ( utils . isUndefined ( 100 ) ) . to . be . equal ( false ) ;
89
+ expect ( utils . isUndefined ( - 1 ) ) . to . be . equal ( false ) ;
90
+ } ) ;
91
+ } ) ;
92
+
93
+ describe ( "setParallels" , ( ) => {
94
+ it ( "should set bsconfig parallels equal to value provided in args" , ( ) => {
95
+ let bsConfig = {
96
+ "run_settings" : {
97
+ "parallels" : 10 ,
98
+ }
99
+ } ;
100
+ utils . setParallels ( bsConfig , { parallels : 100 } ) ;
101
+ expect ( bsConfig [ 'run_settings' ] [ 'parallels' ] ) . to . be . eq ( 100 ) ;
102
+ } ) ;
103
+
104
+ it ( "should retain bsconfig parallels if args is undefined" , ( ) => {
105
+ let bsConfig = {
106
+ "run_settings" : {
107
+ "parallels" : 10 ,
108
+ }
109
+ } ;
110
+ utils . setParallels ( bsConfig , { parallels : undefined } ) ;
111
+ expect ( bsConfig [ 'run_settings' ] [ 'parallels' ] ) . to . be . eq ( 10 ) ;
112
+ } ) ;
113
+ } ) ;
114
+
30
115
describe ( "getErrorCodeFromErr" , ( ) => {
31
116
it ( "should return bstack_json_invalid_unknown if err.Code is not present in the list" , ( ) => {
32
117
expect ( utils . getErrorCodeFromErr ( "random_value" ) ) . to . be . eq ( "bstack_json_invalid_unknown" ) ;
0 commit comments