Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { DEBUG } from '@glimmer/env';
import { moduleFor, RenderingTestCase, applyMixins, strip, runTask } from 'internal-test-helpers';
import {
moduleFor,
RenderingTestCase,
applyMixins,
strip,
runTask,
expectDeprecation,
emberAWithoutDeprecation,
} from 'internal-test-helpers';

import { isEmpty } from '@ember/utils';
import { action } from '@ember/object';
import { A as emberA } from '@ember/array';

import { Component } from '../../utils/helpers';

Expand Down Expand Up @@ -1160,7 +1167,7 @@ moduleFor(
});

this.render('{{component (component "my-link") params=this.allParams}}', {
allParams: emberA(['a', 'b']),
allParams: emberAWithoutDeprecation(['a', 'b']),
});

this.assertText('ab');
Expand All @@ -1169,23 +1176,29 @@ moduleFor(

this.assertText('ab');

runTask(() => this.context.get('allParams').pushObject('c'));
expectDeprecation(() => {
runTask(() => this.context.get('allParams').pushObject('c'));
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('abc');

runTask(() => this.context.get('allParams').popObject());
expectDeprecation(() => {
runTask(() => this.context.get('allParams').popObject());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('ab');

runTask(() => this.context.get('allParams').clear());
expectDeprecation(() => {
runTask(() => this.context.get('allParams').clear());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('');

runTask(() => this.context.set('allParams', emberA(['1', '2'])));
runTask(() => this.context.set('allParams', emberAWithoutDeprecation(['1', '2'])));

this.assertText('12');

runTask(() => this.context.set('allParams', emberA(['a', 'b'])));
runTask(() => this.context.set('allParams', emberAWithoutDeprecation(['a', 'b'])));

this.assertText('ab');
}
Expand All @@ -1201,7 +1214,7 @@ moduleFor(
this.render(
'{{#let (hash link=(component "my-link")) as |c|}}{{c.link params=this.allParams}}{{/let}}',
{
allParams: emberA(['a', 'b']),
allParams: emberAWithoutDeprecation(['a', 'b']),
}
);

Expand All @@ -1211,23 +1224,29 @@ moduleFor(

this.assertText('ab');

runTask(() => this.context.get('allParams').pushObject('c'));
expectDeprecation(() => {
runTask(() => this.context.get('allParams').pushObject('c'));
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('abc');

runTask(() => this.context.get('allParams').popObject());
expectDeprecation(() => {
runTask(() => this.context.get('allParams').popObject());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('ab');

runTask(() => this.context.get('allParams').clear());
expectDeprecation(() => {
runTask(() => this.context.get('allParams').clear());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('');

runTask(() => this.context.set('allParams', emberA(['1', '2'])));
runTask(() => this.context.set('allParams', emberAWithoutDeprecation(['1', '2'])));

this.assertText('12');

runTask(() => this.context.set('allParams', emberA(['a', 'b'])));
runTask(() => this.context.set('allParams', emberAWithoutDeprecation(['a', 'b'])));

this.assertText('ab');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
equalsElement,
runTask,
runLoopSettled,
expectDeprecation,
emberAWithoutDeprecation as emberA,
} from 'internal-test-helpers';

import { action } from '@ember/object';
Expand All @@ -17,7 +19,6 @@ import { alias } from '@ember/object/computed';
import { on } from '@ember/object/evented';
import Service, { service } from '@ember/service';
import EmberObject, { set, get, computed, observer } from '@ember/object';
import { A as emberA } from '@ember/array';

import { Component, compile, htmlSafe } from '../../utils/helpers';
import { backtrackingMessageFor } from '../../utils/debug-stack';
Expand Down Expand Up @@ -1714,15 +1715,21 @@ moduleFor(

this.assertText('Foo4Bar');

runTask(() => this.context.get('things').pushObject(5));
expectDeprecation(() => {
runTask(() => this.context.get('things').pushObject(5));
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('Foo4Bar5');

runTask(() => this.context.get('things').shiftObject());
expectDeprecation(() => {
runTask(() => this.context.get('things').shiftObject());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('4Bar5');

runTask(() => this.context.get('things').clear());
expectDeprecation(() => {
runTask(() => this.context.get('things').clear());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('');

Expand Down Expand Up @@ -2574,11 +2581,15 @@ moduleFor(

this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]');

runTask(() => this.context.get('items').pushObject('Sergio'));
expectDeprecation(() => {
runTask(() => this.context.get('items').pushObject('Sergio'));
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]');

runTask(() => this.context.get('items').shiftObject());
expectDeprecation(() => {
runTask(() => this.context.get('items').shiftObject());
}, /Usage of Ember.Array methods is deprecated/);

this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]');

Expand Down Expand Up @@ -3012,17 +3023,25 @@ moduleFor(
}

updateValue() {
let newValue = this.get('options.lastObject.value');
let newValue;

expectDeprecation(() => {
newValue = this.get('options.lastObject.value');
}, /Usage of Ember.Array methods is deprecated/);

this.set('value', newValue);
}

registerOption(option) {
this.get('options').addObject(option);
expectDeprecation(() => {
this.get('options').addObject(option);
}, /Usage of Ember.Array methods is deprecated/);
}

unregisterOption(option) {
this.get('options').removeObject(option);
expectDeprecation(() => {
this.get('options').removeObject(option);
}, /Usage of Ember.Array methods is deprecated/);

this.updateValue();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { classes, moduleFor, RenderingTestCase, runTask, strip } from 'internal-test-helpers';
import {
classes,
emberAWithoutDeprecation,
expectDeprecation,
moduleFor,
RenderingTestCase,
runTask,
strip,
} from 'internal-test-helpers';

import { schedule } from '@ember/runloop';
import { set, setProperties } from '@ember/object';
import { A as emberA } from '@ember/array';
import { getViewElement, getViewId } from '@ember/-internals/views';

import { Component } from '../../utils/helpers';
Expand Down Expand Up @@ -1464,7 +1471,7 @@ moduleFor(
template: NestedTemplate,
});

let array = emberA([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]);
let array = emberAWithoutDeprecation([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]);

this.render(
strip`
Expand All @@ -1487,8 +1494,10 @@ moduleFor(
this.assertText('1AB2AB3AB4AB5AB6AB7AB');

runTask(() => {
array.removeAt(2);
array.removeAt(2);
expectDeprecation(() => {
array.removeAt(2);
array.removeAt(2);
}, /Usage of Ember.Array methods is deprecated/);
set(this.context, 'model.shouldShow', false);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
ApplicationTestCase,
ModuleBasedTestResolver,
expectDeprecation,
moduleFor,
runTask,
} from 'internal-test-helpers';
import Controller, { inject as injectController } from '@ember/controller';
import { A as emberA } from '@ember/array';

Check failure on line 9 in packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js

View workflow job for this annotation

GitHub Actions / Linting

'emberA' is defined but never used
import { RSVP } from '@ember/-internals/runtime';
import Route from '@ember/routing/route';
import NoneLocation from '@ember/routing/none-location';
Expand All @@ -13,6 +14,7 @@
import Engine from '@ember/engine';
import { DEBUG } from '@glimmer/env';
import { compile } from '../../../utils/helpers';
import { emberAWithoutDeprecation } from '@ember/routing/-internals';

// IE includes the host name
function normalizeUrl(url) {
Expand Down Expand Up @@ -1536,7 +1538,7 @@
controller = this;
}

routeNames = emberA(['foo', 'bar', 'rar']);
routeNames = emberAWithoutDeprecation(['foo', 'bar', 'rar']);
route1 = 'bar';
route2 = 'foo';
}
Expand Down Expand Up @@ -1579,7 +1581,9 @@

linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']);

runTask(() => controller.routeNames.shiftObject());
expectDeprecation(() => {
runTask(() => controller.routeNames.shiftObject());
}, /Usage of Ember.Array methods is deprecated/);

linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
ApplicationTestCase,
ModuleBasedTestResolver,
emberAWithoutDeprecation,
expectDeprecation,
moduleFor,
runTask,
} from 'internal-test-helpers';
import Controller, { inject as injectController } from '@ember/controller';
import { A as emberA } from '@ember/array';

Check failure on line 10 in packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js

View workflow job for this annotation

GitHub Actions / Linting

'emberA' is defined but never used
import { RSVP } from '@ember/-internals/runtime';
import Route from '@ember/routing/route';
import NoneLocation from '@ember/routing/none-location';
Expand Down Expand Up @@ -1447,7 +1449,7 @@
controller = this;
}

routeNames = emberA(['foo', 'bar', 'rar']);
routeNames = emberAWithoutDeprecation(['foo', 'bar', 'rar']);
route1 = 'bar';
route2 = 'foo';
}
Expand Down Expand Up @@ -1490,7 +1492,9 @@

linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']);

runTask(() => controller.routeNames.shiftObject());
expectDeprecation(() => {
runTask(() => controller.routeNames.shiftObject());
}, /Usage of Ember.Array methods is deprecated/);

linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import EmberObject from '@ember/object';
import { A } from '@ember/array';
import ArrayProxy from '@ember/array/proxy';
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
import { tracked } from '@ember/-internals/metal';
import { computed, get, set } from '@ember/object';
import { Promise } from 'rsvp';
import { moduleFor, RenderingTestCase, strip, runTask } from 'internal-test-helpers';
import {
moduleFor,
RenderingTestCase,
strip,
runTask,
expectDeprecation,
emberAWithoutDeprecation,
} from 'internal-test-helpers';
import GlimmerishComponent from '../../utils/glimmerish-component';
import { Component } from '../../utils/helpers';

Expand Down Expand Up @@ -91,9 +97,11 @@ moduleFor(
class LoaderComponent extends GlimmerishComponent {
get data() {
if (!this._data) {
this._data = PromiseArray.create({
promise: Promise.resolve([1, 2, 3]),
});
expectDeprecation(() => {
this._data = PromiseArray.create({
promise: Promise.resolve([1, 2, 3]),
});
}, /Usage of ArrayProxy is deprecated/);
}

return this._data;
Expand All @@ -114,11 +122,15 @@ moduleFor(
class LoaderComponent extends GlimmerishComponent {
get data() {
if (!this._data) {
this._data = ArrayProxy.create({
content: A(),
});

this._data.content.pushObjects([1, 2, 3]);
expectDeprecation(() => {
this._data = ArrayProxy.create({
content: emberAWithoutDeprecation(),
});
}, /Usage of ArrayProxy is deprecated/);

expectDeprecation(() => {
this._data.content.pushObjects([1, 2, 3]);
}, /Usage of Ember.Array methods is deprecated/);
}

return this._data;
Expand Down Expand Up @@ -242,9 +254,13 @@ moduleFor(

'@test array properties rerender when updated'() {
class NumListComponent extends Component {
@tracked numbers = A([1, 2, 3]);
@tracked numbers = emberAWithoutDeprecation([1, 2, 3]);

addNumber = () => this.numbers.pushObject(4);
addNumber = () => {
expectDeprecation(() => {
this.numbers.pushObject(4);
}, /Usage of Ember.Array methods is deprecated/);
};
}

this.registerComponent('num-list', {
Expand Down
Loading
Loading