Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deps #178

Merged
merged 5 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/artisan",
"version": "4.27.0",
"version": "4.28.0",
"description": "The Athenna CLI application. Built on top of commander and inspired in @adonisjs/ace.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down Expand Up @@ -76,13 +76,13 @@
"ora": "^6.3.1"
},
"devDependencies": {
"@athenna/common": "^4.26.0",
"@athenna/config": "^4.11.0",
"@athenna/ioc": "^4.12.0",
"@athenna/logger": "^4.13.0",
"@athenna/test": "^4.17.0",
"@athenna/common": "^4.27.0",
"@athenna/config": "^4.12.0",
"@athenna/ioc": "^4.13.0",
"@athenna/logger": "^4.14.0",
"@athenna/test": "^4.18.0",
"@athenna/tsconfig": "^4.12.0",
"@athenna/view": "^4.10.0",
"@athenna/view": "^4.11.0",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"commitizen": "^4.2.6",
Expand Down
5 changes: 2 additions & 3 deletions tests/helpers/BaseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import { File, Folder, Path } from '@athenna/common'
import { TestCommand } from '#src/testing/plugins/index'
import { ArtisanProvider, CommanderHandler } from '#src'
import { AfterEach, BeforeEach, Mock } from '@athenna/test'
import { FixtureDatabase } from '#tests/fixtures/FixtureDatabase'
import { AfterEach, BeforeEach, Mock, type Stub } from '@athenna/test'

export class BaseTest {
public processExitMock: Stub
public originalPJson = new File(Path.pwd('package.json')).getContentAsStringSync()

@BeforeEach()
Expand All @@ -23,7 +22,7 @@ export class BaseTest {

TestCommand.setArtisanPath(Path.fixtures('consoles/base-command.ts'))

this.processExitMock = Mock.when(process, 'exit').return(undefined)
Mock.when(process, 'exit').return(undefined)
}

@AfterEach()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/artisan/ArtisanTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class ArtisanTest extends BaseTest {
await Artisan.parse(['node', 'artisan', 'hello', 'world', '--hello=world'])

assert.calledWith(fakeFire, ['hello', 'world'])
assert.calledWith(this.processExitMock, 0)
assert.calledWith(process.exit, 0)
}

@Test()
Expand Down Expand Up @@ -137,7 +137,7 @@ export default class ArtisanTest extends BaseTest {
await Artisan.call('simple', { withSettings: true })

assert.isTrue(FixtureDatabase.has('simple:command'))
assert.calledWith(this.processExitMock, 0)
assert.calledWith(process.exit, 0)
}

@Test()
Expand Down
14 changes: 6 additions & 8 deletions tests/unit/handlers/ConsoleExceptionHandlerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
import { Exception } from '@athenna/common'
import { ConsoleExceptionHandler } from '#src'
import { Log, LoggerProvider } from '@athenna/logger'
import { Test, Mock, AfterEach, BeforeEach, type Context, type Stub } from '@athenna/test'
import { Test, Mock, AfterEach, BeforeEach, type Context } from '@athenna/test'

export default class ConsoleExceptionHandlerTest {
public processExitMock: Stub

@BeforeEach()
public beforeEach() {
new LoggerProvider().register()
this.processExitMock = Mock.when(process, 'exit').return(1)
Mock.when(process, 'exit').return(1)
}

@AfterEach()
Expand All @@ -38,7 +36,7 @@ export default class ConsoleExceptionHandlerTest {

await new ConsoleExceptionHandler().handle(error)

assert.calledWith(this.processExitMock, 1)
assert.calledWith(process.exit, 1)
assert.calledWith(errorFake, await error.toAthennaException().prettify())
}

Expand All @@ -52,7 +50,7 @@ export default class ConsoleExceptionHandlerTest {

await new ConsoleExceptionHandler().handle(exception)

assert.calledWith(this.processExitMock, 1)
assert.calledWith(process.exit, 1)
assert.calledWith(errorFake, await exception.prettify())
}

Expand All @@ -66,7 +64,7 @@ export default class ConsoleExceptionHandlerTest {

await new ConsoleExceptionHandler().handle(exception)

assert.calledWith(this.processExitMock, 1)
assert.calledWith(process.exit, 1)
assert.calledWith(errorFake, 'Test error')
}

Expand All @@ -82,7 +80,7 @@ export default class ConsoleExceptionHandlerTest {

await new ConsoleExceptionHandler().handle(error)

assert.calledWith(this.processExitMock, 1)
assert.calledWith(process.exit, 1)
assert.calledOnce(errorFake)
}
}
36 changes: 24 additions & 12 deletions tests/unit/helpers/ActionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,67 +27,79 @@ export default class ActionTest {
@Test()
public async shouldBeAbleToLogASucceededActionInTheStdout({ assert }: Context) {
const successFake = Mock.fake()
const stub = Log.when('standalone').return({ success: _args => successFake(Color.removeColors(_args)) })
const stub = Log.when('standalone')
.return({ success: _args => successFake(Color.removeColors(_args)) })
.get()

this.action.succeeded('app/Services/Service.ts')

assert.calledTimesWith(stub, 1, { level: 'trace', driver: 'null' })
assert.isTrue(successFake.calledWith('CREATE: app/Services/Service.ts'))
assert.calledWith(successFake, 'CREATE: app/Services/Service.ts')
}

@Test()
public async shouldBeAbleToLogASkippedActionInTheStdout({ assert }: Context) {
const successFake = Mock.fake()
const stub = Log.when('standalone').return({ success: _args => successFake(Color.removeColors(_args)) })
const stub = Log.when('standalone')
.return({ success: _args => successFake(Color.removeColors(_args)) })
.get()

this.action.skipped('app/Services/Service.ts')

assert.calledTimesWith(stub, 1, { level: 'trace', driver: 'null' })
assert.isTrue(successFake.calledWith('SKIP: app/Services/Service.ts'))
assert.calledWith(successFake, 'SKIP: app/Services/Service.ts')
}

@Test()
public async shouldBeAbleToLogASkippedActionWithReasonInTheStdout({ assert }: Context) {
const successFake = Mock.fake()
const stub = Log.when('standalone').return({ success: _args => successFake(Color.removeColors(_args)) })
const stub = Log.when('standalone')
.return({ success: _args => successFake(Color.removeColors(_args)) })
.get()

this.action.skipped('app/Services/Service.ts', 'Some reason')

assert.calledTimesWith(stub, 1, { level: 'trace', driver: 'null' })
assert.isTrue(successFake.calledWith('SKIP: app/Services/Service.ts (Some reason)'))
assert.calledWith(successFake, 'SKIP: app/Services/Service.ts (Some reason)')
}

@Test()
public async shouldBeAbleToLogAFailedActionInTheStdout({ assert }: Context) {
const successFake = Mock.fake()
const stub = Log.when('standalone').return({ success: _args => successFake(Color.removeColors(_args)) })
const stub = Log.when('standalone')
.return({ success: _args => successFake(Color.removeColors(_args)) })
.get()

this.action.failed('app/Services/Service.ts')

assert.calledTimesWith(stub, 1, { level: 'trace', driver: 'null' })
assert.isTrue(successFake.calledWith('ERROR: app/Services/Service.ts'))
assert.calledWith(successFake, 'ERROR: app/Services/Service.ts')
}

@Test()
public async shouldBeAbleToLogAFailedActionWithReasonInTheStdout({ assert }: Context) {
const successFake = Mock.fake()
const stub = Log.when('standalone').return({ success: _args => successFake(Color.removeColors(_args)) })
const stub = Log.when('standalone')
.return({ success: _args => successFake(Color.removeColors(_args)) })
.get()

this.action.failed('app/Services/Service.ts', 'Some reason')

assert.calledTimesWith(stub, 1, { level: 'trace', driver: 'null' })
assert.isTrue(successFake.calledWith('ERROR: app/Services/Service.ts (Some reason)'))
assert.calledWith(successFake, 'ERROR: app/Services/Service.ts (Some reason)')
}

@Test()
public async shouldBeAbleToCreateAnActionInstanceWhereTheErrorActionIsTheBiggest({ assert }: Context) {
const action = new Action('OK')
const successFake = Mock.fake()
const stub = Log.when('standalone').return({ success: _args => successFake(Color.removeColors(_args)) })
const stub = Log.when('standalone')
.return({ success: _args => successFake(Color.removeColors(_args)) })
.get()

action.succeeded('app/Services/Service.ts')

assert.calledTimesWith(stub, 1, { level: 'trace', driver: 'null' })
assert.isTrue(successFake.calledWith('OK: app/Services/Service.ts'))
assert.calledWith(successFake, 'OK: app/Services/Service.ts')
}
}
6 changes: 3 additions & 3 deletions tests/unit/helpers/command/LoggerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class LoggerTest {

@Test()
public async shouldBeAbleToLogSimpleValuesWithoutAnyFormatInStdout({ assert }: Context) {
const successFake = Mock.sandbox.fake()
const successFake = Mock.fake()
const standaloneFake = Mock.sandbox.fake(_configs => ({ success: successFake }))
this.logger.standalone = standaloneFake as any

Expand All @@ -44,7 +44,7 @@ export default class LoggerTest {

@Test()
public async shouldBeAbleToLogRainbowMessagesInStdout({ assert }: Context) {
const simpleMock = Mock.sandbox.fake()
const simpleMock = Mock.fake()
this.logger.simple = simpleMock

this.logger.rainbow('hello')
Expand All @@ -61,7 +61,7 @@ export default class LoggerTest {

@Test()
public async shouldBeAbleToLogColumnifiedMessagesInStdout({ assert }: Context) {
const simpleMock = Mock.sandbox.fake()
const simpleMock = Mock.fake()
this.logger.simple = simpleMock

this.logger.column({ hello: 'world' })
Expand Down
Loading