1
- import { TrackedArray } from '@glimmer/validator' ;
1
+ import { trackedArray } from '@glimmer/validator' ;
2
+ import type { Dict , Owner } from '@glimmer/interfaces' ;
2
3
import {
3
4
GlimmerishComponent as Component ,
4
5
jitSuite ,
@@ -42,13 +43,13 @@ const ARRAY_SETTER_METHODS = [
42
43
] ;
43
44
44
45
class TrackedArrayTest extends RenderTest {
45
- static suiteName = `TrackedArray (rendering)` ;
46
+ static suiteName = `trackedArray() (rendering)` ;
46
47
47
48
@test
48
49
'getting and setting an index' ( ) {
49
50
this . assertReactivity (
50
51
class extends Component {
51
- arr = new TrackedArray ( [ 'foo' ] ) ;
52
+ arr = trackedArray ( [ 'foo' ] ) ;
52
53
53
54
get value ( ) {
54
55
return this . arr [ 0 ] ;
@@ -65,10 +66,10 @@ class TrackedArrayTest extends RenderTest {
65
66
'Can push into a newly created TrackedArray during construction' ( ) {
66
67
this . assertReactivity (
67
68
class extends Component {
68
- arr = new TrackedArray < string > ( ) ;
69
+ arr = trackedArray ( ) ;
69
70
70
- constructor ( ... args : unknown [ ] ) {
71
- super ( ... args ) ;
71
+ constructor ( owner : Owner , args : Dict ) {
72
+ super ( owner , args ) ;
72
73
this . arr . push ( 'hello' ) ;
73
74
}
74
75
@@ -87,10 +88,10 @@ class TrackedArrayTest extends RenderTest {
87
88
'Can unshift into a newly created TrackedArray during construction' ( ) {
88
89
this . assertReactivity (
89
90
class extends Component {
90
- arr = new TrackedArray < string > ( ) ;
91
+ arr = trackedArray ( ) ;
91
92
92
- constructor ( ... args : unknown [ ] ) {
93
- super ( ... args ) ;
93
+ constructor ( owner : Owner , args : Dict ) {
94
+ super ( owner , args ) ;
94
95
this . arr . unshift ( 'hello' ) ;
95
96
}
96
97
@@ -109,7 +110,7 @@ class TrackedArrayTest extends RenderTest {
109
110
'{{each}} works with new items' ( ) {
110
111
this . assertEachReactivity (
111
112
class extends Component {
112
- collection = new TrackedArray ( [ 1 , 2 , 3 ] ) ;
113
+ collection = trackedArray ( [ 1 , 2 , 3 ] ) ;
113
114
114
115
update ( ) {
115
116
this . collection . push ( 4 ) ;
@@ -122,7 +123,7 @@ class TrackedArrayTest extends RenderTest {
122
123
'{{each}} works when updating old items' ( ) {
123
124
this . assertEachReactivity (
124
125
class extends Component {
125
- collection = new TrackedArray ( [ 1 , 2 , 3 ] ) ;
126
+ collection = trackedArray ( [ 1 , 2 , 3 ] ) ;
126
127
127
128
update ( ) {
128
129
this . collection [ 2 ] = 5 ;
@@ -135,7 +136,7 @@ class TrackedArrayTest extends RenderTest {
135
136
'{{each-in}} works with new items' ( ) {
136
137
this . assertEachInReactivity (
137
138
class extends Component {
138
- collection = new TrackedArray ( [ 1 , 2 , 3 ] ) ;
139
+ collection = trackedArray ( [ 1 , 2 , 3 ] ) ;
139
140
140
141
update ( ) {
141
142
this . collection . push ( 4 ) ;
@@ -148,7 +149,7 @@ class TrackedArrayTest extends RenderTest {
148
149
'{{each-in}} works when updating old items' ( ) {
149
150
this . assertEachInReactivity (
150
151
class extends Component {
151
- collection = new TrackedArray ( [ 1 , 2 , 3 ] ) ;
152
+ collection = trackedArray ( [ 1 , 2 , 3 ] ) ;
152
153
153
154
update ( ) {
154
155
this . collection [ 2 ] = 5 ;
@@ -162,7 +163,7 @@ class TrackedArrayTest extends RenderTest {
162
163
ARRAY_GETTER_METHODS . forEach ( ( method ) => {
163
164
this . assertReactivity (
164
165
class extends Component {
165
- arr = new TrackedArray ( [ 'foo' , 'bar' ] ) ;
166
+ arr = trackedArray ( [ 'foo' , 'bar' ] ) ;
166
167
167
168
get value ( ) {
168
169
// @ts -expect-error -- this can't be represented easily in TS, and we
@@ -182,7 +183,7 @@ class TrackedArrayTest extends RenderTest {
182
183
183
184
this . assertReactivity (
184
185
class extends Component {
185
- arr = new TrackedArray ( [ 'foo' , 'bar' ] ) ;
186
+ arr = trackedArray ( [ 'foo' , 'bar' ] ) ;
186
187
187
188
get value ( ) {
188
189
// @ts -expect-error -- this can't be represented easily in TS, and we
@@ -207,7 +208,7 @@ class TrackedArrayTest extends RenderTest {
207
208
ARRAY_SETTER_METHODS . forEach ( ( method ) => {
208
209
this . assertReactivity (
209
210
class extends Component {
210
- arr = new TrackedArray ( [ 'foo' , 'bar' ] ) ;
211
+ arr = trackedArray ( [ 'foo' , 'bar' ] ) ;
211
212
212
213
get value ( ) {
213
214
return this . arr [ 0 ] ;
@@ -225,7 +226,7 @@ class TrackedArrayTest extends RenderTest {
225
226
226
227
this . assertReactivity (
227
228
class extends Component {
228
- arr = new TrackedArray ( [ 'foo' , 'bar' ] ) ;
229
+ arr = trackedArray ( [ 'foo' , 'bar' ] ) ;
229
230
230
231
get value ( ) {
231
232
return void this . arr . forEach ( ( ) => {
0 commit comments