diff options
| author | ST-DDT <[email protected]> | 2023-10-07 11:05:58 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-07 09:05:58 +0000 |
| commit | eb2b18b8a0e64eded3731bae4204d2925dbef3e7 (patch) | |
| tree | 0ace6e551d0a75fae07e6acef448b48691589cdc /test | |
| parent | c80c035333e3c832c46dc7dcac5c86a289829e0d (diff) | |
| download | faker-eb2b18b8a0e64eded3731bae4204d2925dbef3e7.tar.xz faker-eb2b18b8a0e64eded3731bae4204d2925dbef3e7.zip | |
infra(eslint): enable no-useless-escape eslint rule (#2434)
Diffstat (limited to 'test')
| -rw-r--r-- | test/modules/commerce.spec.ts | 2 | ||||
| -rw-r--r-- | test/modules/finance.spec.ts | 6 | ||||
| -rw-r--r-- | test/modules/helpers.spec.ts | 22 | ||||
| -rw-r--r-- | test/modules/image.spec.ts | 8 | ||||
| -rw-r--r-- | test/modules/internet.spec.ts | 2 | ||||
| -rw-r--r-- | test/scripts/apidoc/verify-jsdoc-tags.spec.ts | 2 |
6 files changed, 20 insertions, 22 deletions
diff --git a/test/modules/commerce.spec.ts b/test/modules/commerce.spec.ts index 0588e228..6ccc18f7 100644 --- a/test/modules/commerce.spec.ts +++ b/test/modules/commerce.spec.ts @@ -110,7 +110,7 @@ describe('commerce', () => { expect( amount, 'The expected match should not include a currency symbol' - ).toMatch(/^[0-9\.]+$/); + ).toMatch(/^[0-9.]+$/); }); it('should handle negative amounts, but return 0', () => { diff --git a/test/modules/finance.spec.ts b/test/modules/finance.spec.ts index 97bcdcc7..a0cfbb2e 100644 --- a/test/modules/finance.spec.ts +++ b/test/modules/finance.spec.ts @@ -279,7 +279,7 @@ describe('finance', () => { expect( amount, 'The expected match should not include a currency symbol' - ).toMatch(/^[0-9\.]+$/); + ).toMatch(/^[0-9.]+$/); }); it('should handle negative amounts', () => { @@ -456,7 +456,7 @@ describe('finance', () => { it('should return a correct credit card number when issuer provided', () => { //TODO: implement checks for each format with regexp const visa = faker.finance.creditCardNumber('visa'); - expect(visa).toMatch(/^4(([0-9]){12}|([0-9]){3}(\-([0-9]){4}){3})$/); + expect(visa).toMatch(/^4(([0-9]){12}|([0-9]){3}(-([0-9]){4}){3})$/); expect(visa).toSatisfy(luhnCheck); const mastercard = faker.finance.creditCardNumber('mastercard'); @@ -490,7 +490,7 @@ describe('finance', () => { it('should return custom formatted strings', () => { let number = faker.finance.creditCardNumber('###-###-##L'); - expect(number).toMatch(/^\d{3}\-\d{3}\-\d{3}$/); + expect(number).toMatch(/^\d{3}-\d{3}-\d{3}$/); expect(number).toSatisfy(luhnCheck); number = faker.finance.creditCardNumber('234[5-9]#{999}L'); diff --git a/test/modules/helpers.spec.ts b/test/modules/helpers.spec.ts index df8f00e7..47131376 100644 --- a/test/modules/helpers.spec.ts +++ b/test/modules/helpers.spec.ts @@ -563,7 +563,7 @@ describe('helpers', () => { '6453-####-####-####-###L' ); expect(number).toMatch( - /^6453\-([0-9]){4}\-([0-9]){4}\-([0-9]){4}\-([0-9]){4}$/ + /^6453-([0-9]){4}-([0-9]){4}-([0-9]){4}-([0-9]){4}$/ ); expect(number).toSatisfy(luhnCheck); }); @@ -574,7 +574,7 @@ describe('helpers', () => { '*' ); expect(number).toMatch( - /^6453\-([0-9]){4}\-([0-9]){4}\-([0-9]){4}\-([0-9]){4}$/ + /^6453-([0-9]){4}-([0-9]){4}-([0-9]){4}-([0-9]){4}$/ ); expect(number).toSatisfy(luhnCheck); }); @@ -585,14 +585,14 @@ describe('helpers', () => { '*' ); expect(number).toMatch( - /^6453\-([0-9]){4}\-([0-9]){4}\-([0-9]){4}\-([0-9]){4}$/ + /^6453-([0-9]){4}-([0-9]){4}-([0-9]){4}-([0-9]){4}$/ ); expect(number).toSatisfy(luhnCheck); number = faker.helpers.replaceCreditCardSymbols( '645[5-9]-#{4,6}-#{1,2}-#{4,6}-#{3}L' ); expect(number).toMatch( - /^645[5-9]\-([0-9]){4,6}\-([0-9]){1,2}\-([0-9]){4,6}\-([0-9]){4}$/ + /^645[5-9]-([0-9]){4,6}-([0-9]){1,2}-([0-9]){4,6}-([0-9]){4}$/ ); expect(number).toSatisfy(luhnCheck); }); @@ -607,14 +607,14 @@ describe('helpers', () => { const string = faker.helpers.regexpStyleStringParse('#{5,10}'); expect(string.length).toBeLessThanOrEqual(10); expect(string.length).toBeGreaterThanOrEqual(5); - expect(string).toMatch(/^\#{5,10}$/); + expect(string).toMatch(/^#{5,10}$/); }); it('flips the range when min > max', () => { const string = faker.helpers.regexpStyleStringParse('#{10,5}'); expect(string.length).toBeLessThanOrEqual(10); expect(string.length).toBeGreaterThanOrEqual(5); - expect(string).toMatch(/^\#{5,10}$/); + expect(string).toMatch(/^#{5,10}$/); }); it('repeats string {n} number of times', () => { @@ -638,9 +638,7 @@ describe('helpers', () => { const string = faker.helpers.regexpStyleStringParse( 'Test#{5}%{2,5}Testing**[1-5]**{10}END' ); - expect(string).toMatch( - /^Test\#{5}%{2,5}Testing\*\*[1-5]\*\*{10}END$/ - ); + expect(string).toMatch(/^Test#{5}%{2,5}Testing\*\*[1-5]\*\*{10}END$/); }); }); @@ -649,7 +647,7 @@ describe('helpers', () => { const string = faker.helpers.fromRegExp(/#{5,10}/); expect(string.length).toBeLessThanOrEqual(10); expect(string.length).toBeGreaterThanOrEqual(5); - expect(string).toMatch(/^\#{5,10}$/); + expect(string).toMatch(/^#{5,10}$/); }); it('repeats string {n} number of times', () => { @@ -667,7 +665,7 @@ describe('helpers', () => { const string = faker.helpers.fromRegExp( 'Test#{5}%{2,5}Testing*[1-5]{10}END' ); - expect(string).toMatch(/^Test\#{5}%{2,5}Testing*[1-5]{10}END$/); + expect(string).toMatch(/^Test#{5}%{2,5}Testing*[1-5]{10}END$/); }); it('throws error when min > max outside set', () => { @@ -1176,7 +1174,7 @@ describe('helpers', () => { 'lName', 'domain', ]); // third argument is provider, or domain for email - expect(result).toMatch(/\@domain/); + expect(result).toMatch(/@domain/); }); it('should be possible to limit unique call by maxTime in ms', () => { diff --git a/test/modules/image.spec.ts b/test/modules/image.spec.ts index d77b854d..d2c0152f 100644 --- a/test/modules/image.spec.ts +++ b/test/modules/image.spec.ts @@ -410,7 +410,7 @@ describe('image', () => { expect(avatarUrl).toBeTypeOf('string'); expect(avatarUrl).toMatch( - /^https:\/\/cloudflare\-ipfs\.com\/ipfs\/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye\/avatar\/\d{1,4}\.jpg$/ + /^https:\/\/cloudflare-ipfs\.com\/ipfs\/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye\/avatar\/\d{1,4}\.jpg$/ ); }); }); @@ -463,7 +463,7 @@ describe('image', () => { expect(imageUrl).toBeTypeOf('string'); expect(imageUrl).toMatch( - /^https\:\/\/loremflickr\.com\/\d+\/\d+\?lock=\d+$/ + /^https:\/\/loremflickr\.com\/\d+\/\d+\?lock=\d+$/ ); }); }); @@ -474,7 +474,7 @@ describe('image', () => { expect(imageUrl).toBeTypeOf('string'); expect(imageUrl).toMatch( - /^https\:\/\/picsum\.photos\/seed\/[0-9a-zA-Z]+\/\d+\/\d+$/ + /^https:\/\/picsum\.photos\/seed\/[0-9a-zA-Z]+\/\d+\/\d+$/ ); }); }); @@ -485,7 +485,7 @@ describe('image', () => { expect(imageUrl).toBeTypeOf('string'); expect(imageUrl).toMatch( - /^https\:\/\/via\.placeholder\.com\/\d+x\d+\/[0-9a-fA-F]{6}\/[0-9a-fA-F]{6}\.[a-z]{3,4}\?text=.+$/ + /^https:\/\/via\.placeholder\.com\/\d+x\d+\/[0-9a-fA-F]{6}\/[0-9a-fA-F]{6}\.[a-z]{3,4}\?text=.+$/ ); }); }); diff --git a/test/modules/internet.spec.ts b/test/modules/internet.spec.ts index 8ed65bc0..79d329de 100644 --- a/test/modules/internet.spec.ts +++ b/test/modules/internet.spec.ts @@ -649,7 +649,7 @@ describe('internet', () => { expect(ua).toBeTypeOf('string'); expect(ua.length).toBeGreaterThanOrEqual(1); expect(ua).toMatch( - /^(([^\d]+\/[\dA-Za-z\.]+(\s\(.*\)))|([^\d]+\/[\dA-Za-z\.]+(\s\(.*\)*))(\s[^\d]+\/[\dA-Za-z\.]+(\s\(.*\)*))*)$/ + /^(([^\d]+\/[\dA-Za-z.]+(\s\(.*\)))|([^\d]+\/[\dA-Za-z.]+(\s\(.*\)*))(\s[^\d]+\/[\dA-Za-z.]+(\s\(.*\)*))*)$/ ); }); }); diff --git a/test/scripts/apidoc/verify-jsdoc-tags.spec.ts b/test/scripts/apidoc/verify-jsdoc-tags.spec.ts index 586605a6..5b8f5680 100644 --- a/test/scripts/apidoc/verify-jsdoc-tags.spec.ts +++ b/test/scripts/apidoc/verify-jsdoc-tags.spec.ts @@ -118,7 +118,7 @@ describe('verify JSDoc tags', () => { const path = resolvePathToMethodFile(moduleName, methodName); const imports = [ - ...new Set(examples.match(/(?<!\.)faker[^\.]*(?=\.)/g)), + ...new Set(examples.match(/(?<!\.)faker[^.]*(?=\.)/g)), ]; writeFileSync( path, |
