From 0ca1e442d6a882677fc73012fc481d48ca1905a5 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:37:17 +0100 Subject: fix(location): Pad en_US ZIP codes left to 5 characters if needed (#2278) * fix(location): Pad en_US ZIP codes left to 5 characters if needed * fix NJ and RI * fix PR * updated postcode_by_state to use string patterns --------- Co-authored-by: DivisionByZero --- test/modules/location.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/modules') diff --git a/test/modules/location.spec.ts b/test/modules/location.spec.ts index d9ce9c7f..bd50c8ef 100644 --- a/test/modules/location.spec.ts +++ b/test/modules/location.spec.ts @@ -192,6 +192,11 @@ describe('location', () => { expect(zipCode1).toBeLessThanOrEqual(upper); }); + it('should return a zip code with length 5 for ZIP codes that start with 0', () => { + const zipCode = fakerEN_US.location.zipCode({ state: 'NH' }); + expect(zipCode.length).toBe(5); + }); + it('should throw when definitions.location.postcode_by_state not set', () => { expect(() => faker.location.zipCode({ state: 'XX' })).toThrow( new FakerError( -- cgit v1.2.3