Skip to content

Commit

Permalink
Refactoring jasmine test
Browse files Browse the repository at this point in the history
  • Loading branch information
konarshankar07 committed Feb 19, 2020
1 parent bdfe729 commit 9404f53
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-->
<div if="isVisible" class="masonry-sorting">
<div if="isVisible" class="masonry-image-sorting">
<b><!-- ko i18n: 'Sort by' --><!-- /ko -->:</b>
<select class="admin__control-select" data-bind="
options: options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,54 @@ define([
});

describe('"preparedOptions" method', function () {
it('return empty array if sorting is disabled for the columns', function () {
var columns = [{
sortable: false,
label: 'magento',
index: 'name'
}],
options = [];
it('sort option will not available if sorting is disabled for the columns', function () {
var columns = {
sortable: false,
label: 'magento',
index: 'name'
};

sortByObj.preparedOptions(columns);
expect(sortByObj.options).toEqual(options);
sortByObj.preparedOptions([columns]);
expect(sortByObj.options[0]).toBeUndefined();
expect(sortByObj.options[0]).toBeUndefined();
});

it('return array of options if sorting is enabled for the columns', function () {
var columns = [{
sortable: true,
label: 'magento',
index: 'name'
}],
options = [{
value: 'name',
label: 'magento'
}];
it('sort option will available if sorting is enabled for the columns', function () {
var columns = {
sortable: true,
label: 'magento',
index: 'name'
};

sortByObj.preparedOptions(columns);
expect(sortByObj.options).toEqual(options);
sortByObj.preparedOptions([columns]);
expect(sortByObj.options[0].value).toEqual('name');
expect(sortByObj.options[0].label).toEqual('magento');
});

it('return "isVisible" method true if column is sortable', function () {
var columns = [{
sortable: true,
label: 'magento',
index: 'name'
}];
it('return "isVisible" method true if sorting is enabled for column', function () {
var columns = {
sortable: true,
label: 'magento',
index: 'name'
};

sortByObj.preparedOptions(columns);
sortByObj.preparedOptions([columns]);
expect(sortByObj.isVisible()).toBeTruthy();
});

it('return "isVisible" method false if column is sortable', function () {
var columns = [{
it('return "isVisible" method false if sorting is disabled for column', function () {
var columns = {
sortable: false,
label: 'magento',
index: 'name'
}];
};

sortByObj.preparedOptions(columns);
sortByObj.preparedOptions([columns]);
expect(sortByObj.isVisible()).toBeFalsy();
});
});
describe('"applyChanges" method', function () {
it('return applied option', function () {
it('return applied options for sorting column', function () {
var applied = {
field: 'selectedOption',
direction: 'desc'
Expand Down

0 comments on commit 9404f53

Please sign in to comment.