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

thiagohp pushed a commit to branch feature/coffeescript-to-typescript
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit 95959ad908ddac762ba4a24a933d2a0c9fb47820
Author: decaffeinate <thi...@arsmachina.com.br>
AuthorDate: Sat Apr 19 16:39:00 2025 -0300

    decaffeinate: Convert zonedemo.coffee and 10 other files to JS
---
 .../test/coffeescript/META-INF/assets/zonedemo.js  |  12 ++-
 .../META-INF/modules/app/test-support.js           |  20 ++--
 .../META-INF/modules/client-console-demo.js        |  17 ++--
 .../coffeescript/META-INF/modules/palette-demo.js  |  20 ++--
 .../META-INF/modules/validate-in-error.js          |  14 +--
 .../integration/app1/pages/qunit-config.js         |   4 +-
 .../integration/app1/pages/qunit-driver.js         |   2 +-
 .../tapestry5/integration/app1/pages/test-dom.js   | 101 ++++++++++++---------
 .../integration/app1/pages/test-messages.js        |  28 +++---
 .../tapestry5/integration/app1/pages/test-utils.js |  20 ++--
 .../integration/app1/pages/test-validation.js      |  47 +++++-----
 11 files changed, 157 insertions(+), 128 deletions(-)

diff --git a/tapestry-core/src/test/coffeescript/META-INF/assets/zonedemo.js 
b/tapestry-core/src/test/coffeescript/META-INF/assets/zonedemo.js
index 0b5b8a816..1f672aa66 100644
--- a/tapestry-core/src/test/coffeescript/META-INF/assets/zonedemo.js
+++ b/tapestry-core/src/test/coffeescript/META-INF/assets/zonedemo.js
@@ -1,5 +1,7 @@
-require ["t5/core/dom", "t5/core/events"],
-  (dom, events) ->
-
-    dom.onDocument events.zone.didUpdate, ->
-      (dom "zone-update-message").update "Zone updated."
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+require(["t5/core/dom", "t5/core/events"],
+  (dom, events) => dom.onDocument(events.zone.didUpdate, () => 
(dom("zone-update-message")).update("Zone updated.")));
diff --git 
a/tapestry-core/src/test/coffeescript/META-INF/modules/app/test-support.js 
b/tapestry-core/src/test/coffeescript/META-INF/modules/app/test-support.js
index ffbb58321..806d44ca1 100644
--- a/tapestry-core/src/test/coffeescript/META-INF/modules/app/test-support.js
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/app/test-support.js
@@ -1,14 +1,16 @@
-# Provide test support functions that can be addressed via Selenium.
+// Provide test support functions that can be addressed via Selenium.
 
-# TODO: Maybe move this to main, for external re-use?
+// TODO: Maybe move this to main, for external re-use?
 
