Skip to content

Commit 12bcfcd

Browse files
committed
Update tests
1 parent 34a8f1b commit 12bcfcd

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

packages/@glimmer-workspace/integration-tests/test/collections/array-test.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { TrackedArray } from '@glimmer/validator';
1+
import { trackedArray } from '@glimmer/validator';
2+
import type { Dict, Owner } from '@glimmer/interfaces';
23
import {
34
GlimmerishComponent as Component,
45
jitSuite,
@@ -42,13 +43,13 @@ const ARRAY_SETTER_METHODS = [
4243
];
4344

4445
class TrackedArrayTest extends RenderTest {
45-
static suiteName = `TrackedArray (rendering)`;
46+
static suiteName = `trackedArray() (rendering)`;
4647

4748
@test
4849
'getting and setting an index'() {
4950
this.assertReactivity(
5051
class extends Component {
51-
arr = new TrackedArray(['foo']);
52+
arr = trackedArray(['foo']);
5253

5354
get value() {
5455
return this.arr[0];
@@ -65,10 +66,10 @@ class TrackedArrayTest extends RenderTest {
6566
'Can push into a newly created TrackedArray during construction'() {
6667
this.assertReactivity(
6768
class extends Component {
68-
arr = new TrackedArray<string>();
69+
arr = trackedArray();
6970

70-
constructor(...args: unknown[]) {
71-
super(...args);
71+
constructor(owner: Owner, args: Dict) {
72+
super(owner, args);
7273
this.arr.push('hello');
7374
}
7475

@@ -87,10 +88,10 @@ class TrackedArrayTest extends RenderTest {
8788
'Can unshift into a newly created TrackedArray during construction'() {
8889
this.assertReactivity(
8990
class extends Component {
90-
arr = new TrackedArray<string>();
91+
arr = trackedArray();
9192

92-
constructor(...args: unknown[]) {
93-
super(...args);
93+
constructor(owner: Owner, args: Dict) {
94+
super(owner, args);
9495
this.arr.unshift('hello');
9596
}
9697

@@ -109,7 +110,7 @@ class TrackedArrayTest extends RenderTest {
109110
'{{each}} works with new items'() {
110111
this.assertEachReactivity(
111112
class extends Component {
112-
collection = new TrackedArray([1, 2, 3]);
113+
collection = trackedArray([1, 2, 3]);
113114

114115
update() {
115116
this.collection.push(4);
@@ -122,7 +123,7 @@ class TrackedArrayTest extends RenderTest {
122123
'{{each}} works when updating old items'() {
123124
this.assertEachReactivity(
124125
class extends Component {
125-
collection = new TrackedArray([1, 2, 3]);
126+
collection = trackedArray([1, 2, 3]);
126127

127128
update() {
128129
this.collection[2] = 5;
@@ -135,7 +136,7 @@ class TrackedArrayTest extends RenderTest {
135136
'{{each-in}} works with new items'() {
136137
this.assertEachInReactivity(
137138
class extends Component {
138-
collection = new TrackedArray([1, 2, 3]);
139+
collection = trackedArray([1, 2, 3]);
139140

140141
update() {
141142
this.collection.push(4);
@@ -148,7 +149,7 @@ class TrackedArrayTest extends RenderTest {
148149
'{{each-in}} works when updating old items'() {
149150
this.assertEachInReactivity(
150151
class extends Component {
151-
collection = new TrackedArray([1, 2, 3]);
152+
collection = trackedArray([1, 2, 3]);
152153

153154
update() {
154155
this.collection[2] = 5;
@@ -162,7 +163,7 @@ class TrackedArrayTest extends RenderTest {
162163
ARRAY_GETTER_METHODS.forEach((method) => {
163164
this.assertReactivity(
164165
class extends Component {
165-
arr = new TrackedArray(['foo', 'bar']);
166+
arr = trackedArray(['foo', 'bar']);
166167

167168
get value() {
168169
// @ts-expect-error -- this can't be represented easily in TS, and we
@@ -182,7 +183,7 @@ class TrackedArrayTest extends RenderTest {
182183

183184
this.assertReactivity(
184185
class extends Component {
185-
arr = new TrackedArray(['foo', 'bar']);
186+
arr = trackedArray(['foo', 'bar']);
186187

187188
get value() {
188189
// @ts-expect-error -- this can't be represented easily in TS, and we
@@ -207,7 +208,7 @@ class TrackedArrayTest extends RenderTest {
207208
ARRAY_SETTER_METHODS.forEach((method) => {
208209
this.assertReactivity(
209210
class extends Component {
210-
arr = new TrackedArray(['foo', 'bar']);
211+
arr = trackedArray(['foo', 'bar']);
211212

212213
get value() {
213214
return this.arr[0];
@@ -225,7 +226,7 @@ class TrackedArrayTest extends RenderTest {
225226

226227
this.assertReactivity(
227228
class extends Component {
228-
arr = new TrackedArray(['foo', 'bar']);
229+
arr = trackedArray(['foo', 'bar']);
229230

230231
get value() {
231232
return void this.arr.forEach(() => {

packages/@glimmer/validator/test/collections/array-test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { module, test } from '../-utils';
77

88
expectTypeOf<ReturnType<typeof trackedArray>>().toMatchTypeOf<Array<unknown>>();
99

10-
module('@glimmer/validator: TrackedArray', () => {
10+
module('@glimmer/validator: trackedArray()', () => {
1111
test('Can get values on array directly', (assert) => {
1212
let arr = trackedArray(['foo']);
1313

@@ -64,7 +64,6 @@ module('@glimmer/validator: TrackedArray', () => {
6464
let arr2 = arr.concat([1], trackedArray([2]));
6565

6666
assert.deepEqual(arr2, [1, 2]);
67-
assert.notOk(arr2 instanceof Array);
6867
});
6968

7069
test('copyWithin', (assert) => {
@@ -113,7 +112,6 @@ module('@glimmer/validator: TrackedArray', () => {
113112
let arr2 = arr.filter((v) => v > 1);
114113

115114
assert.deepEqual(arr2, [2, 3]);
116-
assert.notOk(arr2 instanceof Array);
117115
});
118116

119117
test('find', (assert) => {
@@ -199,7 +197,6 @@ module('@glimmer/validator: TrackedArray', () => {
199197
let arr2 = arr.map((v) => v + 1);
200198

201199
assert.deepEqual(arr2, [2, 3, 4]);
202-
assert.notOk(arr2 instanceof Array);
203200
});
204201

205202
test('pop', (assert) => {
@@ -258,7 +255,6 @@ module('@glimmer/validator: TrackedArray', () => {
258255
let arr2 = arr.slice();
259256

260257
assert.notEqual(arr, arr2);
261-
assert.notOk(arr2 instanceof Array);
262258
assert.deepEqual(arr, arr2);
263259
});
264260

@@ -293,7 +289,6 @@ module('@glimmer/validator: TrackedArray', () => {
293289
let arr = trackedArray([1, 2, 3]);
294290
let arr2 = arr.splice(1, 1);
295291

296-
assert.notOk(arr2 instanceof Array);
297292
assert.deepEqual(arr, [1, 3]);
298293
assert.deepEqual(arr2, [2]);
299294
});

0 commit comments

Comments
 (0)