@@ -153,100 +153,80 @@ describe('address', () => {
153
153
} ) ;
154
154
155
155
describe ( 'latitude()' , ( ) => {
156
- it ( 'returns random latitude' , ( ) => {
157
- for ( let i = 0 ; i < 100 ; i ++ ) {
158
- const latitude = faker . address . latitude ( ) ;
156
+ it ( 'returns a number' , ( ) => {
157
+ const latitude = faker . address . latitude ( ) ;
159
158
160
- expect ( latitude ) . toBeTypeOf ( 'string' ) ;
159
+ expect ( latitude ) . toBeTypeOf ( 'number' ) ;
160
+ } ) ;
161
161
162
- const latitude_float = parseFloat ( latitude ) ;
162
+ it ( 'returns random latitude' , ( ) => {
163
+ const latitude = faker . address . latitude ( ) ;
163
164
164
- expect ( latitude_float ) . toBeGreaterThanOrEqual ( - 90.0 ) ;
165
- expect ( latitude_float ) . toBeLessThanOrEqual ( 90.0 ) ;
166
- }
165
+ expect ( latitude ) . toBeGreaterThanOrEqual ( - 90.0 ) ;
166
+ expect ( latitude ) . toBeLessThanOrEqual ( 90.0 ) ;
167
167
} ) ;
168
168
169
169
it ( 'returns latitude with min and max and default precision' , ( ) => {
170
- for ( let i = 0 ; i < 100 ; i ++ ) {
171
- const latitude = faker . address . latitude ( 5 , - 5 ) ;
172
-
173
- expect ( latitude ) . toBeTypeOf ( 'string' ) ;
174
- expect (
175
- latitude . split ( '.' ) [ 1 ] . length ,
176
- 'The precision of latitude should be 4 digits'
177
- ) . toBe ( 4 ) ;
170
+ const latitude = faker . address . latitude ( 5 , - 5 ) ;
178
171
179
- const latitude_float = parseFloat ( latitude ) ;
172
+ expect (
173
+ latitude . toString ( ) . split ( '.' ) [ 1 ] . length ,
174
+ 'The precision of latitude should be 4 digits'
175
+ ) . lessThanOrEqual ( 4 ) ;
180
176
181
- expect ( latitude_float ) . toBeGreaterThanOrEqual ( - 5 ) ;
182
- expect ( latitude_float ) . toBeLessThanOrEqual ( 5 ) ;
183
- }
177
+ expect ( latitude ) . toBeGreaterThanOrEqual ( - 5 ) ;
178
+ expect ( latitude ) . toBeLessThanOrEqual ( 5 ) ;
184
179
} ) ;
185
180
186
181
it ( 'returns random latitude with custom precision' , ( ) => {
187
- for ( let i = 0 ; i < 100 ; i ++ ) {
188
- const latitude = faker . address . latitude ( undefined , undefined , 7 ) ;
189
-
190
- expect ( latitude ) . toBeTypeOf ( 'string' ) ;
191
- expect (
192
- latitude . split ( '.' ) [ 1 ] . length ,
193
- 'The precision of latitude should be 7 digits'
194
- ) . toBe ( 7 ) ;
182
+ const latitude = faker . address . latitude ( undefined , undefined , 7 ) ;
195
183
196
- const latitude_float = parseFloat ( latitude ) ;
184
+ expect (
185
+ latitude . toString ( ) . split ( '.' ) [ 1 ] . length ,
186
+ 'The precision of latitude should be 7 digits'
187
+ ) . lessThanOrEqual ( 7 ) ;
197
188
198
- expect ( latitude_float ) . toBeGreaterThanOrEqual ( - 180 ) ;
199
- expect ( latitude_float ) . toBeLessThanOrEqual ( 180 ) ;
200
- }
189
+ expect ( latitude ) . toBeGreaterThanOrEqual ( - 180 ) ;
190
+ expect ( latitude ) . toBeLessThanOrEqual ( 180 ) ;
201
191
} ) ;
202
192
} ) ;
203
193
204
194
describe ( 'longitude()' , ( ) => {
205
- it ( 'returns random longitude' , ( ) => {
206
- for ( let i = 0 ; i < 100 ; i ++ ) {
207
- const longitude = faker . address . longitude ( ) ;
195
+ it ( 'returns a number' , ( ) => {
196
+ const longitude = faker . address . longitude ( ) ;
208
197
209
- expect ( longitude ) . toBeTypeOf ( 'string' ) ;
198
+ expect ( longitude ) . toBeTypeOf ( 'number' ) ;
199
+ } ) ;
210
200
211
- const longitude_float = parseFloat ( longitude ) ;
201
+ it ( 'returns random longitude' , ( ) => {
202
+ const longitude = faker . address . longitude ( ) ;
212
203
213
- expect ( longitude_float ) . toBeGreaterThanOrEqual ( - 180 ) ;
214
- expect ( longitude_float ) . toBeLessThanOrEqual ( 180 ) ;
215
- }
204
+ expect ( longitude ) . toBeGreaterThanOrEqual ( - 180 ) ;
205
+ expect ( longitude ) . toBeLessThanOrEqual ( 180 ) ;
216
206
} ) ;
217
207
218
208
it ( 'returns random longitude with min and max and default precision' , ( ) => {
219
- for ( let i = 0 ; i < 100 ; i ++ ) {
220
- const longitude = faker . address . longitude ( 100 , - 30 ) ;
221
-
222
- expect ( longitude ) . toBeTypeOf ( 'string' ) ;
223
- expect (
224
- longitude . split ( '.' ) [ 1 ] . length ,
225
- 'The precision of longitude should be 4 digits'
226
- ) . toBe ( 4 ) ;
209
+ const longitude = faker . address . longitude ( 100 , - 30 ) ;
227
210
228
- const longitude_float = parseFloat ( longitude ) ;
211
+ expect (
212
+ longitude . toString ( ) . split ( '.' ) [ 1 ] . length ,
213
+ 'The precision of longitude should be 4 digits'
214
+ ) . lessThanOrEqual ( 4 ) ;
229
215
230
- expect ( longitude_float ) . toBeGreaterThanOrEqual ( - 30 ) ;
231
- expect ( longitude_float ) . toBeLessThanOrEqual ( 100 ) ;
232
- }
216
+ expect ( longitude ) . toBeGreaterThanOrEqual ( - 30 ) ;
217
+ expect ( longitude ) . toBeLessThanOrEqual ( 100 ) ;
233
218
} ) ;
234
219
235
220
it ( 'returns random longitude with custom precision' , ( ) => {
236
- for ( let i = 0 ; i < 100 ; i ++ ) {
237
- const longitude = faker . address . longitude ( undefined , undefined , 7 ) ;
238
-
239
- expect ( longitude ) . toBeTypeOf ( 'string' ) ;
240
- expect (
241
- longitude . split ( '.' ) [ 1 ] . length ,
242
- 'The precision of longitude should be 7 digits'
243
- ) . toBe ( 7 ) ;
221
+ const longitude = faker . address . longitude ( undefined , undefined , 7 ) ;
244
222
245
- const longitude_float = parseFloat ( longitude ) ;
223
+ expect (
224
+ longitude . toString ( ) . split ( '.' ) [ 1 ] . length ,
225
+ 'The precision of longitude should be 7 digits'
226
+ ) . lessThanOrEqual ( 7 ) ;
246
227
247
- expect ( longitude_float ) . toBeGreaterThanOrEqual ( - 180 ) ;
248
- expect ( longitude_float ) . toBeLessThanOrEqual ( 180 ) ;
249
- }
228
+ expect ( longitude ) . toBeGreaterThanOrEqual ( - 180 ) ;
229
+ expect ( longitude ) . toBeLessThanOrEqual ( 180 ) ;
250
230
} ) ;
251
231
} ) ;
252
232
0 commit comments