@@ -20,14 +20,63 @@ define([
20
20
selectElement = $ ( option ) ;
21
21
22
22
beforeEach ( function ( ) {
23
+ //remove this lines when jasmine version will be upgraded
24
+ if ( ! Array . prototype . find ) {
25
+ Object . defineProperty ( Array . prototype , 'find' , { //eslint-disable-line
26
+ enumerable : false ,
27
+ configurable : true ,
28
+ writable : true ,
29
+
30
+ /**
31
+ * Find method
32
+ */
33
+ value : function ( predicate ) {
34
+ var list = Object ( this ) ,
35
+ length = list . length >>> 0 ,
36
+ thisArg = arguments [ 1 ] ,
37
+ value ,
38
+ i ;
39
+
40
+ if ( this == null ) {
41
+ throw new TypeError ( 'Array.prototype.find called on null or undefined' ) ;
42
+ }
43
+
44
+ if ( typeof predicate !== 'function' ) {
45
+ throw new TypeError ( 'predicate must be a function' ) ;
46
+ }
47
+
48
+ for ( i = 0 ; i < length ; i ++ ) {
49
+ if ( i in list ) {
50
+ value = list [ i ] ;
51
+
52
+ if ( predicate . call ( thisArg , value , i , list ) ) { //eslint-disable-line
53
+ return value ;
54
+ }
55
+ }
56
+ }
57
+
58
+ return undefined ;
59
+ }
60
+ } ) ;
61
+ }
23
62
widget = new Configurable ( ) ;
24
63
widget . options = {
25
64
spConfig : {
26
65
chooseText : 'Chose an Option...' ,
27
66
attributes :
28
67
{
29
68
'size' : {
30
- options : $ ( '<div><p class="2"></p></div>' )
69
+ options : [
70
+ {
71
+ id : '2' ,
72
+ value : '2'
73
+ } ,
74
+ {
75
+ id : 3 ,
76
+ value : 'red'
77
+
78
+ }
79
+ ]
31
80
}
32
81
} ,
33
82
prices : {
@@ -45,16 +94,15 @@ define([
45
94
46
95
it ( 'check if attribute value is possible to be set as configurable option' , function ( ) {
47
96
expect ( $ . mage . configurable ) . toBeDefined ( ) ;
48
- widget . _parseQueryParams ( 'http://magento.com/product?color=red& size=2' ) ;
97
+ widget . _parseQueryParams ( 'size=2' ) ;
49
98
expect ( widget . options . values . size ) . toBe ( '2' ) ;
50
99
} ) ;
51
100
52
- it ( 'check if attribute value is possible to be set as option with "please select option" ' , function ( ) {
101
+ it ( 'check that attribute value is not set id provided option does not exists ' , function ( ) {
53
102
expect ( $ . mage . configurable ) . toBeDefined ( ) ;
103
+ widget . _parseQueryParams ( 'size=10' ) ;
54
104
widget . _fillSelect ( selectElement [ 0 ] ) ;
55
- expect ( selectElement [ 0 ] . options [ 0 ] . innerHTML ) . toBe ( widget . options . spConfig . chooseText ) ;
56
- widget . _parseQueryParams ( 'http://magento.com/product?color=red&size=2' ) ;
57
- expect ( widget . options . values . size ) . toBe ( '2' ) ;
105
+ expect ( widget . options . values . size ) . toBe ( undefined ) ;
58
106
} ) ;
59
107
} ) ;
60
108
} ) ;
0 commit comments