-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
8db3a7e
commit 781362a
Showing
15 changed files
with
796 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
215 changes: 215 additions & 0 deletions
215
src/cli/commands/__tests__/changelog.command.functional.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
/** | ||
* @file Functional Tests - ChangelogCommand | ||
* @module grease/cli/commands/tests/functional/ChangelogCommand | ||
*/ | ||
|
||
import to from '#fixtures/git/grease/sha' | ||
import GreaseService from '#src/grease.service' | ||
import type { Mock } from '#tests/interfaces' | ||
import { CliUtilityService } from '@flex-development/nest-commander' | ||
import { CommandTestFactory } from '@flex-development/nest-commander/testing' | ||
import type { TestingModule } from '@nestjs/testing' | ||
import TestSubject from '../changelog.command' | ||
|
||
describe('functional:cli/commands/ChangelogCommand', () => { | ||
let args: ['changelog'] | ||
let changelog: Mock<GreaseService['changelog']> | ||
let command: TestingModule | ||
|
||
beforeAll(() => { | ||
args = ['changelog'] | ||
}) | ||
|
||
beforeEach(async () => { | ||
command = await CommandTestFactory.createTestingCommand({ | ||
providers: [ | ||
CliUtilityService, | ||
TestSubject, | ||
{ | ||
provide: GreaseService, | ||
useValue: { | ||
changelog: changelog = vi.fn().mockName('GreaseService#changelog') | ||
} | ||
} | ||
] | ||
}) | ||
|
||
vi.stubEnv('GREASE_CONFIG', '0') | ||
}) | ||
|
||
describe('--infile, -i <path>', () => { | ||
let infile: string | ||
|
||
beforeAll(() => { | ||
infile = 'CHANGELOG.md' | ||
}) | ||
|
||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, `--infile=${infile}`]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ infile }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-i', infile]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ infile }) | ||
}) | ||
}) | ||
|
||
describe('--outfile, -o <outfile>', () => { | ||
let outfile: string | ||
|
||
beforeAll(() => { | ||
outfile = 'CHANGELOG.md' | ||
}) | ||
|
||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, `--outfile=${outfile}`]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ outfile }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-o', outfile]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ outfile }) | ||
}) | ||
}) | ||
|
||
describe('--releases, -r <count>', () => { | ||
let releases: number | ||
|
||
beforeAll(() => { | ||
releases = 0 | ||
}) | ||
|
||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, `--releases=${releases}`]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ releases }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-r', `${releases}`]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ releases }) | ||
}) | ||
}) | ||
|
||
describe('--samefile, -s', () => { | ||
let samefile: boolean | ||
|
||
beforeAll(() => { | ||
samefile = true | ||
}) | ||
|
||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '--samefile']) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ samefile }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-s']) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ samefile }) | ||
}) | ||
}) | ||
|
||
describe('--to, -t <commitish>', () => { | ||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, `--to=${to}`]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ to }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-t', to]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ to }) | ||
}) | ||
}) | ||
|
||
describe('--unstable, -u [choice]', () => { | ||
let unstable: boolean | ||
|
||
beforeAll(() => { | ||
unstable = false | ||
}) | ||
|
||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, `--unstable=${unstable}`]) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ unstable }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-u', '0']) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ unstable }) | ||
}) | ||
}) | ||
|
||
describe('--write, -w', () => { | ||
let write: boolean | ||
|
||
beforeAll(() => { | ||
write = true | ||
}) | ||
|
||
it('should parse flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '--write']) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ write }) | ||
}) | ||
|
||
it('should parse short flag', async () => { | ||
// Act | ||
await CommandTestFactory.run(command, [...args, '-w']) | ||
|
||
// Expect | ||
expect(changelog).toHaveBeenCalledOnce() | ||
expect(changelog.mock.lastCall?.[0]).toMatchObject({ write }) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @file Commands - ChangelogCommandOpts | ||
* @module grease/commands/ChangelogCommandOpts | ||
*/ | ||
|
||
import type { ChangelogOperation } from '#src/changelog' | ||
|
||
/** | ||
* Parsed `changelog` command options. | ||
* | ||
* @see {@linkcode ChangelogOperation} | ||
* | ||
* @extends {ChangelogOperation} | ||
*/ | ||
interface ChangelogCommandOpts extends ChangelogOperation {} | ||
|
||
export type { ChangelogCommandOpts as default } |
Oops, something went wrong.