File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -137,11 +137,15 @@ export class Helpers {
137
137
* @example
138
138
* faker.helpers.randomize() // 'c'
139
139
* faker.helpers.randomize([1, 2, 3]) // '2'
140
+ *
141
+ * @deprecated
140
142
*/
141
- // TODO ST-DDT 2022-02-06: Mark as deprecated
142
143
randomize < T = string > (
143
144
array : ReadonlyArray < T > = [ 'a' , 'b' , 'c' ] as unknown as ReadonlyArray < T >
144
145
) : T {
146
+ console . warn (
147
+ 'Deprecation Warning: faker.helpers.randomize is now located in faker.random.arrayElement'
148
+ ) ;
145
149
return this . faker . random . arrayElement ( array ) ;
146
150
}
147
151
Original file line number Diff line number Diff line change @@ -764,6 +764,22 @@ describe('helpers', () => {
764
764
expect ( transaction . account ) . toBeTruthy ( ) ;
765
765
} ) ;
766
766
} ) ;
767
+
768
+ describe ( 'deprecation warnings' , ( ) => {
769
+ it . each ( [ [ 'randomize' , 'random.arrayElement' ] ] ) (
770
+ 'should warn user that function helpers.%s is deprecated' ,
771
+ ( functionName , newLocation ) => {
772
+ const spy = vi . spyOn ( console , 'warn' ) ;
773
+
774
+ faker . helpers [ functionName ] ( ) ;
775
+
776
+ expect ( spy ) . toHaveBeenCalledWith (
777
+ `Deprecation Warning: faker.helpers.${ functionName } is now located in faker.${ newLocation } `
778
+ ) ;
779
+ spy . mockRestore ( ) ;
780
+ }
781
+ ) ;
782
+ } ) ;
767
783
}
768
784
} ) ;
769
785
describe ( 'deprecation warnings' , ( ) => {
You can’t perform that action at this time.
0 commit comments