Skip to content

Commit 42e4454

Browse files
committed
MC-30502: JSUnit tests incompatible with Node v10 or v12
- Fixed jasmine test failure - Removed unecessary URLs - Fixed nodejs dependency
1 parent 7fbae46 commit 42e4454

File tree

2 files changed

+60
-64
lines changed

2 files changed

+60
-64
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/masonry.test.js

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,75 @@
66
/*eslint max-nested-callbacks: 0*/
77
define([
88
'jquery',
9-
'ko',
109
'Magento_Ui/js/grid/masonry'
11-
], function ($, ko, Masonry) {
10+
], function ($, Masonry) {
1211
'use strict';
1312

14-
var Component,
15-
rows,
16-
container = '<div data-id="masonry_grid" id="masonry_grid"><div class="masonry-image-column"></div></div>';
13+
describe('Magento_Ui/js/grid/masonry', function () {
14+
var Component,
15+
rows,
16+
container = '<div data-id="masonry_grid" id="masonry_grid"><div class="masonry-image-column"></div></div>';
1717

18-
beforeEach(function () {
19-
rows = [
20-
{
21-
_rowIndex: 0,
22-
category: {},
23-
'category_id': 695,
24-
'category_name': 'People',
25-
'comp_url': 'https://stock.adobe.com/Rest/Libraries/Watermarked/Download/327515738/2',
26-
'content_type': 'image/jpeg',
27-
'country_name': 'Malaysia',
28-
'creation_date': '2020-03-02 10:41:51',
29-
'creator_id': 208217780,
30-
'creator_name': 'NajmiArif',
31-
height: 3264,
32-
id: 327515738,
33-
'id_field_name': 'id',
34-
'is_downloaded': 0,
35-
'is_licensed_locally': 0,
36-
keywords: [],
37-
'media_type_id': 1,
38-
overlay: '',
39-
path: '',
40-
'premium_level_id': 0,
41-
'thumbnail_240_url': 'https://t4.ftcdn.net/jpg/03/27/51/57/240_F_327515738_n.jpg',
42-
'thumbnail_500_ur': 'https://as2.ftcdn.net/jpg/03/27/51/57/500_F_327515738_n.jpg',
43-
title: 'Neon effect picture of man wearing medical mask for viral or pandemic disease',
44-
width: 4896
45-
}
18+
beforeEach(function () {
19+
rows = [
20+
{
21+
_rowIndex: 0,
22+
category: {},
23+
'category_id': 695,
24+
'category_name': 'People',
25+
'content_type': 'image/jpeg',
26+
'country_name': 'Malaysia',
27+
'creation_date': '2020-03-02 10:41:51',
28+
'creator_id': 208217780,
29+
'creator_name': 'NajmiArif',
30+
height: 3264,
31+
id: 327515738,
32+
'id_field_name': 'id',
33+
'is_downloaded': 0,
34+
'is_licensed_locally': 0,
35+
keywords: [],
36+
'media_type_id': 1,
37+
overlay: '',
38+
path: '',
39+
'premium_level_id': 0,
40+
title: 'Neon effect picture of man wearing medical mask for viral or pandemic disease',
41+
width: 4896
42+
}
43+
];
4644

47-
];
48-
49-
$(container).appendTo('body');
50-
51-
Component = new Masonry({
52-
defaults: {
53-
rows: ko.observable()
54-
}
45+
$(document.body).append(container);
46+
Component = new Masonry({
47+
defaults: {
48+
containerId: '#masonry_grid'
49+
}
50+
});
5551
});
5652

57-
});
58-
59-
afterEach(function () {
60-
$('#masonry_grid').remove();
61-
});
53+
afterEach(function () {
54+
Component.clear();
55+
$('#masonry_grid').remove();
56+
});
6257

63-
describe('check initComponent', function () {
64-
it('verify setLayoutstyles called and grid iniztilized', function () {
65-
var setlayoutStyles = spyOn(Component, 'setLayoutStyles');
58+
describe('check initComponent', function () {
59+
it('verify setLayoutstyles called and grid iniztilized', function () {
60+
var setlayoutStyles = spyOn(Component, 'setLayoutStyles');
6661

67-
expect(Component).toBeDefined();
68-
Component.containerId = 'masonry_grid';
69-
Component.initComponent(rows);
70-
Component.rows().forEach(function (image) {
71-
expect(image.styles).toBeDefined();
72-
expect(image.css).toBeDefined();
62+
expect(Component).toBeDefined();
63+
Component.containerId = 'masonry_grid';
64+
Component.initComponent(rows);
65+
Component.rows().forEach(function (image) {
66+
expect(image.styles).toBeDefined();
67+
expect(image.css).toBeDefined();
68+
});
69+
expect(setlayoutStyles).toHaveBeenCalled();
7370
});
74-
expect(setlayoutStyles).toHaveBeenCalled();
75-
});
76-
it('verify events triggered', function () {
77-
var setLayoutStyles = spyOn(Component, 'setLayoutStyles');
71+
it('verify events triggered', function () {
72+
var setLayoutStyles = spyOn(Component, 'setLayoutStyles');
7873

79-
Component.initComponent(rows);
80-
window.dispatchEvent(new Event('resize'));
81-
expect(setLayoutStyles).toHaveBeenCalled();
74+
Component.initComponent(rows);
75+
window.dispatchEvent(new Event('resize'));
76+
expect(setLayoutStyles).toHaveBeenCalled();
77+
});
8278
});
8379
});
8480
});

package.json.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"grunt-contrib-connect": "~1.0.2",
1919
"grunt-contrib-cssmin": "~2.2.1",
2020
"grunt-contrib-imagemin": "~2.0.1",
21-
"grunt-contrib-jasmine": "~1.1.0",
21+
"grunt-contrib-jasmine": "~1.2.0",
2222
"grunt-contrib-less": "~1.4.1",
2323
"grunt-contrib-watch": "~1.0.0",
2424
"grunt-eslint": "~20.1.0",
@@ -39,4 +39,4 @@
3939
"time-grunt": "~1.4.0",
4040
"underscore": "~1.8.0"
4141
}
42-
}
42+
}

0 commit comments

Comments
 (0)