Skip to content

Commit

Permalink
feat(queries): RepositoryQuery
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Nov 13, 2023
1 parent 01fceab commit afd107e
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ component_management:
name: octokit
paths:
- src/subdomains/octokit/**/*.ts
- component_id: queries
name: queries
paths:
- src/queries/*.ts

coverage:
precision: 2
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,6 @@ jobs:
- id: pack
name: Pack project
run: yarn pack -o ${{ env.TARFILE }}
- id: typecheck
name: Run typecheck
run: yarn check:types:build
- id: archive
name: Archive production artifacts
uses: actions/[email protected]
Expand Down
13 changes: 9 additions & 4 deletions dist/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86884,8 +86884,8 @@ var manage_command_default = ManageLabelsCommand;
// src/subdomains/labels/queries/labels.handler.ts
var import_cqrs3 = __toESM(require_cqrs(), 1);

// src/subdomains/labels/queries/labels.query.ts
var LabelsQuery = class {
// src/queries/repository.query.ts
var RepositoryQuery = class {
/**
* Repository owner.
*
Expand All @@ -86903,15 +86903,20 @@ var LabelsQuery = class {
*/
repo;
/**
* Create a new repository labels query.
* Create a new repository query.
*
* @param {LabelsQuery} params - Query parameters
* @param {RepositoryQuery} params - Query parameters
*/
constructor(params) {
this.owner = params.owner;
this.repo = params.repo;
}
};
var repository_query_default = RepositoryQuery;

// src/subdomains/labels/queries/labels.query.ts
var LabelsQuery = class extends repository_query_default {
};
var labels_query_default = LabelsQuery;

// src/subdomains/labels/queries/labels.handler.ts
Expand Down
4 changes: 2 additions & 2 deletions dist/main.mjs.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
"exports": "./dist/main.mjs",
"scripts": {
"build": "mkbuild",
"check:ci": "yarn dedupe --check && yarn check:format && yarn check:lint && yarn check:spelling && yarn typecheck && yarn test:cov && yarn pack && yarn check:types:build && yarn clean:pack",
"check:ci": "yarn dedupe --check && yarn check:format && yarn check:lint && yarn check:spelling && yarn typecheck && yarn test:cov && yarn pack && yarn clean:pack",
"check:format": "dprint check --incremental=false",
"check:lint": "eslint --exit-on-fatal-error --max-warnings 0 .",
"check:spelling": "cspell lint --color --no-progress --relative $@ \"**\"",
"check:types": "tsc -p tsconfig.typecheck.json",
"check:types:build": "tsc -p tsconfig.build.json",
"check:upgrades": "yarn upgrade-interactive",
"clean:build": "trash ./{dist,*.tgz}",
"clean:coverage": "trash ./coverage",
Expand Down
16 changes: 16 additions & 0 deletions src/queries/__tests__/repository.query.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @file Type Tests - RepositoryQuery
* @module repostructure/queries/tests/unit-d/RepositoryQuery
*/

import type TestSubject from '../repository.query'

describe('unit-d:queries/RepositoryQuery', () => {
it('should match [owner: string]', () => {
expectTypeOf<TestSubject>().toHaveProperty('owner').toEqualTypeOf<string>()
})

it('should match [repo: string]', () => {
expectTypeOf<TestSubject>().toHaveProperty('repo').toEqualTypeOf<string>()
})
})
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @file Unit Tests - LabelsQuery
* @module repostructure/labels/queries/tests/unit/LabelsQuery
* @file Unit Tests - RepositoryQuery
* @module repostructure/queries/tests/unit/RepositoryQuery
*/

import OWNER from '#fixtures/owner.fixture'
import REPO from '#fixtures/repo.fixture'
import TestSubject from '../labels.query'
import TestSubject from '../repository.query'

describe('unit:labels/queries/LabelsQuery', () => {
describe('unit:queries/RepositoryQuery', () => {
describe('constructor', () => {
let subject: TestSubject

Expand Down
6 changes: 6 additions & 0 deletions src/queries/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @file Entry Point - Queries
* @module repostructure/queries
*/

export { default as RepositoryQuery } from './repository.query'
41 changes: 41 additions & 0 deletions src/queries/repository.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file Queries - RepositoryQuery
* @module repostructure/queries/RepositoryQuery
*/

/**
* Repository query.
*
* @class
*/
class RepositoryQuery {
/**
* Repository owner.
*
* @public
* @instance
* @member {string} owner
*/
public owner: string

/**
* Repository name.
*
* @public
* @instance
* @member {string} repo
*/
public repo: string

/**
* Create a new repository query.
*
* @param {RepositoryQuery} params - Query parameters
*/
constructor(params: RepositoryQuery) {
this.owner = params.owner
this.repo = params.repo
}
}

export default RepositoryQuery
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @file Functional Tests - LabelsQuery
* @module repostructure/labels/queries/tests/functional/LabelsQuery
*/

import OWNER from '#fixtures/owner.fixture'
import REPO from '#fixtures/repo.fixture'
import { RepositoryQuery } from '#src/queries'
import TestSubject from '../labels.query'

vi.mock('#src/queries/repository.query', () => ({ default: vi.fn() }))

describe('functional:labels/queries/LabelsQuery', () => {
describe('constructor', () => {
it('should extend RepositoryQuery', () => {
// Arrange
const params: Record<'owner' | 'repo', string> = {
owner: OWNER,
repo: REPO
}

// Act
new TestSubject(params)

// Expect
expect(RepositoryQuery).toHaveBeenCalledOnce()
expect(RepositoryQuery).toHaveBeenCalledWith(params)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
* @module repostructure/labels/queries/tests/unit-d/LabelsQuery
*/

import type { RepositoryQuery } from '#src/queries'
import type TestSubject from '../labels.query'

describe('unit-d:labels/queries/LabelsQuery', () => {
it('should match [owner: string]', () => {
expectTypeOf<TestSubject>().toHaveProperty('owner').toEqualTypeOf<string>()
})

it('should match [repo: string]', () => {
expectTypeOf<TestSubject>().toHaveProperty('repo').toEqualTypeOf<string>()
it('should extend RepositoryQuery', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<RepositoryQuery>()
})
})
35 changes: 6 additions & 29 deletions src/subdomains/labels/queries/labels.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,16 @@
* @module repostructure/labels/queries/LabelsQuery
*/

import { RepositoryQuery } from '#src/queries'

/**
* Repository labels query.
*
* @see {@linkcode RepositoryQuery}
*
* @class
* @extends {RepositoryQuery}
*/
class LabelsQuery {
/**
* Repository owner.
*
* @public
* @instance
* @member {string} owner
*/
public owner: string

/**
* Repository name.
*
* @public
* @instance
* @member {string} repo
*/
public repo: string

/**
* Create a new repository labels query.
*
* @param {LabelsQuery} params - Query parameters
*/
constructor(params: LabelsQuery) {
this.owner = params.owner
this.repo = params.repo
}
}
class LabelsQuery extends RepositoryQuery {}

export default LabelsQuery

0 comments on commit afd107e

Please sign in to comment.