Skip to content

Commit

Permalink
chore(npm): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Aug 26, 2024
1 parent cc0790f commit 35cab68
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 8 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "5.1.0",
"version": "5.2.0",
"description": "One foundation for multiple applications.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down Expand Up @@ -62,6 +62,7 @@
"./commands/BuildCommand": "./src/commands/BuildCommand.js",
"./commands/InstallCommand": "./src/commands/InstallCommand.js",
"./testing/BaseHttpTest": "./src/testing/BaseHttpTest.js",
"./testing/BaseCronTest": "./src/testing/BaseCronTest.js",
"./testing/BaseConsoleTest": "./src/testing/BaseConsoleTest.js"
},
"imports": {
Expand All @@ -83,7 +84,7 @@
"@athenna/artisan": "^5.1.0",
"@athenna/common": "^5.0.0",
"@athenna/config": "^5.0.0",
"@athenna/cron": "^5.1.0",
"@athenna/cron": "^5.2.0",
"@athenna/http": "^5.1.0",
"@athenna/ioc": "^5.0.0",
"@athenna/logger": "^5.0.0",
Expand Down
8 changes: 8 additions & 0 deletions src/commands/MakeTestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export class MakeTestCommand extends BaseCommand {
})
public isConsole: boolean

@Option({
description: 'Create a Cron test.',
signature: '-cr, --cron',
default: false
})
public isCron: boolean

@Option({
description: 'Create the test as function instead of class.',
signature: '--function',
Expand All @@ -58,6 +65,7 @@ export class MakeTestCommand extends BaseCommand {
let template = 'test'

if (this.isConsole) template = 'test-console'
else if (this.isCron) template = 'test-cron'
else if (this.isHttp) template = 'test-http'
else if (this.isUnit) template = 'test' // This is necessary to avoid multiple options case.

Expand Down
47 changes: 47 additions & 0 deletions src/testing/BaseCronTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @athenna/core
*
* (c) João Lenon <lenon@athenna.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import { CronImpl } from '@athenna/cron'
import { Path, Options } from '@athenna/common'
import { AfterAll, BeforeAll } from '@athenna/test'
import { Ignite, type CronOptions, type IgniteOptions } from '#src'

export class BaseCronTest {
public ignite: Ignite
public cron: CronImpl
public cronOptions: CronOptions = {}
public igniteOptions: IgniteOptions = {}

@BeforeAll()
public async baseBeforeAll() {
this.ignite = await new Ignite().load(
Path.toHref(Path.bin(`test.${Path.ext()}`)),
this.getIgniteOptions()
)

this.cron = await this.ignite.cron(this.getCronOptions())
}

@AfterAll()
public async baseAfterAll() {
await this.cron.close()
}

private getCronOptions() {
return Options.create(this.cronOptions, {})
}

private getIgniteOptions() {
return Options.create(this.igniteOptions, {
bootLogs: false,
loadConfigSafe: false,
environments: ['test']
})
}
}
9 changes: 9 additions & 0 deletions templates/test-cron.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Test, type Context } from '@athenna/test'
import { BaseCronTest } from '@athenna/core/testing/BaseCronTest'

export default class {{ namePascal }} extends BaseCronTest {
@Test()
public async shouldBeAbleToRunSchedulers({ scheduler }: Context) {
await scheduler.runByName('MySchedulerClassName')
}
}
11 changes: 11 additions & 0 deletions tests/unit/commands/MakeTestCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ export default class MakeTestCommandTest extends BaseCommandTest {
assert.isTrue(await File.exists(Path.tests('e2e/TestTest.ts')))
}

@Test()
public async shouldBeAbleToCreateATestFileUsingCronTemplate({ assert, command }: Context) {
const output = await command.run('make:test TestTest --cron')

output.assertSucceeded()
output.assertLogged('[ MAKING TEST ]')
output.assertLogged('[ success ] Test "TestTest" successfully created.')

assert.isTrue(await File.exists(Path.tests('e2e/TestTest.ts')))
}

@Test()
public async shouldBeAbleToCreateATestFileUsingFunctionalTemplate({ assert, command }: Context) {
const output = await command.run('make:test TestTest --function')
Expand Down

0 comments on commit 35cab68

Please sign in to comment.