From de07242b6a37aa9f99a156d16fbb2abab6eb1ba6 Mon Sep 17 00:00:00 2001
From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
Date: Thu, 28 Mar 2024 14:19:57 -0400
Subject: [PATCH] modernize input tests
---
.../components/input-angle-test.js | 55 ++++++-------------
.../components/input-curly-test.js | 35 ++++--------
2 files changed, 26 insertions(+), 64 deletions(-)
diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/input-angle-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/input-angle-test.js
index a1dfccd37fc..4fcd2bb4771 100644
--- a/packages/@ember/-internals/glimmer/tests/integration/components/input-angle-test.js
+++ b/packages/@ember/-internals/glimmer/tests/integration/components/input-angle-test.js
@@ -1,12 +1,5 @@
-import {
- moduleFor,
- RenderingTestCase,
- runDestroy,
- runTask,
- testUnless,
-} from 'internal-test-helpers';
-import { set } from '@ember/object';
-import { DEPRECATIONS } from '../../../../deprecations';
+import { moduleFor, RenderingTestCase, runDestroy, runTask } from 'internal-test-helpers';
+import { action, set } from '@ember/object';
class InputRenderingTest extends RenderingTestCase {
$input() {
@@ -287,24 +280,16 @@ moduleFor(
// this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce)
}
- [`${testUnless(
- DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isRemoved
- )} sends an action with \`\` when is pressed`](
+ [`@test sends an action with \`\` when is pressed`](
assert
) {
- assert.expect(3);
- expectDeprecation(
- /Usage of the `\(action\)` helper is deprecated./,
- DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isEnabled
- );
+ assert.expect(2);
- this.render(``, {
- actions: {
- foo(value, event) {
- assert.ok(true, 'action was triggered');
- assert.ok(event instanceof Event, 'Native event was passed');
- },
- },
+ this.render(``, {
+ foo: action(function (value, event) {
+ assert.ok(true, 'action was triggered');
+ assert.ok(event instanceof Event, 'Native event was passed');
+ }),
});
this.triggerEvent('keyup', {
@@ -327,24 +312,16 @@ moduleFor(
});
}
- [`${testUnless(
- DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isRemoved
- )} sends an action with \`\` when is pressed`](
+ ['@test sends an action with `` when is pressed'](
assert
) {
- assert.expect(3);
- expectDeprecation(
- /Usage of the `\(action\)` helper is deprecated./,
- DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isEnabled
- );
+ assert.expect(2);
- this.render(``, {
- actions: {
- foo(value, event) {
- assert.ok(true, 'action was triggered');
- assert.ok(event instanceof Event, 'Native event was passed');
- },
- },
+ this.render(``, {
+ foo: action(function (value, event) {
+ assert.ok(true, 'action was triggered');
+ assert.ok(event instanceof Event, 'Native event was passed');
+ }),
});
this.triggerEvent('keyup', { key: 'Escape' });
diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/input-curly-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/input-curly-test.js
index 3af637cc9bb..42448fc0c9e 100644
--- a/packages/@ember/-internals/glimmer/tests/integration/components/input-curly-test.js
+++ b/packages/@ember/-internals/glimmer/tests/integration/components/input-curly-test.js
@@ -1,13 +1,6 @@
-import {
- RenderingTestCase,
- moduleFor,
- runDestroy,
- runTask,
- testUnless,
-} from 'internal-test-helpers';
+import { RenderingTestCase, moduleFor, runDestroy, runTask } from 'internal-test-helpers';
-import { set } from '@ember/object';
-import { DEPRECATIONS } from '../../../../deprecations';
+import { action, set } from '@ember/object';
class InputRenderingTest extends RenderingTestCase {
$input() {
@@ -156,22 +149,14 @@ moduleFor(
// this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce)
}
- [`${testUnless(
- DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isRemoved
- )} sends an action with \`{{input enter=(action "foo")}}\` when is pressed`](assert) {
- assert.expect(3);
- expectDeprecation(
- /Usage of the `\(action\)` helper is deprecated./,
- DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isEnabled
- );
-
- this.render(`{{input enter=(action 'foo')}}`, {
- actions: {
- foo(value, event) {
- assert.ok(true, 'action was triggered');
- assert.ok(event instanceof Event, 'Native event was passed');
- },
- },
+ ['@test sends an action with `{{input enter=this.foo}}` when is pressed'](assert) {
+ assert.expect(2);
+
+ this.render(`{{input enter=this.foo}}`, {
+ foo: action(function (value, event) {
+ assert.ok(true, 'action was triggered');
+ assert.ok(event instanceof Event, 'Native event was passed');
+ }),
});
this.triggerEvent('keyup', {