1
1
import { moduleFor , RenderingTestCase , styles , runTask } from 'internal-test-helpers' ;
2
2
3
- import { set , computed } from '@ember/object' ;
3
+ import { get , set , computed } from '@ember/object' ;
4
4
5
5
import { Component , htmlSafe } from '../../utils/helpers' ;
6
6
@@ -47,15 +47,15 @@ moduleFor(
47
47
firstAttr : 'first attr' ,
48
48
} ) ;
49
49
50
- assert . equal ( instance . get ( 'first' ) , 'first attr' ) ;
50
+ assert . equal ( get ( instance , 'first' ) , 'first attr' ) ;
51
51
52
52
runTask ( ( ) => this . rerender ( ) ) ;
53
53
54
- assert . equal ( instance . get ( 'first' ) , 'first attr' ) ;
54
+ assert . equal ( get ( instance , 'first' ) , 'first attr' ) ;
55
55
56
56
runTask ( ( ) => set ( this . context , 'firstAttr' , 'second attr' ) ) ;
57
57
58
- assert . equal ( instance . get ( 'first' ) , 'second attr' ) ;
58
+ assert . equal ( get ( instance , 'first' ) , 'second attr' ) ;
59
59
60
60
runTask ( ( ) => set ( this . context , 'firstAttr' , 'first attr' ) ) ;
61
61
@@ -71,7 +71,7 @@ moduleFor(
71
71
}
72
72
73
73
didReceiveAttrs ( ) {
74
- this . set ( 'first' , this . get ( 'first' ) . toUpperCase ( ) ) ;
74
+ set ( this , 'first' , get ( this , 'first' ) . toUpperCase ( ) ) ;
75
75
}
76
76
} ;
77
77
this . registerComponent ( 'foo-bar' , {
@@ -81,13 +81,13 @@ moduleFor(
81
81
82
82
this . render ( `{{foo-bar first="first attr"}}` ) ;
83
83
84
- assert . equal ( instance . get ( 'first' ) , 'FIRST ATTR' , 'component lookup uses local state' ) ;
84
+ assert . equal ( get ( instance , 'first' ) , 'FIRST ATTR' , 'component lookup uses local state' ) ;
85
85
this . assertText ( 'FIRST ATTR' ) ;
86
86
87
87
runTask ( ( ) => this . rerender ( ) ) ;
88
88
89
89
assert . equal (
90
- instance . get ( 'first' ) ,
90
+ get ( instance , 'first' ) ,
91
91
'FIRST ATTR' ,
92
92
'component lookup uses local state during rerender'
93
93
) ;
@@ -108,7 +108,7 @@ moduleFor(
108
108
}
109
109
110
110
didReceiveAttrs ( ) {
111
- assert . equal ( this . get ( 'woot' ) , wootVal , 'found attr in didReceiveAttrs' ) ;
111
+ assert . equal ( get ( this , 'woot' ) , wootVal , 'found attr in didReceiveAttrs' ) ;
112
112
}
113
113
} ;
114
114
this . registerComponent ( 'foo-bar' , { ComponentClass : FooBarComponent } ) ;
@@ -117,25 +117,25 @@ moduleFor(
117
117
woot : wootVal ,
118
118
} ) ;
119
119
120
- assert . equal ( instance . get ( 'woot' ) , 'yes' , 'component found attr' ) ;
120
+ assert . equal ( get ( instance , 'woot' ) , 'yes' , 'component found attr' ) ;
121
121
122
122
runTask ( ( ) => this . rerender ( ) ) ;
123
123
124
- assert . equal ( instance . get ( 'woot' ) , 'yes' , 'component found attr after rerender' ) ;
124
+ assert . equal ( get ( instance , 'woot' ) , 'yes' , 'component found attr after rerender' ) ;
125
125
126
126
runTask ( ( ) => {
127
127
wootVal = 'nope' ;
128
128
set ( this . context , 'woot' , wootVal ) ;
129
129
} ) ;
130
130
131
- assert . equal ( instance . get ( 'woot' ) , 'nope' , 'component found attr after attr change' ) ;
131
+ assert . equal ( get ( instance , 'woot' ) , 'nope' , 'component found attr after attr change' ) ;
132
132
133
133
runTask ( ( ) => {
134
134
wootVal = 'yes' ;
135
135
set ( this . context , 'woot' , wootVal ) ;
136
136
} ) ;
137
137
138
- assert . equal ( instance . get ( 'woot' ) , 'yes' , 'component found attr after reset' ) ;
138
+ assert . equal ( get ( instance , 'woot' ) , 'yes' , 'component found attr after reset' ) ;
139
139
}
140
140
141
141
[ '@test getAttr() should return the same value as get()' ] ( assert ) {
@@ -149,9 +149,9 @@ moduleFor(
149
149
}
150
150
151
151
didReceiveAttrs ( ) {
152
- let rootFirstPositional = this . get ( 'firstPositional' ) ;
153
- let rootFirst = this . get ( 'first' ) ;
154
- let rootSecond = this . get ( 'second' ) ;
152
+ let rootFirstPositional = get ( this , 'firstPositional' ) ;
153
+ let rootFirst = get ( this , 'first' ) ;
154
+ let rootSecond = get ( this , 'second' ) ;
155
155
let attrFirstPositional = this . getAttr ( 'firstPositional' ) ;
156
156
let attrFirst = this . getAttr ( 'first' ) ;
157
157
let attrSecond = this . getAttr ( 'second' ) ;
@@ -178,58 +178,58 @@ moduleFor(
178
178
second : 'second' ,
179
179
} ) ;
180
180
181
- assert . equal ( instance . get ( 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
182
- assert . equal ( instance . get ( 'first' ) , 'first' , 'matches known value' ) ;
183
- assert . equal ( instance . get ( 'second' ) , 'second' , 'matches known value' ) ;
181
+ assert . equal ( get ( instance , 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
182
+ assert . equal ( get ( instance , 'first' ) , 'first' , 'matches known value' ) ;
183
+ assert . equal ( get ( instance , 'second' ) , 'second' , 'matches known value' ) ;
184
184
185
185
runTask ( ( ) => this . rerender ( ) ) ;
186
186
187
- assert . equal ( instance . get ( 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
188
- assert . equal ( instance . get ( 'first' ) , 'first' , 'matches known value' ) ;
189
- assert . equal ( instance . get ( 'second' ) , 'second' , 'matches known value' ) ;
187
+ assert . equal ( get ( instance , 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
188
+ assert . equal ( get ( instance , 'first' ) , 'first' , 'matches known value' ) ;
189
+ assert . equal ( get ( instance , 'second' ) , 'second' , 'matches known value' ) ;
190
190
191
191
runTask ( ( ) => {
192
192
set ( this . context , 'first' , 'third' ) ;
193
193
} ) ;
194
194
195
- assert . equal ( instance . get ( 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
196
- assert . equal ( instance . get ( 'first' ) , 'third' , 'matches known value' ) ;
197
- assert . equal ( instance . get ( 'second' ) , 'second' , 'matches known value' ) ;
195
+ assert . equal ( get ( instance , 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
196
+ assert . equal ( get ( instance , 'first' ) , 'third' , 'matches known value' ) ;
197
+ assert . equal ( get ( instance , 'second' ) , 'second' , 'matches known value' ) ;
198
198
199
199
runTask ( ( ) => {
200
200
set ( this . context , 'second' , 'fourth' ) ;
201
201
} ) ;
202
202
203
- assert . equal ( instance . get ( 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
204
- assert . equal ( instance . get ( 'first' ) , 'third' , 'matches known value' ) ;
205
- assert . equal ( instance . get ( 'second' ) , 'fourth' , 'matches known value' ) ;
203
+ assert . equal ( get ( instance , 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
204
+ assert . equal ( get ( instance , 'first' ) , 'third' , 'matches known value' ) ;
205
+ assert . equal ( get ( instance , 'second' ) , 'fourth' , 'matches known value' ) ;
206
206
207
207
runTask ( ( ) => {
208
208
set ( this . context , 'firstPositional' , 'fifth' ) ;
209
209
} ) ;
210
210
211
- assert . equal ( instance . get ( 'firstPositional' ) , 'fifth' , 'matches known value' ) ;
212
- assert . equal ( instance . get ( 'first' ) , 'third' , 'matches known value' ) ;
213
- assert . equal ( instance . get ( 'second' ) , 'fourth' , 'matches known value' ) ;
211
+ assert . equal ( get ( instance , 'firstPositional' ) , 'fifth' , 'matches known value' ) ;
212
+ assert . equal ( get ( instance , 'first' ) , 'third' , 'matches known value' ) ;
213
+ assert . equal ( get ( instance , 'second' ) , 'fourth' , 'matches known value' ) ;
214
214
215
215
runTask ( ( ) => {
216
216
set ( this . context , 'firstPositional' , 'firstPositional' ) ;
217
217
set ( this . context , 'first' , 'first' ) ;
218
218
set ( this . context , 'second' , 'second' ) ;
219
219
} ) ;
220
220
221
- assert . equal ( instance . get ( 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
222
- assert . equal ( instance . get ( 'first' ) , 'first' , 'matches known value' ) ;
223
- assert . equal ( instance . get ( 'second' ) , 'second' , 'matches known value' ) ;
221
+ assert . equal ( get ( instance , 'firstPositional' ) , 'firstPositional' , 'matches known value' ) ;
222
+ assert . equal ( get ( instance , 'first' ) , 'first' , 'matches known value' ) ;
223
+ assert . equal ( get ( instance , 'second' ) , 'second' , 'matches known value' ) ;
224
224
}
225
225
226
226
[ '@test bound computed properties can be overridden in extensions, set during init, and passed in as attrs' ] ( ) {
227
227
let FooClass = class extends Component {
228
228
attributeBindings = [ 'style' ] ;
229
229
@computed ( 'height' , 'color' )
230
230
get style ( ) {
231
- let height = this . get ( 'height' ) ;
232
- let color = this . get ( 'color' ) ;
231
+ let height = get ( this , 'height' ) ;
232
+ let color = get ( this , 'color' ) ;
233
233
return htmlSafe ( `height: ${ height } px; background-color: ${ color } ;` ) ;
234
234
}
235
235
color = 'red' ;
0 commit comments