diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/classic/contextual-components-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/classic/contextual-components-test.js index 62b1ed8309b..cae118daefc 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/classic/contextual-components-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/classic/contextual-components-test.js @@ -1,6 +1,6 @@ import { moduleFor, RenderingTestCase, applyMixins, strip, runTask } from 'internal-test-helpers'; import { action } from '@ember/object'; -import { A as emberA } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { Component as EmberComponent } from '../../../utils/helpers'; @@ -246,7 +246,7 @@ moduleFor( ); this.render('{{component (component "my-link") params=this.allParams}}', { - allParams: emberA(['a', 'b']), + allParams: trackedArray(['a', 'b']), }); this.assertText('ab'); @@ -255,23 +255,23 @@ moduleFor( this.assertText('ab'); - runTask(() => this.context.get('allParams').pushObject('c')); + runTask(() => this.context.get('allParams').push('c')); this.assertText('abc'); - runTask(() => this.context.get('allParams').popObject()); + runTask(() => this.context.get('allParams').pop()); this.assertText('ab'); - runTask(() => this.context.get('allParams').clear()); + runTask(() => this.context.get('allParams').splice(0)); this.assertText(''); - runTask(() => this.context.set('allParams', emberA(['1', '2']))); + runTask(() => this.context.set('allParams', ['1', '2'])); this.assertText('12'); - runTask(() => this.context.set('allParams', emberA(['a', 'b']))); + runTask(() => this.context.set('allParams', ['a', 'b'])); this.assertText('ab'); } @@ -290,7 +290,7 @@ moduleFor( this.render( '{{#let (hash link=(component "my-link")) as |c|}}{{c.link params=this.allParams}}{{/let}}', { - allParams: emberA(['a', 'b']), + allParams: trackedArray(['a', 'b']), } ); @@ -300,23 +300,23 @@ moduleFor( this.assertText('ab'); - runTask(() => this.context.get('allParams').pushObject('c')); + runTask(() => this.context.get('allParams').push('c')); this.assertText('abc'); - runTask(() => this.context.get('allParams').popObject()); + runTask(() => this.context.get('allParams').pop()); this.assertText('ab'); - runTask(() => this.context.get('allParams').clear()); + runTask(() => this.context.get('allParams').splice(0)); this.assertText(''); - runTask(() => this.context.set('allParams', emberA(['1', '2']))); + runTask(() => this.context.set('allParams', ['1', '2'])); this.assertText('12'); - runTask(() => this.context.set('allParams', emberA(['a', 'b']))); + runTask(() => this.context.set('allParams', ['a', 'b'])); this.assertText('ab'); } diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/classic/curly-components-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/classic/curly-components-test.js index ed90907d727..5b4ac8e7fad 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/classic/curly-components-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/classic/curly-components-test.js @@ -16,7 +16,7 @@ import { tracked } from '@ember/-internals/metal'; import { on } from '@ember/object/evented'; import { service } from '@ember/service'; import { set, get, computed, observer } from '@ember/object'; -import { A as emberA } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import { Component } from '../../../utils/helpers'; import { template } from '@ember/template-compiler/runtime'; import { setComponentTemplate } from '@glimmer/manager'; @@ -1143,7 +1143,7 @@ moduleFor( ); this.render('{{sample-component names=this.things}}', { - things: emberA(['Foo', 4, 'Bar']), + things: trackedArray(['Foo', 4, 'Bar']), }); this.assertText('Foo4Bar'); @@ -1152,19 +1152,19 @@ moduleFor( this.assertText('Foo4Bar'); - runTask(() => this.context.get('things').pushObject(5)); + runTask(() => this.context.get('things').push(5)); this.assertText('Foo4Bar5'); - runTask(() => this.context.get('things').shiftObject()); + runTask(() => this.context.get('things').shift()); this.assertText('4Bar5'); - runTask(() => this.context.get('things').clear()); + runTask(() => this.context.get('things').splice(0)); this.assertText(''); - runTask(() => this.context.set('things', emberA(['Foo', 4, 'Bar']))); + runTask(() => this.context.set('things', ['Foo', 4, 'Bar'])); this.assertText('Foo4Bar'); } @@ -1882,22 +1882,22 @@ moduleFor( init() { super.init(...arguments); - this.options = emberA([]); + this.options = []; this.value = null; } updateValue() { - let newValue = this.get('options.lastObject.value'); + let newValue = this.options.at(-1)?.value; this.set('value', newValue); } registerOption(option) { - this.get('options').addObject(option); + this.options.push(option); } unregisterOption(option) { - this.get('options').removeObject(option); + this.options.splice(this.options.indexOf(option), 1); this.updateValue(); } diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/classic/life-cycle-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/classic/life-cycle-test.js index 7515d22048c..d94d4715974 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/classic/life-cycle-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/classic/life-cycle-test.js @@ -2,7 +2,7 @@ import { classes, moduleFor, RenderingTestCase, runTask, strip } from 'internal- import { schedule } from '@ember/runloop'; import { set, setProperties } from '@ember/object'; -import { A as emberA } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import { getViewElement, getViewId } from '@ember/-internals/views'; import { precompileTemplate } from '@ember/template-compilation'; import { setComponentTemplate } from '@glimmer/manager'; @@ -1469,7 +1469,7 @@ moduleFor( setComponentTemplate(precompileTemplate('{{yield}}'), NestedComponent) ); - let array = emberA([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]); + let array = trackedArray([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]); this.render( strip` @@ -1492,8 +1492,7 @@ moduleFor( this.assertText('1AB2AB3AB4AB5AB6AB7AB'); runTask(() => { - array.removeAt(2); - array.removeAt(2); + array.splice(2, 2); set(this.context, 'model.shouldShow', false); }); diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js index ac2af775699..fb5dd168b0b 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/curly-components-test.js @@ -12,7 +12,7 @@ import { tracked } from '@ember/-internals/metal'; import { alias } from '@ember/object/computed'; import Service, { service } from '@ember/service'; import EmberObject, { set, computed } from '@ember/object'; -import { A as emberA } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import { htmlSafe } from '../../utils/helpers'; import PositionalComponent from '../../utils/positional-component'; @@ -1369,7 +1369,7 @@ moduleFor( setComponentTemplate(precompileTemplate('Child: {{@item}}.'), templateOnly()) ); - let items = emberA(['Tom', 'Dick', 'Harry']); + let items = trackedArray(['Tom', 'Dick', 'Harry']); this.render('{{non-block items=this.items}}', { items }); @@ -1379,15 +1379,15 @@ moduleFor( this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); - runTask(() => this.context.get('items').pushObject('Sergio')); + runTask(() => this.context.get('items').push('Sergio')); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]'); - runTask(() => this.context.get('items').shiftObject()); + runTask(() => this.context.get('items').shift()); this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]'); - runTask(() => this.context.set('items', emberA(['Tom', 'Dick', 'Harry']))); + runTask(() => this.context.set('items', ['Tom', 'Dick', 'Harry'])); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); } diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js index 2a4d84bedd1..46c8c7db092 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js @@ -6,7 +6,7 @@ import { runTask, } from 'internal-test-helpers'; import Controller, { inject as injectController } from '@ember/controller'; -import { A as emberA } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import { RSVP } from '@ember/-internals/runtime'; import Route from '@ember/routing/route'; import NoneLocation from '@ember/routing/none-location'; @@ -1607,7 +1607,7 @@ moduleFor( controller = this; } - routeNames = emberA(['foo', 'bar', 'rar']); + routeNames = trackedArray(['foo', 'bar', 'rar']); route1 = 'bar'; route2 = 'foo'; } @@ -1649,7 +1649,7 @@ moduleFor( linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); - runTask(() => controller.routeNames.shiftObject()); + runTask(() => controller.routeNames.shift()); linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); } diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js index e1313862bba..72c318843fa 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js @@ -5,7 +5,7 @@ import { runTask, } from 'internal-test-helpers'; import Controller, { inject as injectController } from '@ember/controller'; -import { A as emberA } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import { RSVP } from '@ember/-internals/runtime'; import Route from '@ember/routing/route'; import NoneLocation from '@ember/routing/none-location'; @@ -1523,7 +1523,7 @@ moduleFor( controller = this; } - routeNames = emberA(['foo', 'bar', 'rar']); + routeNames = trackedArray(['foo', 'bar', 'rar']); route1 = 'bar'; route2 = 'foo'; } @@ -1567,7 +1567,7 @@ moduleFor( linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); - runTask(() => controller.routeNames.shiftObject()); + runTask(() => controller.routeNames.shift()); linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); } diff --git a/packages/@ember/-internals/glimmer/tests/integration/helpers/unbound-test.js b/packages/@ember/-internals/glimmer/tests/integration/helpers/unbound-test.js index a37ede590f3..bf687667e9a 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/helpers/unbound-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/helpers/unbound-test.js @@ -7,7 +7,6 @@ import { } from 'internal-test-helpers'; import { set, get, setProperties } from '@ember/object'; -import { A as emberA } from '@ember/array'; import { precompileTemplate } from '@ember/template-compilation'; import { setComponentTemplate } from '@glimmer/manager'; @@ -44,7 +43,7 @@ moduleFor( ['@test should be able to use unbound helper in #each helper']() { this.render(``, { - items: emberA(['a', 'b', 'c', 1, 2, 3]), + items: ['a', 'b', 'c', 1, 2, 3], }); this.assertText('abc123'); @@ -58,7 +57,7 @@ moduleFor( this.render( ``, { - items: emberA([{ wham: 'bam' }, { wham: 1 }]), + items: [{ wham: 'bam' }, { wham: 1 }], } ); @@ -68,11 +67,11 @@ moduleFor( this.assertText('bam1'); - runTask(() => this.context.items.setEach('wham', 'HEY')); + runTask(() => this.context.items.forEach((item) => set(item, 'wham', 'HEY'))); this.assertText('bam1'); - runTask(() => set(this.context, 'items', emberA([{ wham: 'bam' }, { wham: 1 }]))); + runTask(() => set(this.context, 'items', [{ wham: 'bam' }, { wham: 1 }])); this.assertText('bam1'); } @@ -112,7 +111,7 @@ moduleFor( } ['@test should property escape unsafe hrefs']() { - let unsafeUrls = emberA([ + let unsafeUrls = [ { name: 'Bob', url: 'javascript:bob-is-cool', @@ -125,7 +124,7 @@ moduleFor( name: 'Richard', url: 'javascript:richard-is-cool', }, - ]); + ]; this.render( ``, @@ -154,7 +153,9 @@ moduleFor( this.assertHTML(escapedHtml); - runTask(() => this.context.people.setEach('url', 'http://google.com')); + runTask(() => + this.context.people.forEach((person) => set(person, 'url', 'http://google.com')) + ); this.assertHTML(escapedHtml); @@ -447,7 +448,7 @@ moduleFor( this.render( `{{#each this.people as |person|}}{{capitalize person.firstName}} {{unbound (capitalize person.firstName)}}{{/each}}`, { - people: emberA([ + people: [ { firstName: 'shooby', lastName: 'taylor', @@ -456,7 +457,7 @@ moduleFor( firstName: 'cindy', lastName: 'taylor', }, - ]), + ], } ); @@ -466,25 +467,21 @@ moduleFor( this.assertText('SHOOBY SHOOBYCINDY CINDY'); - runTask(() => this.context.people.setEach('firstName', 'chad')); + runTask(() => this.context.people.forEach((person) => set(person, 'firstName', 'chad'))); this.assertText('CHAD SHOOBYCHAD CINDY'); runTask(() => - set( - this.context, - 'people', - emberA([ - { - firstName: 'shooby', - lastName: 'taylor', - }, - { - firstName: 'cindy', - lastName: 'taylor', - }, - ]) - ) + set(this.context, 'people', [ + { + firstName: 'shooby', + lastName: 'taylor', + }, + { + firstName: 'cindy', + lastName: 'taylor', + }, + ]) ); this.assertText('SHOOBY SHOOBYCINDY CINDY'); diff --git a/packages/@ember/-internals/glimmer/tests/integration/syntax/each-test.js b/packages/@ember/-internals/glimmer/tests/integration/syntax/each-test.js index 45dfd2be3d5..db550e99be9 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/syntax/each-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/syntax/each-test.js @@ -1144,7 +1144,7 @@ if (!ARRAY_PROXY_REMOVED) { init: function () { this._super(...arguments); - this.set('content', emberA(wrapped)); + this.set('content', wrapped); }, }).create() ); diff --git a/packages/@ember/-internals/glimmer/tests/integration/syntax/if-unless-test.js b/packages/@ember/-internals/glimmer/tests/integration/syntax/if-unless-test.js index 19b999faf7b..b8e6cc37a58 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/syntax/if-unless-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/syntax/if-unless-test.js @@ -1,6 +1,5 @@ import { RenderingTestCase, moduleFor, strip, runTask } from 'internal-test-helpers'; -import { A as emberA } from '@ember/array'; import { set } from '@ember/object'; import { precompileTemplate } from '@ember/template-compilation'; import { setComponentTemplate } from '@glimmer/manager'; @@ -65,7 +64,7 @@ moduleFor( {{else}} Nothing Here! {{/if}}`, - { cond: true, numbers: emberA([1, 2, 3]) } + { cond: true, numbers: [1, 2, 3] } ); this.assertText('123'); diff --git a/packages/@ember/-internals/glimmer/tests/integration/syntax/let-test.js b/packages/@ember/-internals/glimmer/tests/integration/syntax/let-test.js index d9f71186d8a..f1270479267 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/syntax/let-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/syntax/let-test.js @@ -9,7 +9,7 @@ import { import { DEPRECATIONS } from '@ember/-internals/deprecations'; import { get, set } from '@ember/object'; -import { A as emberA, removeAt } from '@ember/array'; +import { trackedArray } from '@ember/reactive/collections'; import ObjectProxy from '@ember/object/proxy'; moduleFor( @@ -173,7 +173,7 @@ moduleFor( this.render( `{{#let this.arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/let}}`, { - arrayThing: emberA(['Hello', ' ', 'world']), + arrayThing: trackedArray(['Hello', ' ', 'world']), } ); @@ -185,10 +185,10 @@ moduleFor( runTask(() => { let array = get(this.context, 'arrayThing'); - array.replace(0, 1, ['Goodbye']); - removeAt(array, 1); - array.insertAt(1, ', '); - array.pushObject('!'); + array.splice(0, 1, 'Goodbye'); + array.splice(1, 1); + array.splice(1, 0, ', '); + array.push('!'); }); this.assertText('Goodbye, world!'); diff --git a/packages/@ember/-internals/glimmer/tests/utils/shared-conditional-tests.js b/packages/@ember/-internals/glimmer/tests/utils/shared-conditional-tests.js index cce81d78f39..07ac2d0ecc4 100644 --- a/packages/@ember/-internals/glimmer/tests/utils/shared-conditional-tests.js +++ b/packages/@ember/-internals/glimmer/tests/utils/shared-conditional-tests.js @@ -315,6 +315,34 @@ export const ObjectTestCases = { // Testing behaviors related to arrays and array proxies export const ArrayTestCases = { ['@test it considers empty arrays falsy']() { + this.renderValues(['hello'], []); + + this.assertText('T1F2'); + + runTask(() => this.rerender()); + + this.assertText('T1F2'); + + runTask(() => set(this.context, 'cond1', [])); + + this.assertText('F1F2'); + + runTask(() => { + set(this.context, 'cond1', ['hello']); + set(this.context, 'cond2', [1]); + }); + + this.assertText('T1T2'); + + runTask(() => { + set(this.context, 'cond1', ['hello']); + set(this.context, 'cond2', []); + }); + + this.assertText('T1F2'); + }, + + ['@test it considers empty Ember arrays falsy']() { this.renderValues(emberA(['hello']), emberA()); this.assertText('T1F2'); @@ -335,15 +363,15 @@ export const ArrayTestCases = { this.assertText('T1T2'); runTask(() => { - set(this.context, 'cond1', emberA(['hello'])); - set(this.context, 'cond2', emberA()); + set(this.context, 'cond1', ['hello']); + set(this.context, 'cond2', []); }); this.assertText('T1F2'); }, [`${testUnless(ARRAY_PROXY_REMOVED)} @test it considers array proxies without content falsy`]() { - this.renderValues(arrayProxy({ content: emberA(['hello']) }), arrayProxy({ content: null })); + this.renderValues(arrayProxy({ content: ['hello'] }), arrayProxy({ content: null })); this.assertText('T1F2'); @@ -359,14 +387,14 @@ export const ArrayTestCases = { this.assertText('F1F2'); runTask(() => { - set(this.context, 'cond1.content', emberA(['hello'])); - set(this.context, 'cond2.content', emberA([1])); + set(this.context, 'cond1.content', ['hello']); + set(this.context, 'cond2.content', [1]); }); this.assertText('T1T2'); runTask(() => { - set(this.context, 'cond1', arrayProxy({ content: emberA(['hello']) })); + set(this.context, 'cond1', arrayProxy({ content: ['hello'] })); set(this.context, 'cond2', arrayProxy({ content: null })); }); @@ -397,8 +425,8 @@ export const ArrayTestCases = { this.assertText('T1T2'); runTask(() => { - set(this.context, 'cond1', arrayProxy({ content: emberA(['hello']) })); - set(this.context, 'cond2', arrayProxy({ content: emberA() })); + set(this.context, 'cond1', arrayProxy({ content: ['hello'] })); + set(this.context, 'cond2', arrayProxy({ content: [] })); }); this.assertText('T1F2'); diff --git a/packages/@ember/-internals/runtime/tests/core/is_array_test.js b/packages/@ember/-internals/runtime/tests/core/is_array_test.js index a11de641cb0..0e83d6cadb2 100644 --- a/packages/@ember/-internals/runtime/tests/core/is_array_test.js +++ b/packages/@ember/-internals/runtime/tests/core/is_array_test.js @@ -1,4 +1,4 @@ -import { A as emberA, isArray } from '@ember/array'; +import { isArray } from '@ember/array'; import ArrayProxy from '@ember/array/proxy'; import EmberObject from '@ember/object'; import { window } from '@ember/-internals/browser-environment'; @@ -38,7 +38,7 @@ moduleFor( )} @test Ember.isArray with an ArrayProxy`](assert) { expectDeprecation(/`ArrayProxy` is deprecated/, DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isEnabled); - let arrayProxy = ArrayProxy.create({ content: emberA() }); + let arrayProxy = ArrayProxy.create({ content: [] }); assert.equal(isArray(arrayProxy), true, 'ArrayProxy'); } diff --git a/packages/@ember/-internals/runtime/tests/core/is_empty_test.js b/packages/@ember/-internals/runtime/tests/core/is_empty_test.js index f339fa3e28a..a6ee37c8b15 100644 --- a/packages/@ember/-internals/runtime/tests/core/is_empty_test.js +++ b/packages/@ember/-internals/runtime/tests/core/is_empty_test.js @@ -1,7 +1,6 @@ import { isEmpty } from '@ember/utils'; import ArrayProxy from '@ember/array/proxy'; import ObjectProxy from '@ember/object/proxy'; -import { A as emberA } from '@ember/array'; import { moduleFor, AbstractTestCase, expectDeprecation, testUnless } from 'internal-test-helpers'; import { DEPRECATIONS } from '@ember/-internals/deprecations'; @@ -17,7 +16,7 @@ moduleFor( expectDeprecation(/`ArrayProxy` is deprecated/, DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isEnabled); - let arrayProxy = ArrayProxy.create({ content: emberA() }); + let arrayProxy = ArrayProxy.create({ content: [] }); assert.equal(true, isEmpty(arrayProxy), 'for an ArrayProxy that has empty content'); } @@ -33,7 +32,7 @@ moduleFor( DEPRECATIONS.DEPRECATE_OBJECT_PROXY.isEnabled ); - let arrayProxy = ArrayProxy.create({ content: emberA([]) }); + let arrayProxy = ArrayProxy.create({ content: [] }); let objectProxy = ObjectProxy.create({ content: arrayProxy }); assert.equal( diff --git a/packages/@ember/-internals/runtime/tests/system/array_proxy/watching_and_listening_test.js b/packages/@ember/-internals/runtime/tests/system/array_proxy/watching_and_listening_test.js index 9dac1d8fb36..6c5fcb01d5c 100644 --- a/packages/@ember/-internals/runtime/tests/system/array_proxy/watching_and_listening_test.js +++ b/packages/@ember/-internals/runtime/tests/system/array_proxy/watching_and_listening_test.js @@ -1,6 +1,5 @@ import { peekMeta } from '@ember/-internals/meta'; import ArrayProxy from '@ember/array/proxy'; -import { A } from '@ember/array'; import { moduleFor, AbstractTestCase, expectDeprecation, testUnless } from 'internal-test-helpers'; import { DEPRECATIONS } from '@ember/-internals/deprecations'; @@ -24,7 +23,7 @@ moduleFor( [`${testUnless(DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isRemoved)} @test setting 'content' adds listeners correctly`]( assert ) { - let content = A(); + let content = []; let proxy = ArrayProxy.create(); assert.deepEqual(sortedListenersFor(content, '@array:before'), []); @@ -43,8 +42,8 @@ moduleFor( [`${testUnless(DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isRemoved)} @test changing 'content' adds and removes listeners correctly`]( assert ) { - let content1 = A(); - let content2 = A(); + let content1 = []; + let content2 = []; let proxy = ArrayProxy.create({ content: content1 }); assert.deepEqual(sortedListenersFor(content1, '@array:before'), []); diff --git a/packages/@ember/object/tests/observable_test.js b/packages/@ember/object/tests/observable_test.js index 8b6ce290204..ccb78081bc8 100644 --- a/packages/@ember/object/tests/observable_test.js +++ b/packages/@ember/object/tests/observable_test.js @@ -642,7 +642,7 @@ moduleFor( toggleVal: true, observedProperty: 'beingWatched', testRemove: 'observerToBeRemoved', - normalArray: emberA([1, 2, 3, 4, 5]), + normalArray: [1, 2, 3, 4, 5], }); } @@ -720,6 +720,10 @@ moduleFor( } async ['@test should notify array observer when array changes'](assert) { + object.set('normalArray', emberA([1, 2, 3, 4, 5])); + await runLoopSettled(); + object.abnormal = 'zeroValue'; + get(object, 'normalArray').replace(0, 0, [6]); await runLoopSettled(); diff --git a/packages/ember/tests/homepage_example_test.js b/packages/ember/tests/homepage_example_test.js index 8f9de393b67..4d9f5bda588 100644 --- a/packages/ember/tests/homepage_example_test.js +++ b/packages/ember/tests/homepage_example_test.js @@ -1,6 +1,5 @@ import Route from '@ember/routing/route'; import EmberObject, { computed } from '@ember/object'; -import { A as emberA } from '@ember/array'; import { moduleFor, ApplicationTestCase } from 'internal-test-helpers'; import { precompileTemplate } from '@ember/template-compilation'; @@ -30,10 +29,10 @@ moduleFor( 'route:index', class extends Route { model() { - return emberA([ + return [ Person.create({ firstName: 'Tom', lastName: 'Dale' }), Person.create({ firstName: 'Yehuda', lastName: 'Katz' }), - ]); + ]; } } ); diff --git a/packages/ember/tests/routing/model_loading_test.js b/packages/ember/tests/routing/model_loading_test.js index 733af89f554..8518605838f 100644 --- a/packages/ember/tests/routing/model_loading_test.js +++ b/packages/ember/tests/routing/model_loading_test.js @@ -2,7 +2,6 @@ import Route from '@ember/routing/route'; import Controller from '@ember/controller'; import EmberObject from '@ember/object'; -import { A as emberA } from '@ember/array'; import { moduleFor, ApplicationTestCase, getTextOf } from 'internal-test-helpers'; import { run } from '@ember/runloop'; import { action, computed, set } from '@ember/object'; @@ -731,7 +730,7 @@ moduleFor( ['@test Parent route context change'](assert) { let editCount = 0; - let editedPostIds = emberA(); + let editedPostIds = []; this.add('template:application', precompileTemplate('{{outlet}}')); this.add('template:posts', precompileTemplate('{{outlet}}')); diff --git a/packages/ember/tests/routing/query_params_test.js b/packages/ember/tests/routing/query_params_test.js index 76a0214c0ed..5b9c265cf2a 100644 --- a/packages/ember/tests/routing/query_params_test.js +++ b/packages/ember/tests/routing/query_params_test.js @@ -2,7 +2,6 @@ import Controller from '@ember/controller'; import { dasherize } from '@ember/-internals/string'; import EmberObject, { action, get, computed } from '@ember/object'; import { RSVP } from '@ember/-internals/runtime'; -import { A as emberA } from '@ember/array'; import { run } from '@ember/runloop'; import { peekMeta } from '@ember/-internals/meta'; import { tracked } from '@ember/-internals/metal'; @@ -1322,7 +1321,7 @@ moduleFor( this.route('home', { path: '/' }); }); - this.setSingleQPController('home', 'foo', emberA()); + this.setSingleQPController('home', 'foo', []); await this.visitAndAssert('/'); let controller = this.getController('home'); @@ -1385,13 +1384,13 @@ moduleFor( } ); - this.setSingleQPController('home', 'foo', emberA([1])); + this.setSingleQPController('home', 'foo', [1]); await this.visitAndAssert('/'); assert.equal(modelCount, 1); let controller = this.getController('home'); - await this.setAndFlush(controller, 'model', emberA([1])); + await this.setAndFlush(controller, 'model', [1]); assert.equal(modelCount, 1); this.assertCurrentPath('/'); @@ -1444,7 +1443,7 @@ moduleFor( assert.deepEqual(controller.get('foo'), [1, 2]); this.assertCurrentPath('/home'); - await this.setAndFlush(controller, 'foo', emberA([1, 3])); + await this.setAndFlush(controller, 'foo', [1, 3]); this.assertCurrentPath('/home?foo=%5B1%2C3%5D'); await this.transitionTo('/home'); @@ -1455,7 +1454,7 @@ moduleFor( await this.setAndFlush(controller, 'foo', null); this.assertCurrentPath('/home', 'Setting property to null'); - await this.setAndFlush(controller, 'foo', emberA([1, 3])); + await this.setAndFlush(controller, 'foo', [1, 3]); this.assertCurrentPath('/home?foo=%5B1%2C3%5D'); await this.setAndFlush(controller, 'foo', undefined); diff --git a/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js b/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js index c369825e7c9..1526416cad4 100644 --- a/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js +++ b/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js @@ -1,5 +1,4 @@ import Controller from '@ember/controller'; -import { A as emberA } from '@ember/array'; import Route from '@ember/routing/route'; import { computed } from '@ember/object'; import { precompileTemplate } from '@ember/template-compilation'; @@ -39,7 +38,7 @@ moduleFor( this.route('about'); }); - let articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + let articles = [{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]; this.add( 'controller:application', @@ -62,7 +61,7 @@ moduleFor( ); self.expectedModelHookParams = null; } - return articles.findBy('id', params.id); + return articles.find((article) => article.id === params.id); } } ); @@ -385,7 +384,7 @@ moduleFor( this.route('about'); }); - let site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + let site_articles = [{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]; this.add( 'controller:application', @@ -408,7 +407,7 @@ moduleFor( ); self.expectedModelHookParams = null; } - return site_articles.findBy('id', params.id); + return site_articles.find((article) => article.id === params.id); } } ); @@ -733,8 +732,8 @@ moduleFor( }); }); - let sites = emberA([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]); - let site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + let sites = [{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]; + let site_articles = [{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]; this.add( 'controller:application', @@ -776,7 +775,7 @@ moduleFor( ); self.expectedSiteModelHookParams = null; } - return sites.findBy('id', params.site_id); + return sites.find((site) => site.id === params.site_id); } } ); @@ -793,7 +792,7 @@ moduleFor( ); self.expectedArticleModelHookParams = null; } - return site_articles.findBy('id', params.article_id); + return site_articles.find((article) => article.id === params.article_id); } } ); diff --git a/packages/ember/tests/routing/template_rendering_test.js b/packages/ember/tests/routing/template_rendering_test.js index 00bd20b818d..8e036ca42cd 100644 --- a/packages/ember/tests/routing/template_rendering_test.js +++ b/packages/ember/tests/routing/template_rendering_test.js @@ -2,7 +2,6 @@ import Route from '@ember/routing/route'; import Controller from '@ember/controller'; import EmberObject from '@ember/object'; -import { A as emberA } from '@ember/array'; import { moduleFor, ApplicationTestCase, @@ -185,7 +184,7 @@ moduleFor( 'route:application', class extends Route { model() { - return emberA(); + return []; } } );