-define ["t5/core/dom"],
-  (dom) ->
+define(["t5/core/dom"],
+  function(dom) {
 
-    exports =
-      findCSSMatchCount: (selector) -> dom.body.find(selector).length
-      doesNotExist: (elementId) -> (dom elementId) is null
+    const exports = {
+      findCSSMatchCount(selector) { return dom.body.find(selector).length; },
+      doesNotExist(elementId) { return (dom(elementId)) === null; }
+    };
 
-    window.testSupport = exports
+    window.testSupport = exports;
 
-    return exports
\ No newline at end of file
+    return exports;
+});
\ No newline at end of file
diff --git 
a/tapestry-core/src/test/coffeescript/META-INF/modules/client-console-demo.js 
b/tapestry-core/src/test/coffeescript/META-INF/modules/client-console-demo.js
index 2a960ff96..ebca6c142 100644
--- 
a/tapestry-core/src/test/coffeescript/META-INF/modules/client-console-demo.js
+++ 
b/tapestry-core/src/test/coffeescript/META-INF/modules/client-console-demo.js
@@ -1,8 +1,13 @@
-define ["t5/core/dom", "t5/core/console"],
-  (dom, console) ->
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+define(["t5/core/dom", "t5/core/console"],
+  function(dom, console) {
 
-    for name in ["debug", "info", "warn", "error"]
-      do (name) ->
-        (dom name).on "change", -> console[name](@value())
+    for (var name of ["debug", "info", "warn", "error"]) {
+      ((name => (dom(name)).on("change", function() { return 
console[name](this.value()); })))(name);
+    }
 
-    return
\ No newline at end of file
+});
\ No newline at end of file
diff --git 
a/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.js 
b/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.js
index dde3d82b6..c232437f7 100644
--- a/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.js
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/palette-demo.js
@@ -1,11 +1,15 @@
-define ["t5/core/dom", "t5/core/events", "underscore", "t5/core/console"],
-  (dom, events, _, console) ->
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+define(["t5/core/dom", "t5/core/events", "underscore", "t5/core/console"],
+  (dom, events, _, console) => dom.body.on(events.palette.willChange, 
function(event, memo) {
 
-    dom.body.on events.palette.willChange, (event, memo) ->
+    console.info("palette-demo, palette willChange");
 
-      console.info "palette-demo, palette willChange"
+    const values = _.map(memo.selectedOptions, o => o.value);
 
-      values = _.map memo.selectedOptions, (o) -> o.value
-
-      (dom "event-selection").update JSON.stringify values
-      (dom "event-reorder").update memo.reorder.toString()
\ No newline at end of file
+    (dom("event-selection")).update(JSON.stringify(values));
+    return (dom("event-reorder")).update(memo.reorder.toString());
+  }));
\ No newline at end of file
diff --git 
a/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.js 
b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.js
index 75edfe8dd..84519854d 100644
--- a/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.js
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.js
@@ -1,7 +1,7 @@
-define ['t5/core/dom', 't5/core/events'], (dom, events)->
-  dom.onDocument events.form.validateInError, 'form', ->
-    attributes =
-      id: 'validate-in-error'
-    @prepend dom.create 'div', attributes, 'Validate in error'
-    return
-  return
+define(['t5/core/dom', 't5/core/events'], function(dom, events){
+  dom.onDocument(events.form.validateInError, 'form', function() {
+    const attributes =
+      {id: 'validate-in-error'};
+    this.prepend(dom.create('div', attributes, 'Validate in error'));
+  });
+});
diff --git 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-config.js
 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-config.js
index 8e81d9a11..caf38bd9a 100644
--- 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-config.js
+++ 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-config.js
@@ -1,2 +1,2 @@
-QUnit.config.autostart = false
-QUnit.config.autorun = true
\ No newline at end of file
+QUnit.config.autostart = false;
+QUnit.config.autorun = true;
\ No newline at end of file
diff --git 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-driver.js
 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-driver.js
index fa6a776d3..1d974f564 100644
--- 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-driver.js
+++ 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/qunit-driver.js
@@ -1 +1 @@
-QUnit.load()
+QUnit.load();
diff --git 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-dom.js
 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-dom.js
