aboutsummaryrefslogtreecommitdiff
path: root/test/modules
diff options
context:
space:
mode:
authorMatt Mayer <[email protected]>2023-08-10 18:37:17 +0100
committerGitHub <[email protected]>2023-08-10 19:37:17 +0200
commit0ca1e442d6a882677fc73012fc481d48ca1905a5 (patch)
tree84b2ca509e5a126cd0e7c033fc1fc5f14a8f8f08 /test/modules
parent7f0daf3ddaa8956dc393964362eb696e23dc57d6 (diff)
downloadfaker-0ca1e442d6a882677fc73012fc481d48ca1905a5.tar.xz
faker-0ca1e442d6a882677fc73012fc481d48ca1905a5.zip
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 <[email protected]>
Diffstat (limited to 'test/modules')
-rw-r--r--test/modules/location.spec.ts5
1 files changed, 5 insertions, 0 deletions
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(