Skip to content

Commit

Permalink
feat(errors): ERR_INVALID_URL_SCHEME
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Sep 8, 2024
1 parent ee4609f commit 9df7c77
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 233 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ This package exports the following identifiers:
- `ERR_INVALID_PACKAGE_CONFIG`
- `ERR_INVALID_PACKAGE_TARGET`
- `ERR_INVALID_RETURN_VALUE`
- `ERR_INVALID_URL_SCHEME`
- `ERR_INVALID_URL`
- `ERR_METHOD_NOT_IMPLEMENTED`
- `ERR_MISSING_OPTION`
Expand Down
3 changes: 2 additions & 1 deletion __tests__/utils/node-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const NODE_VERSIONS: SemanticVersion[] = [
'19.9.0',
'20.17.0',
'21.7.3',
'22.7.0'
'22.7.0',
'22.8.0'
]

export default NODE_VERSIONS
187 changes: 0 additions & 187 deletions loader.mjs

This file was deleted.

24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,33 @@
"files": [
"CHANGELOG.md",
"LICENSE.md",
"dist",
"src"
"README.md",
"dist"
],
"exports": {
".": "./dist/index.mjs",
".": {
"vitest": null,
"default": "./dist/index.mjs"
},
"./package.json": "./package.json"
},
"imports": {
"#format-message": {
"ts-node": "./src/internal/format-message.development.ts",
"development": "./dist/internal/format-message.development.mjs",
"production": "./dist/internal/format-message.mjs",
"default": "./dist/internal/format-message.mjs"
},
"#hide-stack-frames": "./dist/internal/hide-stack-frames.mjs",
"#k-is-node-error": "./dist/internal/k-is-node-error.mjs",
"#hide-stack-frames": {
"ts-node": "./src/internal/hide-stack-frames.ts",
"default": "./dist/internal/hide-stack-frames.mjs"
},
"#k-is-node-error": {
"ts-node": "./src/internal/k-is-node-error.ts",
"default": "./dist/internal/k-is-node-error.mjs"
},
"#stack-trace": {
"ts-node": "./src/internal/stack-trace.ts",
"browser": "./dist/internal/stack-trace.browser.mjs",
"node": "./dist/internal/stack-trace.mjs",
"default": "./dist/internal/stack-trace.mjs"
Expand Down Expand Up @@ -106,11 +117,8 @@
"@commitlint/types": "19.0.3",
"@eslint/js": "9.9.1",
"@flex-development/commitlint-config": "1.0.1",
"@flex-development/decorator-regex": "2.0.0",
"@flex-development/esm-types": "2.0.0",
"@flex-development/grease": "3.0.0-alpha.9",
"@flex-development/mkbuild": "1.0.0-alpha.23",
"@flex-development/mlly": "1.0.0-alpha.18",
"@flex-development/pathe": "2.0.0",
"@flex-development/pkg-types": "4.0.0",
"@stylistic/eslint-plugin": "2.7.2",
Expand Down
2 changes: 2 additions & 0 deletions src/__snapshots__/errors.integration.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ exports[`integration:errors > ERR_INVALID_RETURN_VALUE > #toString > should retu

exports[`integration:errors > ERR_INVALID_URL > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_URL]: Invalid URL`;

exports[`integration:errors > ERR_INVALID_URL_SCHEME > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file`;

exports[`integration:errors > ERR_METHOD_NOT_IMPLEMENTED > #toString > should return string representation of error 1`] = `Error [ERR_METHOD_NOT_IMPLEMENTED]: The _transform() method is not implemented`;

exports[`integration:errors > ERR_MISSING_OPTION > #toString > should return string representation of error 1`] = `TypeError [ERR_MISSING_OPTION]: init.highWaterMark is required`;
Expand Down
1 change: 1 addition & 0 deletions src/__snapshots__/index.e2e.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports[`e2e:errnode > should expose public api 1`] = `
"ERR_INVALID_PACKAGE_TARGET",
"ERR_INVALID_RETURN_VALUE",
"ERR_INVALID_URL",
"ERR_INVALID_URL_SCHEME",
"ERR_METHOD_NOT_IMPLEMENTED",
"ERR_MISSING_OPTION",
"ERR_MODULE_NOT_FOUND",
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/errors.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('integration:errors', () => {
],
[codes.ERR_INVALID_RETURN_VALUE, TypeError, 'null', 'body', 13],
[codes.ERR_INVALID_URL, TypeError, pathe.sep, 'http://[127.0.0.1]:8000'],
[codes.ERR_INVALID_URL_SCHEME, TypeError, 'file'],
[codes.ERR_METHOD_NOT_IMPLEMENTED, Error, '_transform()'],
[codes.ERR_MISSING_OPTION, TypeError, 'init.highWaterMark'],
[
Expand Down
5 changes: 5 additions & 0 deletions src/errors/__snapshots__/err-invalid-url-scheme.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`unit:errors/ERR_INVALID_URL_SCHEME > should build message from parameters (0) 1`] = `"The URL must be of scheme file"`;

exports[`unit:errors/ERR_INVALID_URL_SCHEME > should build message from parameters (1) 1`] = `"The URL must be one of scheme file or node"`;
36 changes: 36 additions & 0 deletions src/errors/__tests__/err-invalid-url-scheme.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @file Type Tests - ERR_INVALID_URL_SCHEME
* @module errnode/errors/tests/unit-d/ERR_INVALID_URL_SCHEME
*/

import { codes } from '#src/enums'
import type { NodeError, NodeErrorConstructor } from '#src/interfaces'
import type * as TestSubject from '../err-invalid-url-scheme'

describe('unit-d:errors/ERR_INVALID_URL_SCHEME', () => {
describe('ERR_INVALID_URL_SCHEME', () => {
it('should be ErrInvalidUrlSchemeConstructor', () => {
expectTypeOf<typeof TestSubject.default>()
.toEqualTypeOf<TestSubject.ErrInvalidUrlSchemeConstructor>()
})
})

describe('ErrInvalidUrlScheme', () => {
it('should extend NodeError<codes.ERR_INVALID_URL_SCHEME>', () => {
expectTypeOf<TestSubject.ErrInvalidUrlScheme>()
.toMatchTypeOf<NodeError<codes.ERR_INVALID_URL_SCHEME>>()
})
})

describe('ErrInvalidUrlSchemeConstructor', () => {
it('should match NodeErrorConstructor', () => {
// Arrange
type T = TestSubject.ErrInvalidUrlScheme
type Args = TestSubject.ErrInvalidUrlSchemeArgs

// Expect
expectTypeOf<TestSubject.ErrInvalidUrlSchemeConstructor>()
.toMatchTypeOf<NodeErrorConstructor<T, Args>>()
})
})
})
22 changes: 22 additions & 0 deletions src/errors/__tests__/err-invalid-url-scheme.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @file Unit Tests - ERR_INVALID_URL_SCHEME
* @module errnode/errors/tests/unit/ERR_INVALID_URL_SCHEME
*/

import TestSubject, {
type ErrInvalidUrlScheme
} from '../err-invalid-url-scheme'

describe('unit:errors/ERR_INVALID_URL_SCHEME', () => {
it.each<ConstructorParameters<typeof TestSubject>>([
['file'],
[['file', 'node']]
])('should build message from parameters (%#)', (...args) => {
// Act
const subject: ErrInvalidUrlScheme = new TestSubject(...args)

// Expect
expect(subject).to.have.property('message').be.a('string').that.is.not.empty
expect(subject.message).toMatchSnapshot()
})
})
Loading

0 comments on commit 9df7c77

Please sign in to comment.