Skip to content
Merged
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,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';
Expand Down Expand Up @@ -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');
Expand All @@ -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');
}
Expand All @@ -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']),
}
);

Expand All @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand All @@ -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');
}
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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`
Expand All @@ -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);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });

Expand All @@ -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.]');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1607,7 +1607,7 @@ moduleFor(
controller = this;
}

routeNames = emberA(['foo', 'bar', 'rar']);
routeNames = trackedArray(['foo', 'bar', 'rar']);
route1 = 'bar';
route2 = 'foo';
}
Expand Down Expand Up @@ -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']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1523,7 +1523,7 @@ moduleFor(
controller = this;
}

routeNames = emberA(['foo', 'bar', 'rar']);
routeNames = trackedArray(['foo', 'bar', 'rar']);
route1 = 'bar';
route2 = 'foo';
}
Expand Down Expand Up @@ -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']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -44,7 +43,7 @@ moduleFor(

['@test should be able to use unbound helper in #each helper']() {
this.render(`<ul>{{#each this.items as |item|}}<li>{{unbound item}}</li>{{/each}}</ul>`, {
items: emberA(['a', 'b', 'c', 1, 2, 3]),
items: ['a', 'b', 'c', 1, 2, 3],
});

this.assertText('abc123');
Expand All @@ -58,7 +57,7 @@ moduleFor(
this.render(
`<ul>{{#each this.items as |item|}}<li>{{unbound item.wham}}</li>{{/each}}</ul>`,
{
items: emberA([{ wham: 'bam' }, { wham: 1 }]),
items: [{ wham: 'bam' }, { wham: 1 }],
}
);

Expand All @@ -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');
}
Expand Down Expand Up @@ -112,7 +111,7 @@ moduleFor(
}

['@test should property escape unsafe hrefs']() {
let unsafeUrls = emberA([
let unsafeUrls = [
{
name: 'Bob',
url: 'javascript:bob-is-cool',
Expand All @@ -125,7 +124,7 @@ moduleFor(
name: 'Richard',
url: 'javascript:richard-is-cool',
},
]);
];

this.render(
`<ul>{{#each this.people as |person|}}<li><a href="{{unbound person.url}}">{{person.name}}</a></li>{{/each}}</ul>`,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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',
Expand All @@ -456,7 +457,7 @@ moduleFor(
firstName: 'cindy',
lastName: 'taylor',
},
]),
],
}
);

Expand All @@ -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');
Expand Down
Loading
Loading