Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 80fffba

Browse files
chore: deps
1 parent 6a280d4 commit 80fffba

13 files changed

+57
-47
lines changed

eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import sharedConfig from '@naturalcycles/dev-lib/cfg/eslint.config.js'
33
export default [
44
...sharedConfig,
55
{
6-
rules: {
7-
'@typescript-eslint/consistent-type-imports': 2,
8-
},
6+
rules: {},
97
},
108
]

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"@naturalcycles/dev-lib": "^18",
4444
"@types/node": "^22",
4545
"@types/through2-concurrent": "^2",
46-
"@vitest/coverage-v8": "^3",
4746
"tsx": "^4",
4847
"vitest": "^3"
4948
},

src/security/crypto.util.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
const encKeyBuffer = Buffer.from(TEST_ENC_KEY, 'base64')
1414

1515
test('testEncKeySize', () => {
16-
expect(encKeyBuffer.length).toBe(256)
16+
expect(encKeyBuffer).toHaveLength(256)
1717
})
1818

1919
test('encryptBuffer, decryptBuffer', () => {

src/security/id.util.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const base64urlRegex = /^[a-zA-Z0-9-_]*$/
2222

2323
test('stringId', () => {
2424
const id = stringId()
25-
expect(id.length).toBe(16)
25+
expect(id).toHaveLength(16)
2626
expect(id.toLowerCase()).toBe(id)
2727

28-
expect(stringId(32).length).toBe(32)
28+
expect(stringId(32)).toHaveLength(32)
2929

3030
_range(100).forEach(() => {
3131
expect(stringId()).toMatch(stringIdRegex)
@@ -34,7 +34,7 @@ test('stringId', () => {
3434

3535
test('stringIdBase62', () => {
3636
const id = stringIdBase62()
37-
expect(id.length).toBe(16)
37+
expect(id).toHaveLength(16)
3838
expect(id).not.toContain('=')
3939
expect(id).not.toContain('-')
4040
expect(id).not.toContain('_')
@@ -51,18 +51,18 @@ test('stringIdBase62', () => {
5151

5252
test('stringIdBase64', () => {
5353
const id = stringIdBase64()
54-
expect(id.length).toBe(16) // default
54+
expect(id).toHaveLength(16) // default
5555

5656
const id2 = stringIdBase64Url()
57-
expect(id2.length).toBe(16) // default
57+
expect(id2).toHaveLength(16) // default
5858

5959
const lengths = [4, 8, 12, 16, 32]
6060

6161
lengths.forEach(len => {
6262
_range(100).forEach(() => {
6363
const id = stringIdBase64(len)
6464
// console.log(id, id.length)
65-
expect(id.length).toBe(len)
65+
expect(id).toHaveLength(len)
6666
expect(id).toMatch(base64regex)
6767
validate(id, base64Schema)
6868
if (len >= 8) {
@@ -71,7 +71,7 @@ test('stringIdBase64', () => {
7171

7272
const id2 = stringIdBase64Url(len)
7373
// console.log(id2, id2.length)
74-
expect(id2.length).toBe(len)
74+
expect(id2).toHaveLength(len)
7575
expect(id2).toMatch(base64urlRegex)
7676
validate(id2, base64UrlSchema)
7777

@@ -97,7 +97,7 @@ test('stringIdBase64Url should have no padding', () => {
9797
describe('stringIdNonAmbiguous', () => {
9898
test('default size', () => {
9999
const id = stringIdNonAmbiguous()
100-
expect(id.length).toBe(16)
100+
expect(id).toHaveLength(16)
101101
expect(id).not.toContain('0')
102102
expect(id).not.toContain('O')
103103
expect(id).not.toContain('I')
@@ -106,7 +106,7 @@ describe('stringIdNonAmbiguous', () => {
106106

107107
test('custom size', () => {
108108
const id = stringIdNonAmbiguous(100)
109-
expect(id.length).toBe(100)
109+
expect(id).toHaveLength(100)
110110
expect(id).not.toContain('0')
111111
expect(id).not.toContain('O')
112112
expect(id).not.toContain('1')

src/security/secret.util.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('secret', async () => {
4545
})
4646

4747
expect(secretOptional('N')).toBeUndefined()
48-
expect(() => secret('N')).toThrow()
48+
expect(() => secret('N')).toThrowErrorMatchingInlineSnapshot(`[Error: secret(N) not found!]`)
4949
expect(secret('SECRET_A')).toBe('VALUE A')
5050
expect(secret('secret_a')).toBe('VALUE A')
5151
expect(secret('seCrEt_a')).toBe('VALUE A')

src/string/inspect.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ test('_inspect maxLen', () => {
1414
})
1515

1616
function expectResults(fn: (...args: any[]) => any, values: any[]): Assertion {
17+
// eslint-disable-next-line vitest/valid-expect
1718
return expect(new Map(values.map(v => [v, fn(v)])))
1819
}

src/util/env.util.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import { requireEnvKeys, requireFileToExist } from '../index.js'
33
import { srcDir } from '../test/paths.cnst.js'
44

55
test('requireEnvKeys', () => {
6-
expect(() => requireEnvKeys('NON_EXISTING')).toThrow()
6+
expect(() => requireEnvKeys('NON_EXISTING')).toThrowErrorMatchingInlineSnapshot(
7+
`[Error: NON_EXISTING env variable is required, but missing]`,
8+
)
79

810
process.env['AAAA'] = 'aaaa'
911
expect(requireEnvKeys('AAAA')).toEqual({
1012
AAAA: 'aaaa',
1113
})
1214

1315
process.env['BBBB'] = '' // not allowed
14-
expect(() => requireEnvKeys('BBBB')).toThrow()
16+
expect(() => requireEnvKeys('BBBB')).toThrowErrorMatchingInlineSnapshot(
17+
`[Error: BBBB env variable is required, but missing]`,
18+
)
1519

1620
process.env['CCCC'] = 'cccc'
1721
expect(requireEnvKeys('AAAA', 'CCCC')).toEqual({
@@ -24,5 +28,5 @@ test('requireFileToExist', async () => {
2428
// should not throw
2529
requireFileToExist(`${srcDir}/util/env.util.ts`)
2630

27-
expect(() => requireFileToExist(`${srcDir}/util/non-existing`)).toThrow()
31+
expect(() => requireFileToExist(`${srcDir}/util/non-existing`)).toThrow(`should exist`)
2832
})

src/util/zip.util.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ test('deflate vs gzip length', async () => {
5454
// console.log(zipped)
5555
// console.log(gzipped)
5656
// console.log(zipped.length, gzipped.length)
57-
expect(zipped.length).toBe(9)
58-
expect(gzipped.length).toBe(21)
57+
expect(zipped).toHaveLength(9)
58+
expect(gzipped).toHaveLength(21)
5959

6060
const longString = 'a'.repeat(100_000)
6161
const zippedLong = await deflateString(longString)
6262
const gzippedLong = await gzipString(longString)
6363
// console.log(zippedLong)
6464
// console.log(gzippedLong)
6565
// console.log(zippedLong.length, gzippedLong.length)
66-
expect(zippedLong.length).toBe(121)
67-
expect(gzippedLong.length).toBe(133)
66+
expect(zippedLong).toHaveLength(121)
67+
expect(gzippedLong).toHaveLength(133)
6868
})

src/validation/joi/joi.shared.schemas.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
urlSchema,
2727
uuidSchema,
2828
} from './joi.shared.schemas.js'
29+
import { JoiValidationError } from './joi.validation.error.js'
2930
import { isValid, validate } from './joi.validation.util.js'
3031

3132
test('semVerSchema', () => {
@@ -40,10 +41,10 @@ test('urlSchema', () => {
4041
const schema = urlSchema()
4142
const schemaAllowHttp = urlSchema(['https', 'http'])
4243

43-
expect(() => validate('abc', schema)).toThrow()
44+
expect(() => validate('abc', schema)).toThrow(JoiValidationError)
4445

4546
validate('https://example.com', schema)
46-
expect(() => validate('http://example.com', schema)).toThrow()
47+
expect(() => validate('http://example.com', schema)).toThrow(JoiValidationError)
4748

4849
validate('https://example.com', schemaAllowHttp)
4950
validate('http://example.com', schemaAllowHttp)
@@ -206,7 +207,7 @@ describe('macAddressSchema', () => {
206207
]
207208

208209
test.each(nonMacAddresses)('invalid macAddressSchema: %s', s => {
209-
expect(() => validate(s, macAddressSchema)).toThrow()
210+
expect(() => validate(s, macAddressSchema)).toThrow(JoiValidationError)
210211
})
211212
})
212213

@@ -216,8 +217,12 @@ describe('uuidSchema', () => {
216217
})
217218

218219
test('invalid', () => {
219-
expect(() => validate('123e4567-e89b-12d3-a456-4266141740000', uuidSchema)).toThrow()
220-
expect(() => validate('123g4567-e89b-12d3-a456-426614174000', uuidSchema)).toThrow()
220+
expect(() => validate('123e4567-e89b-12d3-a456-4266141740000', uuidSchema)).toThrow(
221+
JoiValidationError,
222+
)
223+
expect(() => validate('123g4567-e89b-12d3-a456-426614174000', uuidSchema)).toThrow(
224+
JoiValidationError,
225+
)
221226
})
222227
})
223228

src/validation/joi/joi.validation.util.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test('should trim strings by default', async () => {
8080
const v2 = validate(v, obj1Schema)
8181

8282
expect(v2.a1).toBe('sdf')
83-
expect(v === v2).toBeFalsy() // object should be cloned
83+
expect(v === v2).toBe(false) // object should be cloned
8484
})
8585

8686
test('should strip unknown keys', async () => {
@@ -264,9 +264,9 @@ test('should convert null to undefined and strip', () => {
264264
expect(validate(undefined, numberSchema.optional())).toBeUndefined()
265265

266266
// null is invalid
267-
expect(isValid(null, numberSchema.optional())).toBeFalsy()
268-
expect(isValid(null, integerSchema.optional())).toBeFalsy()
269-
expect(isValid(null, arraySchema().optional())).toBeFalsy()
267+
expect(isValid(null, numberSchema.optional())).toBe(false)
268+
expect(isValid(null, integerSchema.optional())).toBe(false)
269+
expect(isValid(null, arraySchema().optional())).toBe(false)
270270

271271
// this is how to make null valid
272272
const numberPermissiveSchema = numberSchema.empty(null).optional()

0 commit comments

Comments
 (0)