@@ -3,6 +3,7 @@ import logger from '../src/logger';
33
44jest . mock ( '../src/logger' , ( ) => ( {
55 warn : jest . fn ( ) ,
6+ info : jest . fn ( ) ,
67} ) ) ;
78
89describe ( 'utils' , ( ) => {
@@ -70,4 +71,118 @@ describe('utils', () => {
7071 expect ( logger . warn ) . not . toHaveBeenCalled ( ) ;
7172 } ) ;
7273 } ) ;
74+
75+ describe ( 'isWildcardDevice' , ( ) => {
76+ it ( 'should return true for undefined device' , ( ) => {
77+ expect ( utils . isWildcardDevice ( undefined ) ) . toBe ( true ) ;
78+ } ) ;
79+
80+ it ( 'should return true for wildcard "*"' , ( ) => {
81+ expect ( utils . isWildcardDevice ( '*' ) ) . toBe ( true ) ;
82+ } ) ;
83+
84+ it ( 'should return true for patterns containing "*"' , ( ) => {
85+ expect ( utils . isWildcardDevice ( 'Pixel*' ) ) . toBe ( true ) ;
86+ expect ( utils . isWildcardDevice ( 'Pixel 9*' ) ) . toBe ( true ) ;
87+ expect ( utils . isWildcardDevice ( '*Pro' ) ) . toBe ( true ) ;
88+ } ) ;
89+
90+ it ( 'should return true for patterns containing ".*"' , ( ) => {
91+ expect ( utils . isWildcardDevice ( 'Pixel.*' ) ) . toBe ( true ) ;
92+ expect ( utils . isWildcardDevice ( 'iPhone.*Pro' ) ) . toBe ( true ) ;
93+ } ) ;
94+
95+ it ( 'should return true for patterns containing "?"' , ( ) => {
96+ expect ( utils . isWildcardDevice ( 'Pixel ?' ) ) . toBe ( true ) ;
97+ expect ( utils . isWildcardDevice ( 'iPhone 1?' ) ) . toBe ( true ) ;
98+ } ) ;
99+
100+ it ( 'should return false for specific device names' , ( ) => {
101+ expect ( utils . isWildcardDevice ( 'Pixel 9 Pro' ) ) . toBe ( false ) ;
102+ expect ( utils . isWildcardDevice ( 'iPhone 15' ) ) . toBe ( false ) ;
103+ expect ( utils . isWildcardDevice ( 'Samsung Galaxy S24' ) ) . toBe ( false ) ;
104+ } ) ;
105+ } ) ;
106+
107+ describe ( 'isWildcardVersion' , ( ) => {
108+ it ( 'should return true for undefined version' , ( ) => {
109+ expect ( utils . isWildcardVersion ( undefined ) ) . toBe ( true ) ;
110+ } ) ;
111+
112+ it ( 'should return true for wildcard "*"' , ( ) => {
113+ expect ( utils . isWildcardVersion ( '*' ) ) . toBe ( true ) ;
114+ } ) ;
115+
116+ it ( 'should return true for patterns containing "*"' , ( ) => {
117+ expect ( utils . isWildcardVersion ( '15*' ) ) . toBe ( true ) ;
118+ expect ( utils . isWildcardVersion ( '15.*' ) ) . toBe ( true ) ;
119+ } ) ;
120+
121+ it ( 'should return true for patterns containing "?"' , ( ) => {
122+ expect ( utils . isWildcardVersion ( '15.?' ) ) . toBe ( true ) ;
123+ } ) ;
124+
125+ it ( 'should return false for specific versions' , ( ) => {
126+ expect ( utils . isWildcardVersion ( '15' ) ) . toBe ( false ) ;
127+ expect ( utils . isWildcardVersion ( '15.0' ) ) . toBe ( false ) ;
128+ expect ( utils . isWildcardVersion ( '15.0.1' ) ) . toBe ( false ) ;
129+ } ) ;
130+ } ) ;
131+
132+ describe ( 'showRealDeviceFlowsInfo' , ( ) => {
133+ beforeEach ( ( ) => {
134+ jest . clearAllMocks ( ) ;
135+ } ) ;
136+
137+ it ( 'should not show info when not using real device' , ( ) => {
138+ utils . showRealDeviceFlowsInfo ( {
139+ realDevice : false ,
140+ device : 'Pixel 9 Pro' ,
141+ flowCount : 5 ,
142+ } ) ;
143+ expect ( logger . info ) . not . toHaveBeenCalled ( ) ;
144+ } ) ;
145+
146+ it ( 'should not show info when device is a wildcard' , ( ) => {
147+ utils . showRealDeviceFlowsInfo ( {
148+ realDevice : true ,
149+ device : '*' ,
150+ flowCount : 5 ,
151+ } ) ;
152+ expect ( logger . info ) . not . toHaveBeenCalled ( ) ;
153+
154+ utils . showRealDeviceFlowsInfo ( {
155+ realDevice : true ,
156+ device : 'Pixel.*' ,
157+ flowCount : 5 ,
158+ } ) ;
159+ expect ( logger . info ) . not . toHaveBeenCalled ( ) ;
160+ } ) ;
161+
162+ it ( 'should not show info when flow count is 2 or less' , ( ) => {
163+ utils . showRealDeviceFlowsInfo ( {
164+ realDevice : true ,
165+ device : 'Pixel 9 Pro' ,
166+ flowCount : 2 ,
167+ } ) ;
168+ expect ( logger . info ) . not . toHaveBeenCalled ( ) ;
169+
170+ utils . showRealDeviceFlowsInfo ( {
171+ realDevice : true ,
172+ device : 'Pixel 9 Pro' ,
173+ flowCount : 1 ,
174+ } ) ;
175+ expect ( logger . info ) . not . toHaveBeenCalled ( ) ;
176+ } ) ;
177+
178+ it ( 'should not show info when shardSplit is specified' , ( ) => {
179+ utils . showRealDeviceFlowsInfo ( {
180+ realDevice : true ,
181+ device : 'Pixel 9 Pro' ,
182+ flowCount : 5 ,
183+ shardSplit : 2 ,
184+ } ) ;
185+ expect ( logger . info ) . not . toHaveBeenCalled ( ) ;
186+ } ) ;
187+ } ) ;
73188} ) ;
0 commit comments