File tree Expand file tree Collapse file tree 2 files changed +48
-5
lines changed
app/code/Magento/Theme/view/frontend/web/js
dev/tests/js/jasmine/tests/app/code/Magento/Theme/view/frontend/web/js Expand file tree Collapse file tree 2 files changed +48
-5
lines changed Original file line number Diff line number Diff line change 1
1
define ( [
2
2
'jquery' ,
3
3
'Magento_Ui/js/modal/modal' ,
4
- 'mage/translate' ,
5
- ] , function ( $ , modal ) {
4
+ 'mage/translate'
5
+ ] , function ( $ , modal ) {
6
6
'use strict' ;
7
7
8
8
$ . widget ( 'mage.cookieStatus' , {
@@ -14,6 +14,10 @@ define([
14
14
buttons : [ {
15
15
text : $ . mage . __ ( 'Close' ) ,
16
16
class : 'cookie-status' ,
17
+
18
+ /**
19
+ * Callback for click event
20
+ */
17
21
click : function ( ) {
18
22
this . closeModal ( ) ;
19
23
}
@@ -26,11 +30,11 @@ define([
26
30
*/
27
31
_init : function ( ) {
28
32
29
- if ( ! navigator . cookieEnabled ) {
33
+ if ( ! navigator . cookieEnabled ) {
30
34
modal ( this . options , $ ( '#cookie-status' ) ) ;
31
35
}
32
36
}
33
37
} ) ;
34
-
38
+
35
39
return $ . mage . cookieStatus ;
36
- } ) ;
40
+ } ) ;
Original file line number Diff line number Diff line change
1
+
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ define ( [
8
+ 'jquery' ,
9
+ 'cookieStatus'
10
+ ] , function ( $ , Cookie ) {
11
+ 'use strict' ;
12
+
13
+ describe ( 'Magento_Theme/js/cookie-status' , function ( ) {
14
+ var widget ,
15
+ htmlContainer = '<div id="cookie-status" style="display: none"></div>' ,
16
+ navigator ;
17
+
18
+ beforeEach ( function ( ) {
19
+ $ ( document . body ) . append ( htmlContainer ) ;
20
+ widget = new Cookie ( ) ;
21
+ navigator = window . navigator ;
22
+ } ) ;
23
+
24
+ afterEach ( function ( ) {
25
+ window . navigator = navigator ;
26
+ } ) ;
27
+
28
+ it ( 'verify cookie-status initialization' , function ( ) {
29
+ expect ( $ . fn . cookieStatus ) . toBeDefined ( ) ;
30
+ window . navigator = {
31
+ cookieEnabled : false
32
+ } ;
33
+ widget . _init ( ) ;
34
+ expect ( $ ( '.cookie-status' ) . length ) . toBe ( 1 ) ;
35
+ expect ( $ ( document . body ) . html ( ) ) . toContain ( '<aside role="dialog" class="modal-popup' ) ;
36
+ } ) ;
37
+
38
+ } ) ;
39
+ } ) ;
You can’t perform that action at this time.
0 commit comments