Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / system / tests / modules / js_ajax_test / js / js_ajax_test.ajax.es6.js
diff --git a/web/core/modules/system/tests/modules/js_ajax_test/js/js_ajax_test.ajax.es6.js b/web/core/modules/system/tests/modules/js_ajax_test/js/js_ajax_test.ajax.es6.js
new file mode 100644 (file)
index 0000000..627d2e3
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * @file
+ *  Testing behavior for JSWebAssertTest.
+ */
+(function ($, Drupal) {
+  /**
+   * Test Ajax command.
+   *
+   * @param {Drupal.Ajax} [ajax]
+   *   {@link Drupal.Ajax} object created by {@link Drupal.Ajax}.
+   * @param {object} response
+   *   The response from the Ajax request.
+   * @param {string} response.selector
+   *   A jQuery selector string.
+   */
+  Drupal.AjaxCommands.prototype.jsAjaxTestCommand = function (ajax, response) {
+    const $domElement = $(response.selector);
+    ajax.element_settings.cat = 'catbro';
+
+    const data = {
+      element_settings: ajax.element_settings.cat || {},
+      elementSettings: ajax.elementSettings.cat || {},
+    };
+
+    $domElement.html(`<div id="js_ajax_test_form_element">${JSON.stringify(data)}</div>`);
+  };
+}(jQuery, Drupal));