@@ -25,6 +25,18 @@ describe('SymbolShim', function () {
25
25
expect ( test ) . toBe ( '@@test' ) ;
26
26
} ) ;
27
27
28
+ it ( 'should add a for method even if Symbol already exists but does not have for' , function ( ) {
29
+ var root = {
30
+ Symbol : { }
31
+ } ;
32
+ var result = polyfillSymbol ( root ) ;
33
+
34
+ expect ( typeof result . for ) . toBe ( 'function' ) ;
35
+
36
+ var test = result . for ( 'test' ) ;
37
+ expect ( test ) . toBe ( '@@test' ) ;
38
+ } ) ;
39
+
28
40
describe ( 'when symbols exists on root' , function ( ) {
29
41
it ( 'should use symbols from root' , function ( ) {
30
42
var root = {
@@ -59,17 +71,15 @@ describe('SymbolShim', function () {
59
71
expect ( result . observable ) . toBe ( '@@observable' ) ;
60
72
} ) ;
61
73
} ) ;
62
- } ) ;
63
74
64
- describe ( 'ensureIterator' , function ( ) {
65
- it ( 'should patch root using for symbol if exist' , function ( ) {
75
+ it ( 'should patch root using Symbol.for if exist' , function ( ) {
66
76
var root = {
67
77
Symbol : {
68
78
for : function ( x ) { return x ; }
69
79
}
70
80
} ;
71
- ensureIterator ( root . Symbol , root ) ;
72
- expect ( root . Symbol . iterator ) . toBe ( root . Symbol . for ( 'iterator' ) ) ;
81
+ var result = polyfillSymbol ( root ) ;
82
+ expect ( result . iterator ) . toBe ( root . Symbol . for ( 'iterator' ) ) ;
73
83
} ) ;
74
84
75
85
it ( 'should patch using Set for mozilla bug' , function ( ) {
@@ -82,8 +92,8 @@ describe('ensureIterator', function () {
82
92
Symbol : { }
83
93
} ;
84
94
85
- ensureIterator ( root . Symbol , root ) ;
86
- expect ( root . Symbol . iterator ) . toBe ( '@@iterator' ) ;
95
+ var result = polyfillSymbol ( root ) ;
96
+ expect ( result . iterator ) . toBe ( '@@iterator' ) ;
87
97
} ) ;
88
98
89
99
it ( 'should patch using map for es6-shim' , function ( ) {
@@ -95,7 +105,7 @@ describe('ensureIterator', function () {
95
105
root . Map . prototype . key = 'iteratorValue' ;
96
106
root . Map . prototype . entries = 'iteratorValue' ;
97
107
98
- ensureIterator ( root . Symbol , root ) ;
99
- expect ( root . Symbol . iterator ) . toBe ( 'key' ) ;
108
+ var result = polyfillSymbol ( root ) ;
109
+ expect ( result . iterator ) . toBe ( 'key' ) ;
100
110
} ) ;
101
111
} ) ;
0 commit comments