@@ -153,100 +153,80 @@ describe('address', () => {
153153 } ) ;
154154
155155 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 ( ) ;
159158
160- expect ( latitude ) . toBeTypeOf ( 'string' ) ;
159+ expect ( latitude ) . toBeTypeOf ( 'number' ) ;
160+ } ) ;
161161
162- const latitude_float = parseFloat ( latitude ) ;
162+ it ( 'returns random latitude' , ( ) => {
163+ const latitude = faker . address . latitude ( ) ;
163164
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 ) ;
167167 } ) ;
168168
169169 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 ) ;
178171
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 ) ;
180176
181- expect ( latitude_float ) . toBeGreaterThanOrEqual ( - 5 ) ;
182- expect ( latitude_float ) . toBeLessThanOrEqual ( 5 ) ;
183- }
177+ expect ( latitude ) . toBeGreaterThanOrEqual ( - 5 ) ;
178+ expect ( latitude ) . toBeLessThanOrEqual ( 5 ) ;
184179 } ) ;
185180
186181 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 ) ;
195183
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 ) ;
197188
198- expect ( latitude_float ) . toBeGreaterThanOrEqual ( - 180 ) ;
199- expect ( latitude_float ) . toBeLessThanOrEqual ( 180 ) ;
200- }
189+ expect ( latitude ) . toBeGreaterThanOrEqual ( - 180 ) ;
190+ expect ( latitude ) . toBeLessThanOrEqual ( 180 ) ;
201191 } ) ;
202192 } ) ;
203193
204194 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 ( ) ;
208197
209- expect ( longitude ) . toBeTypeOf ( 'string' ) ;
198+ expect ( longitude ) . toBeTypeOf ( 'number' ) ;
199+ } ) ;
210200
211- const longitude_float = parseFloat ( longitude ) ;
201+ it ( 'returns random longitude' , ( ) => {
202+ const longitude = faker . address . longitude ( ) ;
212203
213- expect ( longitude_float ) . toBeGreaterThanOrEqual ( - 180 ) ;
214- expect ( longitude_float ) . toBeLessThanOrEqual ( 180 ) ;
215- }
204+ expect ( longitude ) . toBeGreaterThanOrEqual ( - 180 ) ;
205+ expect ( longitude ) . toBeLessThanOrEqual ( 180 ) ;
216206 } ) ;
217207
218208 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 ) ;
227210
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 ) ;
229215
230- expect ( longitude_float ) . toBeGreaterThanOrEqual ( - 30 ) ;
231- expect ( longitude_float ) . toBeLessThanOrEqual ( 100 ) ;
232- }
216+ expect ( longitude ) . toBeGreaterThanOrEqual ( - 30 ) ;
217+ expect ( longitude ) . toBeLessThanOrEqual ( 100 ) ;
233218 } ) ;
234219
235220 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 ) ;
244222
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 ) ;
246227
247- expect ( longitude_float ) . toBeGreaterThanOrEqual ( - 180 ) ;
248- expect ( longitude_float ) . toBeLessThanOrEqual ( 180 ) ;
249- }
228+ expect ( longitude ) . toBeGreaterThanOrEqual ( - 180 ) ;
229+ expect ( longitude ) . toBeLessThanOrEqual ( 180 ) ;
250230 } ) ;
251231 } ) ;
252232
0 commit comments