Skip to content

Commit

Permalink
[REFACTOR] support isEnabled in expectDeprecation directly
Browse files Browse the repository at this point in the history
  • Loading branch information
chancancode committed Feb 13, 2021
1 parent d2b8b58 commit 4bb3713
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 247 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -103,6 +103,7 @@ module.exports = {
expectDeprecation: true,
expectDeprecationAsync: true,
expectNoDeprecation: true,
expectNoDeprecationAsync: true,
expectWarning: true,
expectNoWarning: true,
ignoreAssertion: true,
Expand Down
@@ -1,10 +1,4 @@
import {
RenderingTestCase,
maybeExpectDeprecation,
moduleFor,
runDestroy,
runTask,
} from 'internal-test-helpers';
import { RenderingTestCase, moduleFor, runDestroy, runTask } from 'internal-test-helpers';
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { action } from '@ember/object';
import { assign } from '@ember/polyfills';
Expand Down Expand Up @@ -151,12 +145,12 @@ class InputRenderingTest extends RenderingTestCase {
<TestComponent ${argsFor('custom')} />
`;

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(template, { actions });
},
/Passing the `@(touchStart|touchMove|touchEnd|touchCancel|keyDown|keyUp|keyPress|mouseDown|mouseUp|contextMenu|click|doubleClick|focusIn|focusOut|submit|input|change|dragStart|drag|dragEnter|dragLeave|dragOver|drop|dragEnd|mouseEnter|mouseLeave|mouseMove|focus-in|focus-out|key-press|key-up|key-down)` argument to <Input> is deprecated\./
/Passing the `@(touchStart|touchMove|touchEnd|touchCancel|keyDown|keyUp|keyPress|mouseDown|mouseUp|contextMenu|click|doubleClick|focusIn|focusOut|submit|input|change|dragStart|drag|dragEnter|dragLeave|dragOver|drop|dragEnd|mouseEnter|mouseLeave|mouseMove|focus-in|focus-out|key-press|key-up|key-down)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assert.ok(this.$('input').length === 2);
Expand Down Expand Up @@ -328,8 +322,7 @@ moduleFor(
}

['@test [DEPRECATED] dynamic attributes (named argument)']() {
maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(
`<Input @type="text" @value={{this.value}}
Expand All @@ -355,7 +348,8 @@ moduleFor(
}
);
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertNotDisabled();
Expand All @@ -382,8 +376,7 @@ moduleFor(
// this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce)

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
runTask(() => {
set(this.context, 'value', 'Updated value');
Expand All @@ -397,7 +390,8 @@ moduleFor(
// set(this.context, 'tabindex', 31); //NOTE: failing in IE (TEST_SUITE=sauce)
});
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertDisabled();
Expand All @@ -411,8 +405,7 @@ moduleFor(
// this.assertAttr('size', '21'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '31'); //NOTE: failing in IE (TEST_SUITE=sauce)

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
runTask(() => {
set(this.context, 'value', 'Original value');
Expand All @@ -426,7 +419,8 @@ moduleFor(
// set(this.context, 'tabindex', 30); //NOTE: failing in IE (TEST_SUITE=sauce)
});
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertNotDisabled();
Expand Down Expand Up @@ -481,23 +475,23 @@ moduleFor(
}

['@test [DEPRECATED] static attributes (named argument)']() {
maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(
`<Input @type="text" @value="Original value"
@elementId="test-input"
@ariaRole="search"
@disabled={{true}}
@placeholder="Original placeholder"
@name="original-name"
@maxlength={{10}}
@minlength={{5}}
@size={{20}}
@tabindex={{30}}/>`
@elementId="test-input"
@ariaRole="search"
@disabled={{true}}
@placeholder="Original placeholder"
@name="original-name"
@maxlength={{10}}
@minlength={{5}}
@size={{20}}
@tabindex={{30}}/>`
);
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|minlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertDisabled();
Expand Down Expand Up @@ -637,8 +631,7 @@ moduleFor(
['@test sends an action with `<Input @key-press={{action "foo"}} />` is pressed'](assert) {
let triggered = 0;

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(`<Input @value={{this.value}} @key-press={{action 'foo'}} />`, {
value: 'initial',
Expand All @@ -656,7 +649,8 @@ moduleFor(
},
});
},
/Passing the `@key-press` argument to <Input> is deprecated\./
/Passing the `@key-press` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.triggerEvent('keypress', { key: 'A' });
Expand All @@ -678,10 +672,10 @@ moduleFor(
template: `<Input @bubbles={{true}} />`,
});

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => this.render(`<Parent />`),
'Passing the `@bubbles` argument to <Input> is deprecated.'
'Passing the `@bubbles` argument to <Input> is deprecated.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.triggerEvent('change');
Expand All @@ -692,8 +686,7 @@ moduleFor(
['@test [DEPRECATED] triggers `focus-in` when focused'](assert) {
let wasFocused = false;

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(`<Input @focus-in={{action 'foo'}} />`, {
actions: {
Expand All @@ -703,7 +696,8 @@ moduleFor(
},
});
},
/Passing the `@focus-in` argument to <Input> is deprecated\./
/Passing the `@focus-in` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

runTask(() => {
Expand Down Expand Up @@ -810,8 +804,7 @@ moduleFor(
) {
let triggered = 0;

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(`<Input @key-down={{action 'foo'}} />`, {
actions: {
Expand All @@ -827,7 +820,8 @@ moduleFor(
},
});
},
/Passing the `@key-down` argument to <Input> is deprecated\./
/Passing the `@key-down` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.triggerEvent('keydown', { key: 'A' });
Expand Down Expand Up @@ -865,8 +859,7 @@ moduleFor(
) {
let triggered = 0;

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(`<Input @key-up={{action 'foo'}} />`, {
actions: {
Expand All @@ -882,7 +875,8 @@ moduleFor(
},
});
},
/Passing the `@key-up` argument to <Input> is deprecated\./
/Passing the `@key-up` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.triggerEvent('keyup', { key: 'A' });
Expand All @@ -902,16 +896,16 @@ moduleFor(
}

['@test [DEPRECATED] triggers a method with `<Input @key-up={{this.didTrigger}} />`'](assert) {
maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(`<Input @key-up={{this.didTrigger}} />`, {
didTrigger: action(function () {
assert.ok(true, 'action was triggered');
}),
});
},
/Passing the `@key-up` argument to <Input> is deprecated\./
/Passing the `@key-up` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.triggerEvent('keyup', { key: 'A' });
Expand Down Expand Up @@ -1045,8 +1039,7 @@ moduleFor(
}

['@test [DEPRECATED] dynamic attributes (named argument)']() {
maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(
`<Input @type='checkbox' @checked={{this.checked}}
Expand All @@ -1064,7 +1057,8 @@ moduleFor(
}
);
},
/Passing the `@(elementId|ariaRole|disabled|name|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|name|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertSingleCheckbox();
Expand All @@ -1081,8 +1075,7 @@ moduleFor(
this.assertAttr('name', 'original-name');
this.assertAttr('tabindex', '10');

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
runTask(() => {
set(this.context, 'role', 'radio');
Expand All @@ -1091,7 +1084,8 @@ moduleFor(
set(this.context, 'tabindex', 11);
});
},
/Passing the `@(elementId|ariaRole|disabled|name|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|name|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertSingleCheckbox();
Expand All @@ -1100,8 +1094,7 @@ moduleFor(
this.assertAttr('name', 'updated-name');
this.assertAttr('tabindex', '11');

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
runTask(() => {
set(this.context, 'role', 'checkbox');
Expand All @@ -1110,7 +1103,8 @@ moduleFor(
set(this.context, 'tabindex', 10);
});
},
/Passing the `@(elementId|ariaRole|disabled|name|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|name|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertSingleCheckbox();
Expand Down Expand Up @@ -1204,14 +1198,14 @@ moduleFor(
}

['@test [DEPRECATED] with static values (named argument)']() {
maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(
`<Input @type="checkbox" @checked={{false}} @ariaRole="radio" @disabled={{false}} @tabindex={{10}} @name="original-name" />`
);
},
/Passing the `@(elementId|ariaRole|disabled|tabindex|name)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|tabindex|name)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertSingleCheckbox();
Expand Down Expand Up @@ -1318,8 +1312,7 @@ moduleFor(
['@test [DEPRECATED] null values (named argument)']() {
let attributes = ['role', 'disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex'];

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
this.render(
`<Input @type="text" @value={{this.value}}
Expand All @@ -1342,7 +1335,8 @@ moduleFor(
}
);
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertValue('');
Expand All @@ -1353,8 +1347,7 @@ moduleFor(
this.assertValue('');
this.assertAllAttrs(attributes, undefined);

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
runTask(() => {
set(this.context, 'role', 'search');
Expand All @@ -1367,7 +1360,8 @@ moduleFor(
set(this.context, 'tabindex', 31);
});
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertDisabled();
Expand All @@ -1379,8 +1373,7 @@ moduleFor(
this.assertAttr('size', '21');
this.assertAttr('tabindex', '31');

maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => {
runTask(() => {
set(this.context, 'role', null);
Expand All @@ -1393,7 +1386,8 @@ moduleFor(
set(this.context, 'tabindex', null);
});
},
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|size|tabindex)` argument to <Input> is deprecated\./
/Passing the `@(elementId|ariaRole|disabled|placeholder|name|maxlength|size|tabindex)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

this.assertAttr('disabled', undefined);
Expand Down Expand Up @@ -1468,10 +1462,10 @@ function InputAttributesTest(attrs) {
`[GH#15675] Components test: <Input ${attrs} />`,
class extends InputAttributesTest(attrs) {
renderInput(value = 25) {
maybeExpectDeprecation(
EMBER_MODERNIZED_BUILT_IN_COMPONENTS,
expectDeprecation(
() => super.renderInput(value),
/Passing the `@(min|max)` argument to <Input> is deprecated\./
/Passing the `@(min|max)` argument to <Input> is deprecated\./,
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);
}
}
Expand Down

0 comments on commit 4bb3713

Please sign in to comment.