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

chore(npm): update dependencies #236

Merged
merged 2 commits into from
Aug 26, 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
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.

6 changes: 4 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 <[email protected]>",
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 Expand Up @@ -212,6 +213,7 @@
"test": "./templates/test.edge",
"test-console": "./templates/test-console.edge",
"test-http": "./templates/test-http.edge",
"test-cron": "./templates/test-cron.edge",
"test-fn": "./templates/test-fn.edge",
"command": "node_modules/@athenna/artisan/templates/command.edge",
"controller": "node_modules/@athenna/http/templates/controller.edge",
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 <[email protected]>
*
* 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')
}
}
13 changes: 13 additions & 0 deletions tests/unit/commands/MakeTestCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ 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')

console.log(output.output)

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
Loading