@@ -57,8 +57,7 @@ describe('autobind method decorator', function() {
57
57
} , / @ a u t o b i n d d e c o r a t o r c a n o n l y b e a p p l i e d t o m e t h o d s / ) ;
58
58
} ) ;
59
59
60
-
61
- it ( 'should not override binded instance method, while calling super method with the same name' , function ( ) { // eslint-disable-line max-len
60
+ it ( 'should not override bound instance method, while calling super method with the same name' , function ( ) { // eslint-disable-line max-len
62
61
class B extends A {
63
62
64
63
@autobind
@@ -210,3 +209,56 @@ describe('autobind class decorator', function() {
210
209
} ) ;
211
210
} ) ;
212
211
} ) ;
212
+
213
+ describe ( 'set new value' , function ( ) {
214
+ class A {
215
+ constructor ( ) {
216
+ this . data = 'A' ;
217
+ this . foo = 'foo' ;
218
+ this . bar = 'bar' ;
219
+ }
220
+
221
+ @autobind
222
+ noop ( ) {
223
+ return this . data ;
224
+ }
225
+ }
226
+
227
+ const a = new A ( ) ;
228
+
229
+ it ( 'should not throw when reassigning to an object' , function ( ) {
230
+ a . noop = {
231
+ foo : 'bar'
232
+ } ;
233
+ assert . deepEqual ( a . noop , {
234
+ foo : 'bar'
235
+ } ) ;
236
+ assert . equal ( a . noop , a . noop ) ;
237
+ } ) ;
238
+
239
+ it ( 'should not throw when reassigning to a function' , function ( ) {
240
+ a . noop = function noop ( ) {
241
+ return this . foo ;
242
+ } ;
243
+ assert . equal ( a . noop ( ) , 'foo' ) ;
244
+ const noop = a . noop ;
245
+ assert . equal ( noop ( ) , 'foo' ) ;
246
+ assert . equal ( a . noop , a . noop ) ;
247
+ } ) ;
248
+
249
+ it ( 'should not throw when reassigning to a function again' , function ( ) {
250
+ a . noop = function noop2 ( ) {
251
+ return this . bar ;
252
+ } ;
253
+ assert ( a . noop ( ) , 'bar' ) ;
254
+ const noop2 = a . noop ;
255
+ assert . equal ( noop2 ( ) , 'bar' ) ;
256
+ assert . equal ( a . noop , a . noop ) ;
257
+ } ) ;
258
+
259
+ it ( 'should not throw when reassigning to an object after bound a function' , function ( ) {
260
+ a . noop = { } ;
261
+ assert . deepEqual ( a . noop , { } ) ;
262
+ assert . equal ( a . noop , a . noop ) ;
263
+ } ) ;
264
+ } ) ;
0 commit comments