diff --git a/package-lock.json b/package-lock.json index 2a628f0..9013b77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/core", - "version": "4.10.1", + "version": "4.10.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/core", - "version": "4.10.1", + "version": "4.10.2", "license": "MIT", "dependencies": { "pretty-repl": "^3.1.2", diff --git a/package.json b/package.json index 58bb51c..89d2a5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/core", - "version": "4.10.1", + "version": "4.10.2", "description": "The plug and play Node.js framework.", "license": "MIT", "author": "João Lenon ", @@ -57,8 +57,8 @@ "./commands/ServeCommand": "./src/commands/ServeCommand.js", "./commands/TestCommand": "./src/commands/TestCommand.js", "./commands/BuildCommand": "./src/commands/BuildCommand.js", - "./testing/BaseCliTest": "./src/testing/BaseCliTest.js", - "./testing/BaseRestTest": "./src/testing/BaseRestTest.js" + "./testing/BaseHttpTest": "./src/testing/BaseHttpTest.js", + "./testing/BaseConsoleTest": "./src/testing/BaseConsoleTest.js" }, "imports": { "#bin/*": "./bin/*.js", @@ -106,8 +106,8 @@ "src/**/*.ts" ], "exclude": [ - "src/testing/BaseCliTest.ts", - "src/testing/BaseRestTest.ts", + "src/testing/BaseConsoleTest.ts", + "src/testing/BaseHttpTest.ts", "src/repl/helpers/Command.ts", "src/types/*" ], @@ -204,8 +204,8 @@ "provider": "./templates/provider.edge", "service": "./templates/service.edge", "test": "./templates/test.edge", - "test-cli": "./templates/test-cli.edge", - "test-rest": "./templates/test-rest.edge", + "test-console": "./templates/test-console.edge", + "test-http": "./templates/test-http.edge", "test-fn": "./templates/test-fn.edge", "command": "node_modules/@athenna/artisan/templates/command.edge", "controller": "node_modules/@athenna/http/templates/controller.edge", diff --git a/src/applications/Http.ts b/src/applications/Http.ts index 68a228d..3b3c584 100644 --- a/src/applications/Http.ts +++ b/src/applications/Http.ts @@ -22,7 +22,7 @@ export class Http { host: Config.get('http.host', '127.0.0.1'), port: Config.get('http.port', 3000), trace: Config.get('http.trace', false), - routePath: Path.routes(`rest.${Path.ext()}`), + routePath: Path.routes(`http.${Path.ext()}`), kernelPath: '@athenna/http/kernels/HttpKernel' }) @@ -37,7 +37,7 @@ export class Http { await server.listen({ host: options.host, port: options.port }) if (Config.notExists('rc.bootLogs') || Config.is('rc.bootLogs', false)) { - return + return server } const host = server.getHost() || options.host diff --git a/src/commands/MakeTestCommand.ts b/src/commands/MakeTestCommand.ts index a9673a0..2f83170 100644 --- a/src/commands/MakeTestCommand.ts +++ b/src/commands/MakeTestCommand.ts @@ -25,18 +25,18 @@ export class MakeTestCommand extends BaseCommand { public isUnit: boolean @Option({ - description: 'Create a REST API test.', - signature: '-r, --rest', + description: 'Create a HTTP test.', + signature: '-h, --http', default: false }) - public isRest: boolean + public isHttp: boolean @Option({ - description: 'Create a CLI test.', - signature: '-c, --cli', + description: 'Create a Console test.', + signature: '-c, --console', default: false }) - public isCli: boolean + public isConsole: boolean @Option({ description: 'Create the test as function instead of class.', @@ -58,8 +58,8 @@ export class MakeTestCommand extends BaseCommand { let template = 'test' - if (this.isCli) template = 'test-cli' - else if (this.isRest) template = 'test-rest' + if (this.isConsole) template = 'test-console' + else if (this.isHttp) template = 'test-http' else if (this.isUnit) template = 'test' // This is necessary to avoid multiple options case. if (this.isFunction) { diff --git a/src/testing/BaseCliTest.ts b/src/testing/BaseConsoleTest.ts similarity index 96% rename from src/testing/BaseCliTest.ts rename to src/testing/BaseConsoleTest.ts index cc32c95..d698bfc 100644 --- a/src/testing/BaseCliTest.ts +++ b/src/testing/BaseConsoleTest.ts @@ -12,7 +12,7 @@ import { BeforeAll } from '@athenna/test' import { Ignite, type IgniteOptions } from '@athenna/core' import { TestCommand } from '@athenna/artisan/testing/plugins' -export class BaseCliTest { +export class BaseConsoleTest { public ignite: Ignite public igniteOptions: IgniteOptions = {} public artisanPath: string = Path.bootstrap(`artisan.${Path.ext()}`) diff --git a/src/testing/BaseRestTest.ts b/src/testing/BaseHttpTest.ts similarity index 97% rename from src/testing/BaseRestTest.ts rename to src/testing/BaseHttpTest.ts index 5fceb90..b72d9a5 100644 --- a/src/testing/BaseRestTest.ts +++ b/src/testing/BaseHttpTest.ts @@ -12,7 +12,7 @@ import { ServerImpl } from '@athenna/http' import { AfterAll, BeforeAll } from '@athenna/test' import { Ignite, type HttpOptions, type IgniteOptions } from '@athenna/core' -export class BaseRestTest { +export class BaseHttpTest { public ignite: Ignite public httpServer: ServerImpl public httpOptions: HttpOptions = {} diff --git a/templates/test-cli.edge b/templates/test-cli.edge deleted file mode 100644 index 914463b..0000000 --- a/templates/test-cli.edge +++ /dev/null @@ -1,12 +0,0 @@ -import { Test, type Context } from '@athenna/test' -import { BaseCliTest } from '@athenna/core/testing/BaseCliTest' - -export default class {{ namePascal }} extends BaseCliTest { - @Test() - public async shouldBeAbleToExecuteCliCommands({ command }: Context) { - const output = await command.run('greet') - - output.assertSucceeded() - output.assertLogged('Hello World!') - } -} diff --git a/templates/test-console.edge b/templates/test-console.edge new file mode 100644 index 0000000..c5f5ab7 --- /dev/null +++ b/templates/test-console.edge @@ -0,0 +1,12 @@ +import { Test, type Context } from '@athenna/test' +import { BaseConsoleTest } from '@athenna/core/testing/BaseConsoleTest' + +export default class {{ namePascal }} extends BaseConsoleTest { + @Test() + public async shouldBeAbleToExecuteConsoleCommands({ command }: Context) { + const output = await command.run('greet') + + output.assertSucceeded() + output.assertLogged('Hello World!') + } +} diff --git a/templates/test-http.edge b/templates/test-http.edge new file mode 100644 index 0000000..1a694fc --- /dev/null +++ b/templates/test-http.edge @@ -0,0 +1,11 @@ +import { Test, type Context } from '@athenna/test' +import { BaseHttpTest } from '@athenna/core/testing/BaseHttpTest' + +export default class {{ namePascal }} extends BaseHttpTest { + @Test() + public async shouldBeAbleToExecuteHttpRequests({ request }: Context) { + const response = await request.get('/') + + response.assertStatusCode(200) + } +} diff --git a/templates/test-rest.edge b/templates/test-rest.edge deleted file mode 100644 index a7720aa..0000000 --- a/templates/test-rest.edge +++ /dev/null @@ -1,11 +0,0 @@ -import { Test, type Context } from '@athenna/test' -import { BaseRestTest } from '@athenna/core/testing/BaseRestTest' - -export default class {{ namePascal }} extends BaseRestTest { - @Test() - public async shouldBeAbleToExecuteRestApiRequests({ request }: Context) { - const response = await request.get('/') - - response.assertStatusCode(200) - } -} diff --git a/tests/helpers/BaseCommandTest.ts b/tests/helpers/BaseCommandTest.ts index 5761f11..8ffc490 100644 --- a/tests/helpers/BaseCommandTest.ts +++ b/tests/helpers/BaseCommandTest.ts @@ -32,6 +32,7 @@ export class BaseCommandTest { await Folder.safeRemove(Path.app()) await Folder.safeRemove(Path.providers()) await Folder.safeRemove(Path.storage()) + await Folder.safeRemove(Path.fixtures('storage')) await Folder.safeRemove(Path.pwd('dist')) await Folder.safeRemove(Path.pwd('build')) await Folder.safeRemove(Path.pwd('build-relative')) diff --git a/tests/unit/commands/MakeTestCommandTest.ts b/tests/unit/commands/MakeTestCommandTest.ts index c6fde7f..a66f490 100644 --- a/tests/unit/commands/MakeTestCommandTest.ts +++ b/tests/unit/commands/MakeTestCommandTest.ts @@ -35,8 +35,8 @@ export default class MakeTestCommandTest extends BaseCommandTest { } @Test() - public async shouldBeAbleToCreateATestFileUsingRestTemplate({ assert, command }: Context) { - const output = await command.run('make:test TestTest --rest') + public async shouldBeAbleToCreateATestFileUsingHttpTemplate({ assert, command }: Context) { + const output = await command.run('make:test TestTest --http') output.assertSucceeded() output.assertLogged('[ MAKING TEST ]') @@ -46,8 +46,8 @@ export default class MakeTestCommandTest extends BaseCommandTest { } @Test() - public async shouldBeAbleToCreateATestFileUsingCliTemplate({ assert, command }: Context) { - const output = await command.run('make:test TestTest --cli') + public async shouldBeAbleToCreateATestFileUsingConsoleTemplate({ assert, command }: Context) { + const output = await command.run('make:test TestTest --console') output.assertSucceeded() output.assertLogged('[ MAKING TEST ]') diff --git a/tests/unit/testing/BaseCliTestTest.ts b/tests/unit/testing/BaseCliTestTest.ts deleted file mode 100644 index 01b72a1..0000000 --- a/tests/unit/testing/BaseCliTestTest.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @athenna/core - * - * (c) João Lenon - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -export default class BaseCliTestTest {} diff --git a/tests/unit/testing/BaseRestTestTest.ts b/tests/unit/testing/BaseRestTestTest.ts deleted file mode 100644 index 39a577b..0000000 --- a/tests/unit/testing/BaseRestTestTest.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @athenna/core - * - * (c) João Lenon - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -export default class BaseRestTestTest {}