From ec81ecde6fe28f2b09664bda6d0b5539e57fb25e Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Wed, 30 Nov 2022 22:32:21 -0500 Subject: [PATCH] feat(interfaces): `LicenseObject` Signed-off-by: Lexus Drumgold --- .../__tests__/license-object.spec-d.ts | 22 ++++++++++++++++++ src/interfaces/index.ts | 1 + src/interfaces/license-object.ts | 23 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/interfaces/__tests__/license-object.spec-d.ts create mode 100644 src/interfaces/license-object.ts diff --git a/src/interfaces/__tests__/license-object.spec-d.ts b/src/interfaces/__tests__/license-object.spec-d.ts new file mode 100644 index 00000000..ee72b54c --- /dev/null +++ b/src/interfaces/__tests__/license-object.spec-d.ts @@ -0,0 +1,22 @@ +/** + * @file Unit Tests - LicenseObject + * @module pkg-types/interfaces/tests/LicenseObject + */ + +import type TestSubject from '../license-object' + +describe('unit:interfaces/LicenseObject', () => { + const url: string = 'https://www.opensource.org/licenses/mit-license.php' + + it('should allow empty object', () => { + assertType({}) + }) + + it('should allow object that only has property "url"', () => { + assertType({ url }) + }) + + it('should allow object with all properties', () => { + assertType>({ type: 'MIT', url }) + }) +}) diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 7358c820..b6963112 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -7,5 +7,6 @@ export type { default as BugsObject } from './bugs-object' export type { default as DependencyMeta } from './dependency-meta' export type { default as FundingObject } from './funding-object' export type { default as InstallConfig } from './install-config' +export type { default as LicenseObject } from './license-object' export type { default as PeerDependencyMeta } from './peer-dependency-meta' export type { default as WorkspacesConfig } from './workspaces-config' diff --git a/src/interfaces/license-object.ts b/src/interfaces/license-object.ts new file mode 100644 index 00000000..e82e9701 --- /dev/null +++ b/src/interfaces/license-object.ts @@ -0,0 +1,23 @@ +/** + * @file Interfaces - LicenseObject + * @module pkg-types/interfaces/LicenseObject + */ + +/** + * Object representing a package license. + * + * @see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#license + */ +interface LicenseObject { + /** + * License type. + */ + type?: string + + /** + * License URL. + */ + url?: string +} + +export type { LicenseObject as default }