You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by be...@apache.org on 2021/09/14 06:40:34 UTC

[tapestry-5] branch master updated: webresources: un-ignored TypeScriptCompilerSpec

This is an automated email from the ASF dual-hosted git repository.

benw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git


The following commit(s) were added to refs/heads/master by this push:
     new aa5b789  webresources: un-ignored TypeScriptCompilerSpec
aa5b789 is described below

commit aa5b789c4b65a6310fbbd274bda33adfde9215f8
Author: Benjamin Weidig <be...@netzgut.net>
AuthorDate: Tue Sep 14 08:39:27 2021 +0200

    webresources: un-ignored TypeScriptCompilerSpec
    
    The TypeScriptCompilerSpec was ignored because it used Tapestry to build itself, and there were some Spock issues.
    To get it working, the TypeScriptCompiler is now build manually.
    
    A test for TAP5-2691 (Rhino problems) was added. It succeeds on my machine, but maybe not on others. As long as the issue isn't actively worked on, the test is ignored.
---
 .../tests/TypeScriptCompilerSpec.groovy            | 47 +++++++++-------------
 .../resources/t5/webresources/keywords-compiled.js | 17 ++++++++
 .../src/test/resources/t5/webresources/keywords.ts | 14 +++++++
 3 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/tapestry-webresources/src/test/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy b/tapestry-webresources/src/test/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy
index 0bd7a05..29b2ff2 100644
--- a/tapestry-webresources/src/test/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy
+++ b/tapestry-webresources/src/test/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy
@@ -1,41 +1,29 @@
 package t5.webresources.tests;
 
-import org.apache.tapestry5.SymbolConstants
-import org.apache.tapestry5.commons.MappedConfiguration
-import org.apache.tapestry5.http.services.ApplicationGlobals
-import org.apache.tapestry5.internal.InternalSymbols
-import org.apache.tapestry5.internal.test.PageTesterContext
 import org.apache.tapestry5.internal.webresources.TypeScriptCompiler
-import org.apache.tapestry5.ioc.annotations.Autobuild
-import org.apache.tapestry5.ioc.annotations.Inject
-import org.apache.tapestry5.ioc.annotations.SubModule
+import org.apache.tapestry5.ioc.internal.QuietOperationTracker
 import org.apache.tapestry5.ioc.internal.util.ClasspathResource
-import org.apache.tapestry5.modules.AssetsModule
-import org.apache.tapestry5.modules.TapestryModule
-import org.apache.tapestry5.webresources.modules.WebResourcesModule
 
-import spock.lang.Shared
 import spock.lang.Ignore
+import spock.lang.Shared
 import spock.lang.Specification
 
-@Ignore("spock-tapestry isn't ready for Tapestry 5.7.0 yet")
-@SubModule([TapestryModule, WebResourcesModule, TypeScriptCompilerSpec.TestModule, AssetsModule])
-class TypeScriptCompilerSpec /*extends Specification*/ {
+class TypeScriptCompilerSpec extends Specification {
 
-  @Autobuild
+  @Shared
   private TypeScriptCompiler typeScriptCompiler;
 
-  @Inject
-  @Shared
-  private ApplicationGlobals applicationGlobals
 
   def setupSpec(){
-    applicationGlobals.storeContext(new PageTesterContext("/test"));
+    def resource = new ClasspathResource("org/apache/tapestry5/webresources/internal/typescript.js")
+    def op = new QuietOperationTracker()
+    typeScriptCompiler = new TypeScriptCompiler(op, resource)
   }
 
   def "Compile Hello World example"(){
     when:
     def resource = new ClasspathResource("t5/webresources/greeter.ts")
+
     def compiled = typeScriptCompiler.transform(resource, null)
     then:
     compiled.text == TypeScriptCompilerSpec.class.getResourceAsStream('/t5/webresources/greeter-compiled.js').text
@@ -48,13 +36,16 @@ class TypeScriptCompilerSpec /*extends Specification*/ {
     then:
     compiled.text == TypeScriptCompilerSpec.class.getResourceAsStream('/t5/webresources/park-example-compiled.js').text
   }
-  
-  public static class TestModule {
-
-    def contributeApplicationDefaults(MappedConfiguration configuration){
-      configuration.add(InternalSymbols.APP_NAME, "test")
-      configuration.add("tapestry.app-package", "typescript")
-      configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
-    }
+
+  // TAP5-2691: Rhino has (sometimes) problems with ES6 code
+  // Ignored for now, because this works on my machine, but can be problematic
+  // on others
+  @Ignore
+  def "reserved keynamed as properties"(){
+    when:
+    def resource = new ClasspathResource("t5/webresources/keywords.ts")
+    def compiled = typeScriptCompiler.transform(resource, null)
+    then:
+    compiled.text == TypeScriptCompilerSpec.class.getResourceAsStream('/t5/webresources/keywords-compiled.js').text
   }
 }
diff --git a/tapestry-webresources/src/test/resources/t5/webresources/keywords-compiled.js b/tapestry-webresources/src/test/resources/t5/webresources/keywords-compiled.js
new file mode 100644
index 0000000..a2e4e2f
--- /dev/null
+++ b/tapestry-webresources/src/test/resources/t5/webresources/keywords-compiled.js
@@ -0,0 +1,17 @@
+define(["require", "exports"], function (require, exports) {
+    "use strict";
+    var Keywords = /** @class */ (function () {
+        function Keywords() {
+        }
+        Keywords.prototype.delete = function () {
+            // delete is a reserved keyword, but should be fine
+        };
+        Keywords.prototype.return = function () {
+            // another keyword
+        };
+        return Keywords;
+    }());
+    var k = new Keywords();
+    k.delete();
+    k.return();
+});
diff --git a/tapestry-webresources/src/test/resources/t5/webresources/keywords.ts b/tapestry-webresources/src/test/resources/t5/webresources/keywords.ts
new file mode 100644
index 0000000..261f652
--- /dev/null
+++ b/tapestry-webresources/src/test/resources/t5/webresources/keywords.ts
@@ -0,0 +1,14 @@
+class Keywords {
+
+    delete() {
+        // delete is a reserved keyword, but should be fine
+    }
+
+    return() {
+        // another keyword
+    }
+}
+
+let k = new Keywords()
+k.delete()
+k.return()