From 1f4623f6790d4948af0f3d53cdcfb8a2a94c969f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szikszai=20Guszt=C3=A1v?= Date: Mon, 25 Nov 2024 14:13:21 +0100 Subject: [PATCH] Testing Improvements (#715) Co-authored-by: Sijawusz Pur Rahnama --- core/tests/tests/GlobalComponent.mint | 11 ++++ core/tests/tests/Test.mint | 22 +++++++ runtime/src/testing.js | 58 +++++++++++++----- spec/compilers/test | 21 +++++++ spec/compilers/test_with_global_component | 36 +++++++++++ spec/compilers/test_with_reference | 45 ++++++++++++++ spec/compilers/test_with_reference_component | 61 +++++++++++++++++++ spec/compilers_spec.cr | 9 ++- ...tml_element_reference_outside_of_component | 2 +- src/assets/runtime_test.js | 10 +-- src/ast/test.cr | 5 +- src/compiler.cr | 9 +++ src/compiler/js.cr | 5 +- src/compilers/component.cr | 30 +++++---- src/compilers/suite.cr | 2 +- src/compilers/test.cr | 9 ++- src/compilers/variable.cr | 6 +- src/parsers/test.cr | 17 +++++- src/scope.cr | 8 ++- src/type_checkers/html_element.cr | 4 +- src/type_checkers/variable.cr | 6 +- 21 files changed, 323 insertions(+), 53 deletions(-) create mode 100644 core/tests/tests/GlobalComponent.mint create mode 100644 spec/compilers/test create mode 100644 spec/compilers/test_with_global_component create mode 100644 spec/compilers/test_with_reference create mode 100644 spec/compilers/test_with_reference_component diff --git a/core/tests/tests/GlobalComponent.mint b/core/tests/tests/GlobalComponent.mint new file mode 100644 index 000000000..4c7b46d88 --- /dev/null +++ b/core/tests/tests/GlobalComponent.mint @@ -0,0 +1,11 @@ +global component GlobalTest { + fun render : Html { +
+ } +} + +suite "Global Component" { + test "It renders on the page" { + Dom.getElementBySelector(".global-component") != Maybe.Nothing + } +} diff --git a/core/tests/tests/Test.mint b/core/tests/tests/Test.mint index 5addaf7a4..4b869b746 100644 --- a/core/tests/tests/Test.mint +++ b/core/tests/tests/Test.mint @@ -17,3 +17,25 @@ suite "Test (Function)" { test() == "" } } + +suite "Test with HTML reference" { + test "it works" { +