Skip to content

Commit

Permalink
refactor(grease): CreateReleaseDTO#toString
Browse files Browse the repository at this point in the history
P010-33
  • Loading branch information
unicornware committed Sep 18, 2021
1 parent 70156cb commit 0347d26
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 226 deletions.
8 changes: 8 additions & 0 deletions packages/grease/__mocks__/lodash/join.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @file Node Module Mock - lodash/join
* @module grease/tests/mocks/lodash/join
* @see https://jestjs.io/docs/next/manual-mocks#mocking-node-modules
* @see https://github.com/lodash/lodash
*/

export default jest.fn((...args) => jest.requireActual('lodash/join')(...args))
8 changes: 8 additions & 0 deletions packages/grease/__mocks__/lodash/pick.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @file Node Module Mock - lodash/pick
* @module grease/tests/mocks/lodash/pick
* @see https://jestjs.io/docs/next/manual-mocks#mocking-node-modules
* @see https://github.com/lodash/lodash
*/

export default jest.fn((...args) => jest.requireActual('lodash/pick')(...args))
19 changes: 19 additions & 0 deletions packages/grease/__tests__/__fixtures__/CHANGELOG.fixture.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ for commit guidelines.
- **repo:** dtos, interfaces, types
([1d0c286](https://github.com/flex-development/mango/commit/1d0c28660da03a92509c21016c9f99ab2b73cf62))

### :pencil2: Housekeeping

- add `deps-peer` and `yarn` commit scopes
([21905de](https://github.com/flex-development/log/commit/21905def9c8569ad255759ee677fcbb6bd9a7ca2))
- run `yarn set version berry`
([4bcda50](https://github.com/flex-development/log/commit/4bcda50edbd75f013a6114edd7b9a6b5d6ff947e))
- **scripts:** add `check:dedupe`
([8ed8ce6](https://github.com/flex-development/log/commit/8ed8ce6a8fc510d3e8171812a26f9e2fc79dcb49))
- **scripts:** add `check:install`
([54304ea](https://github.com/flex-development/log/commit/54304eaa1e9284052a4296a6de79e9d2555641f0))
- **scripts:** add `clean:modules` and `clean:yarn`
([8f2b31e](https://github.com/flex-development/log/commit/8f2b31e6125494a9d8bec60f4b7f050315880a2d))
- update `lint-staged` config
([f875714](https://github.com/flex-development/log/commit/f87571445c8e1d5b3373b17fd2020641fec916d6))
- update environment variables
([d8e08d5](https://github.com/flex-development/log/commit/d8e08d509f10e32c129c6abf7bba876853b8883b))
- **yarn:** add `@yarnpkg/plugin-interactive-tools`
([aba5881](https://github.com/flex-development/log/commit/aba588102e332ca29dcd1383684b74a32992dda3))

## 1.0.0 (2021-05-22)

### :pencil2: Housekeeping
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ICreateReleaseDTO } from '@grease/interfaces'
import { VERSION } from './git-tags.fixture'
import NOTES from './notes.fixture'

/**
* @file Workspace Test Fixture - CreateReleaseDTO
* @module grease/tests/fixtures/CreateReleaseDTO
*/

export default {
draft: true,
files: ['./*.tgz', './README.md#My display label'],
notes: NOTES,
notesFile: undefined,
prerelease: false,
repo: 'flex-development/grease',
target: 'main',
title: undefined,
version: `v${VERSION}`
} as ICreateReleaseDTO
44 changes: 44 additions & 0 deletions packages/grease/__tests__/__fixtures__/notes.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @file Workspace Test Fixture - Release Notes
* @module grease/tests/fixtures/notes
*/

export default `## ⚠ BREAKING CHANGES
- **repo:** add MangoRepository
- **repo:** dtos, interfaces, types
## :hammer: Build
- **deps:** install repo api dependencies
([0c73e11](https://github.com/flex-development/mango/commit/0c73e11351468c6613560ea08d66d3c97a3ddee5))
## :sparkles: Features
- **decorators:** custom decorators
([32c3d47](https://github.com/flex-development/mango/commit/32c3d4767e7e8db90ca1a38381db55876cbfc2bc))
- **mixins:** add MangoValidator
([25a5df1](https://github.com/flex-development/mango/commit/25a5df10d69cc157b94215f2d794b61fb6a97b6c))
- **repo:** add MangoRepository
([00bf295](https://github.com/flex-development/mango/commit/00bf2958b8a68b81b97a1a695fa6f6d97ccef868))
- **repo:** dtos, interfaces, types
([1d0c286](https://github.com/flex-development/mango/commit/1d0c28660da03a92509c21016c9f99ab2b73cf62))
## :pencil2: Housekeeping
- add \`deps-peer\` and \`yarn\` commit scopes
([21905de](https://github.com/flex-development/log/commit/21905def9c8569ad255759ee677fcbb6bd9a7ca2))
- run \`yarn set version berry\`
([4bcda50](https://github.com/flex-development/log/commit/4bcda50edbd75f013a6114edd7b9a6b5d6ff947e))
- **scripts:** add \`check:dedupe\`
([8ed8ce6](https://github.com/flex-development/log/commit/8ed8ce6a8fc510d3e8171812a26f9e2fc79dcb49))
- **scripts:** add \`check:install\`
([54304ea](https://github.com/flex-development/log/commit/54304eaa1e9284052a4296a6de79e9d2555641f0))
- **scripts:** add \`clean:modules\` and \`clean:yarn\`
([8f2b31e](https://github.com/flex-development/log/commit/8f2b31e6125494a9d8bec60f4b7f050315880a2d))
- update \`lint-staged\` config
([f875714](https://github.com/flex-development/log/commit/f87571445c8e1d5b3373b17fd2020641fec916d6))
- update environment variables
([d8e08d5](https://github.com/flex-development/log/commit/d8e08d509f10e32c129c6abf7bba876853b8883b))
- **yarn:** add \`@yarnpkg/plugin-interactive-tools\`
([aba5881](https://github.com/flex-development/log/commit/aba588102e332ca29dcd1383684b74a32992dda3))`
8 changes: 7 additions & 1 deletion packages/grease/src/config/constants.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TVODefaults } from '@grease/types'
import type { SemanticVersion, TVODefaults } from '@grease/types'

/**
* @file Configuration - Constant Values
Expand Down Expand Up @@ -52,6 +52,12 @@ export const LINE_BREAK = '\n'
*/
export const RELEASE_PATTERN = /(^#+ \[?[0-9]+\.[0-9]+\.[0-9]+|<a name=)/gm

/**
* @property {SemanticVersion} DEFAULT_VERSION - Package version placeholder
* Forces NOT_FOUND Exception or ValidationException
*/
export const DEFAULT_VERSION = 'x.x.x' as unknown as SemanticVersion

/**
* @property {TVODefaults} TVO_DEFAULTS - `class-transformer-validator` options
* @see https://github.com/MichalLytek/class-transformer-validator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import DTO from '@grease/tests/fixtures/create-release-dto.fixture'
import join from 'lodash/join'
import pick from 'lodash/pick'
import TestSubject from '../create-release.dto'

/**
* @file Functional Tests - CreateReleaseDTO
* @module grease/dtos/tests/functional/CreateRelease
*/

const mockJoin = join as jest.MockedFunction<typeof join>
const mockPick = pick as jest.MockedFunction<typeof pick>

describe('functional:dtos/CreateReleaseDTO', () => {
describe('#constructor', () => {
it('should pick CreateReleaseDTO properties from data', () => {
// Arrange
const data = { ...DTO, foo: 'data!' }

// Act
new TestSubject(data)

// Expect
expect(mockPick).toBeCalledTimes(1)
expect(mockPick).toBeCalledWith(data, TestSubject.PROPS)
})
})

describe('#toString', () => {
const Subject = new TestSubject(DTO)
const spy_toStringArgs = jest.spyOn(Subject, 'toStringArgs')

beforeEach(() => {
Subject.toString()
})

it('should get string arguments', () => {
expect(spy_toStringArgs).toBeCalledTimes(1)
})

it('should join string arguments', () => {
expect(mockJoin).toBeCalledTimes(1)
expect(mockJoin).toBeCalledWith(Subject.toStringArgs(), ' ')
})
})
})
Loading

0 comments on commit 0347d26

Please sign in to comment.