From b51f71faf9e66ca5aa855b24e464c303937a1757 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 24 Apr 2024 16:23:31 +0000 Subject: [PATCH] fix tests --- Config/jasmine.json | 10 ++ Config/jasmine_build.sh | 13 ++ Config/snippets.code-snippets | 251 ---------------------------------- 3 files changed, 23 insertions(+), 251 deletions(-) create mode 100644 Config/jasmine.json create mode 100644 Config/jasmine_build.sh delete mode 100755 Config/snippets.code-snippets diff --git a/Config/jasmine.json b/Config/jasmine.json new file mode 100644 index 0000000..c882222 --- /dev/null +++ b/Config/jasmine.json @@ -0,0 +1,10 @@ +{ + "spec_dir": "tests", + "spec_files": [ + "**/*[sS]pec.js" + ], + "helpers": [ + ], + "stopSpecOnExpectationFailure": false, + "random": true + } \ No newline at end of file diff --git a/Config/jasmine_build.sh b/Config/jasmine_build.sh new file mode 100644 index 0000000..226c1c2 --- /dev/null +++ b/Config/jasmine_build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SEARCH_DIR="./tests" + +FILES=$(find $SEARCH_DIR -type f -name "*Test.js") + +for FILE in $FILES; do + INPUT_PATH="$FILE" + + OUT_PATH="${INPUT_PATH/Test.js/Spec.js}" + + npx esbuild $INPUT_PATH --bundle --outfile=$OUT_PATH +done diff --git a/Config/snippets.code-snippets b/Config/snippets.code-snippets deleted file mode 100755 index a802ce4..0000000 --- a/Config/snippets.code-snippets +++ /dev/null @@ -1,251 +0,0 @@ -{ - "Api Controller": { - "scope": "php,tpl.php", - "prefix": "apicontroller", - "body": [ - "/**", - " * Karaka", - " *", - " * PHP Version 8.1", - " *", - " * @package Modules\\\\$1", - " * @copyright Dennis Eichhorn", - " * @license OMS License 1.0", - " * @version 1.0.0", - " * @link https://jingga.app", - " */", - "declare(strict_types=1);", - "", - "namespace Modules\\\\$1\\Controller;", - "", - "use phpOMS\\Account\\Account;", - "use phpOMS\\Localization\\ISO639x1Enum;", - "use phpOMS\\Message\\NotificationLevel;", - "use phpOMS\\Message\\RequestAbstract;", - "use phpOMS\\Message\\ResponseAbstract;", - "use phpOMS\\Model\\Message\\FormValidation;", - "use phpOMS\\Utils\\Parser\\Markdown\\Markdown;", - "", - "/**", - " * $1 controller class.", - " *", - " * @package Modules\\\\$1", - " * @license OMS License 1.0", - " * @link https://jingga.app", - " * @since 1.0.0", - " */", - "final class ApiController extends Controller", - "{", - "", - "}", - "" - ], - "description": "Create a api controller" - }, - "Null Model": { - "scope": "php,tpl.php", - "prefix": "nullmodel", - "body": [ - "/**", - " * Karaka", - " *", - " * PHP Version 8.1", - " *", - " * @package Modules\\\\$1", - " * @copyright Dennis Eichhorn", - " * @license OMS License 1.0", - " * @version 1.0.0", - " * @link https://jingga.app", - " */", - "declare(strict_types=1);", - "", - "namespace Modules\\\\$1\\Models;", - "", - "/**", - " * Null model", - " *", - " * @package Modules\\\\$1", - " * @license OMS License 1.0", - " * @link https://jingga.app", - " * @since 1.0.0", - " */", - "class Null$2 extends $2", - "{", - "}", - "" - ], - "description": "Create a Null Model" - }, - "Model": { - "scope": "php,tpl.php", - "prefix": "model", - "body": [ - "/**", - " * Karaka", - " *", - " * PHP Version 8.1", - " *", - " * @package Modules\\\\$1", - " * @copyright Dennis Eichhorn", - " * @license OMS License 1.0", - " * @version 1.0.0", - " * @link https://jingga.app", - " */", - "declare(strict_types=1);", - "", - "namespace Modules\\\\$1\\Models;", - "", - "/**", - " * Null model", - " *", - " * @package Modules\\\\$1", - " * @license OMS License 1.0", - " * @link https://jingga.app", - " * @since 1.0.0", - " */", - "class $2 implements \\JsonSerializable", - "{", - " private \\$id = 0;", - "", - " public function getId() : int", - " {", - " return \\$this->id;", - " }", - "", - " /**", - " * {@inheritdoc}", - " */", - " public function toArray() : array", - " {", - " return [", - " 'id' => \\$this->id,", - " ];", - " }", - "", - " /**", - " * {@inheritdoc}", - " */", - " public function __toString()", - " {", - " return (string) \\json_encode(\\$this->toArray());", - " }", - "", - " /**", - " * {@inheritdoc}", - " */", - " public function jsonSerialize()", - " {", - " eturn \\$this->toArray();", - " }", - "}", - "" - ], - "description": "Create a Model" - }, - "Api Create": { - "scope": "php,tpl.php", - "prefix": "apicreate", - "body": [ - " /**", - " * Api method to create a $1", - " *", - " * @param RequestAbstract \\$request Request", - " * @param ResponseAbstract \\$response Response", - " * @param mixed \\$data Generic data", - " *", - " * @return void", - " *", - " * @api", - " *", - " * @since 1.0.0", - " */", - " public function api$2Create(RequestAbstract \\$request, ResponseAbstract \\$response, \\$data = null) : void", - " {", - " if (!empty(\\$val = \\$this->validate$2Create(\\$request))) {", - " \\$response->set('$1_create', new FormValidation(\\$val));", - "", - " return;", - " }", - "", - " $$1 = \\$this->create$2FromRequest(\\$request);", - " \\$this->createModel(\\$request->header->account, $$1, $2Mapper::class, '$1');", - " \\$this->fillJsonResponse(\\$request, \\$response, NotificationLevel::OK, '$2', '$2 successfully created', $$1);", - " }", - "", - " /**", - " * Validate $1 from account create request", - " *", - " * @param RequestAbstract \\$request Request", - " *", - " * @return array", - " *", - " * @since 1.0.0", - " */", - " private function validate$2Create(RequestAbstract \\$request) : array", - " {", - " $val = [];", - " if ((\\$val['account'] = empty(\\$request->getData('account')))", - " ) {", - " return $val;", - " }", - "", - " return [];", - " }", - "", - " /**", - " * Method to create $1 from request.", - " *", - " * @param RequestAbstract \\$request Request", - " *", - " * @return $2", - " *", - " * @since 1.0.0", - " */", - " private function create$2FromRequest(RequestAbstract \\$request) : $2", - " {", - " $$1 = new $2();", - "", - " return $$1;", - " }", - "" - ], - "description": "Create a model in the api controller" - }, - "Enum Create": { - "scope": "php", - "prefix": "enum", - "body": [ - "/**", - " * Karaka", - " *", - " * PHP Version 8.1", - " *", - " * @package Modules\\\\$1", - " * @copyright Dennis Eichhorn", - " * @license OMS License 1.0", - " * @version 1.0.0", - " * @link https://jingga.app", - " */", - "declare(strict_types=1);", - "", - "namespace Modules\\\\$1\\Models;", - "", - "use phpOMS\\Stdlib\\Base\\Enum;", - "", - "/**", - " * $2 enum.", - " *", - " * @package Modules\\\\$1", - " * @license OMS License 1.0", - " * @link https://jingga.app", - " * @since 1.0.0", - " */", - "abstract class $2 extends Enum", - "{", - " public const OPEN = 1;", - "}", - "" - ], - "description": "Create an enum" - } -} \ No newline at end of file