Skip to content

Commit 9404f53

Browse files
Refactoring jasmine test
1 parent bdfe729 commit 9404f53

File tree

2 files changed

+31
-34
lines changed
  • app/code/Magento/Ui/view/base/web/templates/grid
  • dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid

2 files changed

+31
-34
lines changed

app/code/Magento/Ui/view/base/web/templates/grid/sortBy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66
-->
7-
<div if="isVisible" class="masonry-sorting">
7+
<div if="isVisible" class="masonry-image-sorting">
88
<b><!-- ko i18n: 'Sort by' --><!-- /ko -->:</b>
99
<select class="admin__control-select" data-bind="
1010
options: options,

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

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,54 @@ define([
1414
});
1515

1616
describe('"preparedOptions" method', function () {
17-
it('return empty array if sorting is disabled for the columns', function () {
18-
var columns = [{
19-
sortable: false,
20-
label: 'magento',
21-
index: 'name'
22-
}],
23-
options = [];
17+
it('sort option will not available if sorting is disabled for the columns', function () {
18+
var columns = {
19+
sortable: false,
20+
label: 'magento',
21+
index: 'name'
22+
};
2423

25-
sortByObj.preparedOptions(columns);
26-
expect(sortByObj.options).toEqual(options);
24+
sortByObj.preparedOptions([columns]);
25+
expect(sortByObj.options[0]).toBeUndefined();
26+
expect(sortByObj.options[0]).toBeUndefined();
2727
});
2828

29-
it('return array of options if sorting is enabled for the columns', function () {
30-
var columns = [{
31-
sortable: true,
32-
label: 'magento',
33-
index: 'name'
34-
}],
35-
options = [{
36-
value: 'name',
37-
label: 'magento'
38-
}];
29+
it('sort option will available if sorting is enabled for the columns', function () {
30+
var columns = {
31+
sortable: true,
32+
label: 'magento',
33+
index: 'name'
34+
};
3935

40-
sortByObj.preparedOptions(columns);
41-
expect(sortByObj.options).toEqual(options);
36+
sortByObj.preparedOptions([columns]);
37+
expect(sortByObj.options[0].value).toEqual('name');
38+
expect(sortByObj.options[0].label).toEqual('magento');
4239
});
4340

44-
it('return "isVisible" method true if column is sortable', function () {
45-
var columns = [{
46-
sortable: true,
47-
label: 'magento',
48-
index: 'name'
49-
}];
41+
it('return "isVisible" method true if sorting is enabled for column', function () {
42+
var columns = {
43+
sortable: true,
44+
label: 'magento',
45+
index: 'name'
46+
};
5047

51-
sortByObj.preparedOptions(columns);
48+
sortByObj.preparedOptions([columns]);
5249
expect(sortByObj.isVisible()).toBeTruthy();
5350
});
5451

55-
it('return "isVisible" method false if column is sortable', function () {
56-
var columns = [{
52+
it('return "isVisible" method false if sorting is disabled for column', function () {
53+
var columns = {
5754
sortable: false,
5855
label: 'magento',
5956
index: 'name'
60-
}];
57+
};
6158

62-
sortByObj.preparedOptions(columns);
59+
sortByObj.preparedOptions([columns]);
6360
expect(sortByObj.isVisible()).toBeFalsy();
6461
});
6562
});
6663
describe('"applyChanges" method', function () {
67-
it('return applied option', function () {
64+
it('return applied options for sorting column', function () {
6865
var applied = {
6966
field: 'selectedOption',
7067
direction: 'desc'

0 commit comments

Comments
 (0)