index 1bbd4ab2f..ebf82c6b5 100644
--- 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-dom.js
+++ 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-dom.js
@@ -1,72 +1,87 @@
-require ["t5/core/dom"], (dom) ->
-  module "t5/core/dom"
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+require(["t5/core/dom"], function(dom) {
+  module("t5/core/dom");
 
-  test "get wrapped element by id", ->
-    e = dom "dom-eventelement-native"
+  test("get wrapped element by id", function() {
+    const e = dom("dom-eventelement-native");
 
-    ok e isnt null, "element found and wrapped"
+    return ok(e !== null, "element found and wrapped");
+  });
 
-  test "get wrapped element by unknown id is null", ->
-    e = dom "dom-does-not-exist-element"
+  test("get wrapped element by unknown id is null", function() {
+    const e = dom("dom-does-not-exist-element");
 
-    ok e is null, "element not found and null"
+    return ok(e === null, "element not found and null");
+  });
 
-  test "trigger native events", ->
+  test("trigger native events", function() {
 
-    clicks = 0
-    container = dom "dom-eventelement-native"
-    button = container.findFirst "a"
+    let clicks = 0;
+    const container = dom("dom-eventelement-native");
+    const button = container.findFirst("a");
 
-    container.on "click", "a", ->
-      clicks++
-      return false
+    container.on("click", "a", function() {
+      clicks++;
+      return false;
+    });
 
-    button.trigger "click"
+    button.trigger("click");
 
-    equal clicks, 1, "native event was triggered"
+    return equal(clicks, 1, "native event was triggered");
+  });
 
-  test "selector used with events filters", ->
+  test("selector used with events filters", function() {
 
-    clicks = 0
-    container = dom "dom-eventelement-selector"
-    primary = container.findFirst "a.btn-primary"
-    secondary = container.findFirst "a[data-use=secondary]"
+    let clicks = 0;
+    const container = dom("dom-eventelement-selector");
+    const primary = container.findFirst("a.btn-primary");
+    const secondary = container.findFirst("a[data-use=secondary]");
 
-    container.on "x:click", "a.btn-primary", ->
-      clicks++
-      return false
+    container.on("x:click", "a.btn-primary", function() {
+      clicks++;
+      return false;
+    });
 
-    primary.trigger "x:click"
+    primary.trigger("x:click");
 
-    equal clicks, 1, "click on selected element invokes handler"
+    equal(clicks, 1, "click on selected element invokes handler");
 
-    secondary.trigger "x:click"
+    secondary.trigger("x:click");
 
-    equal clicks, 1, "click on non-selected element does not invoke handler"
+    return equal(clicks, 1, "click on non-selected element does not invoke 
handler");
+  });
 
-  test "this is matched element in handler", ->
+  test("this is matched element in handler", function() {
 
-    container = dom "dom-eventelement-matched"
-    primary = container.findFirst "a.btn-primary"
+    const container = dom("dom-eventelement-matched");
+    const primary = container.findFirst("a.btn-primary");
 
-    container.on "x:click", "a.btn-primary", ->
+    container.on("x:click", "a.btn-primary", function() {
 
-      strictEqual @element, primary.element, "this should be the wrapper for 
element that was matched"
+      strictEqual(this.element, primary.element, "this should be the wrapper 
for element that was matched");
 
-      return false
+      return false;
+    });
 
-    primary.trigger "x:click"
+    return primary.trigger("x:click");
+  });
 
-  test "visibility, hide(), and show()", ->
+  return test("visibility, hide(), and show()", function() {
 
-    e = (dom "dom-visibility").findFirst "span"
+    const e = (dom("dom-visibility")).findFirst("span");
 
-    equal e.visible(), true, "element is initially visible"
+    equal(e.visible(), true, "element is initially visible");
 
-    e.hide()
+    e.hide();
 
-    equal e.visible(), false, "element is not visible once hidden"
+    equal(e.visible(), false, "element is not visible once hidden");
 
-    e.show()
+    e.show();
 
-    equal e.visible(), true, "element is visible against once shown"
+    return equal(e.visible(), true, "element is visible against once shown");
+  });
+});
diff --git 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-messages.js
 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-messages.js
index 213f5415e..65e98a8fd 100644
--- 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-messages.js
+++ 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-messages.js
@@ -1,22 +1,20 @@
-require ["t5/core/messages", "underscore"], (messages, _) ->
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+require(["t5/core/messages", "underscore"], function(messages, _) {
 
-  module "t5/core/messages"
+  module("t5/core/messages");
 
-  missing = (key) ->
-    (_.indexOf messages.keys(), key) is -1
+  const missing = key => (_.indexOf(messages.keys(), key)) === -1;
 
-  test "access known key", ->
-    equal messages("client-accessible"), "Client Accessible"
+  test("access known key", () => equal(messages("client-accessible"), "Client 
Accessible"));
 
-  test "unknown messages key", ->
+  test("unknown messages key", () => equal(messages("gnip-gnop"), "[[Missing 
Key: 'gnip-gnop']]"));
 
-    equal messages("gnip-gnop"), "[[Missing Key: 'gnip-gnop']]"
+  test("messages values with '%' are not client accessible", () => 
ok(missing("not-visible")));
 
-  test "messages values with '%' are not client accessible", ->
-
-    ok missing "not-visible"
-
-  test "messages prefixed with 'private-' are not client accessible", ->
-
-    ok missing "private-is-not-visible"
+  return test("messages prefixed with 'private-' are not client accessible", 
() => ok(missing("private-is-not-visible")));
+});
 
diff --git 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.js
 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.js
index d1628b99d..b0e06f0b5 100644
--- 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.js
+++ 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.js
@@ -1,10 +1,16 @@
-require ["t5/core/utils"], (utils) ->
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+require(["t5/core/utils"], function(utils) {
 
-  module "t5/core/utils"
+  module("t5/core/utils");
 
-  test "startsWith, positive case", ->
-       ok utils.startsWith 'foobar', 'foo'
-       ok utils.startsWith 'foobarfoo', 'foo' # TAP5-2370
+  test("startsWith, positive case", function() {
+       ok(utils.startsWith('foobar', 'foo'));
+       return ok(utils.startsWith('foobarfoo', 'foo'));
+  }); // TAP5-2370
 
-  test "startsWith, negative case", ->
-    equal (utils.startsWith 'barfoo', 'foo'), false
+  return test("startsWith, negative case", () => 
equal((utils.startsWith('barfoo', 'foo')), false));
+});
diff --git 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-validation.js
 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-validation.js
index 4e9804e66..a102c6d16 100644
--- 
a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-validation.js
+++ 
b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-validation.js
@@ -1,35 +1,32 @@
-require ["t5/core/validation"], (v) ->
+/*
+ * decaffeinate suggestions:
+ * DS102: Remove unnecessary code created because of implicit returns
+ * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
+ */
+require(["t5/core/validation"], function(v) {
 
-  parse = v.parseNumber
+  const parse = v.parseNumber;
 
-  module "t5/core/validation"
+  module("t5/core/validation");
 
-  # Tests assume, currently, that the active locale is "en". This affects
-  # the decimal format symbols.
+  // Tests assume, currently, that the active locale is "en". This affects
+  // the decimal format symbols.
 
-  test "basic numeric parsing", ->
+  test("basic numeric parsing", function() {
 
-    strictEqual (parse "-1.23"), -1.23
-    strictEqual (parse "200", true), 200
-    strictEqual (parse "1,000"), 1000
-    strictEqual (parse ".23"), 0.23
+    strictEqual((parse("-1.23")), -1.23);
+    strictEqual((parse("200", true)), 200);
+    strictEqual((parse("1,000")), 1000);
+    return strictEqual((parse(".23")), 0.23);
+  });
 
-  test "minus not allowed in middle", ->
+  test("minus not allowed in middle", () => throws((() => parse("1-1")), /not 
numeric/));
 
-    throws (-> parse "1-1"), /not numeric/
+  test("input is trimmed", () => strictEqual((parse(" 123,456.78 ")), 
123456.78));
 
-  test "input is trimmed", ->
+  test("no grouping seperator after decimal point", () => throws((() => 
parse(".2,3")), /not numeric/));
 
-    strictEqual (parse " 123,456.78 "), 123456.78
+  test("consecutive grouping seperator not allowed", () => throws((() => 
parse("2,,3")), /not numeric/));
 
-  test "no grouping seperator after decimal point", ->
-
-    throws (-> parse ".2,3"), /not numeric/
-
-  test "consecutive grouping seperator not allowed", ->
-
-    throws (-> parse "2,,3"), /not numeric/
-
-  test "decimal not allowed for integer", ->
-
-    throws (-> parse "3.14", true), /not an integer/
+  return test("decimal not allowed for integer", () => throws((() => 
parse("3.14", true)), /not an integer/));
+});

Reply via email to