File tree 2 files changed +32
-0
lines changed
packages/reactivity/__tests__
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,21 @@ describe('reactivity/ref', () => {
139
139
expect ( tupleRef . value [ 4 ] . value ) . toBe ( 1 )
140
140
} )
141
141
142
+ it ( 'should keep symbols' , ( ) => {
143
+ const customSymbol = Symbol ( )
144
+ const obj = {
145
+ [ Symbol . asyncIterator ] : { a : 1 } ,
146
+ [ Symbol . unscopables ] : { b : '1' } ,
147
+ [ customSymbol ] : { c : [ 1 , 2 , 3 ] }
148
+ }
149
+
150
+ const objRef = ref ( obj )
151
+
152
+ expect ( objRef . value [ Symbol . asyncIterator ] ) . toBe ( obj [ Symbol . asyncIterator ] )
153
+ expect ( objRef . value [ Symbol . unscopables ] ) . toBe ( obj [ Symbol . unscopables ] )
154
+ expect ( objRef . value [ customSymbol ] ) . toStrictEqual ( obj [ customSymbol ] )
155
+ } )
156
+
142
157
test ( 'unref' , ( ) => {
143
158
expect ( unref ( 1 ) ) . toBe ( 1 )
144
159
expect ( unref ( ref ( 1 ) ) ) . toBe ( 1 )
Original file line number Diff line number Diff line change @@ -57,3 +57,20 @@ function bailType(arg: HTMLElement | Ref<HTMLElement>) {
57
57
}
58
58
const el = document . createElement ( 'DIV' )
59
59
bailType ( el )
60
+
61
+ function withSymbol ( ) {
62
+ const customSymbol = Symbol ( )
63
+ const obj = {
64
+ [ Symbol . asyncIterator ] : { a : 1 } ,
65
+ [ Symbol . unscopables ] : { b : '1' } ,
66
+ [ customSymbol ] : { c : [ 1 , 2 , 3 ] }
67
+ }
68
+
69
+ const objRef = ref ( obj )
70
+
71
+ expectType < { a : number } > ( objRef . value [ Symbol . asyncIterator ] )
72
+ expectType < { b : string } > ( objRef . value [ Symbol . unscopables ] )
73
+ expectType < { c : Array < number > } > ( objRef . value [ customSymbol ] )
74
+ }
75
+
76
+ withSymbol ( )
You can’t perform that action at this time.
0 commit comments