Skip to content

Commit

Permalink
Added accordion.test.js for Jasmine testing.
Browse files Browse the repository at this point in the history
Removed accordion.js and index.html for jsTestDriver test.
  • Loading branch information
Carlos Lizaga committed Nov 22, 2017
1 parent 1691621 commit ea56695
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 88 deletions.
57 changes: 0 additions & 57 deletions dev/tests/js/JsTestDriver/testsuite/mage/accordion/accordion.js

This file was deleted.

31 changes: 0 additions & 31 deletions dev/tests/js/JsTestDriver/testsuite/mage/accordion/index.html

This file was deleted.

81 changes: 81 additions & 0 deletions dev/tests/js/jasmine/tests/lib/mage/accordion.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'mage/accordion'
], function ($) {
'use strict';

describe('Test for mage/accordion jQuery plugin', function () {
it('check if accordion can be initialized', function () {
var accordion = $("<div/>");

accordion.accordion();
expect(accordion.is(':mage-accordion')).toBeTruthy();

accordion.accordion('destroy');
expect(accordion.is(':mage-accordion')).toBeFalsy();
});
it('check one-collapsible element accordion', function () {
var accordion = $('<div/>'),
title1 = $('<div data-role="collapsible"></div>').appendTo(accordion),
content1 = $('<div data-role="content"></div>').appendTo(accordion),
title2 = $('<div data-role="collapsible"></div>').appendTo(accordion),
content2 = $('<div data-role="content"></div>').appendTo(accordion);

accordion.appendTo("body");

accordion.accordion();

expect(accordion.is(':mage-accordion')).toBeTruthy();

expect(content1.is(':visible')).toBeTruthy();
expect(content2.is(':hidden')).toBeTruthy();

title2.trigger('click');

expect(content1.is(':hidden')).toBeTruthy();
expect(content2.is(':visible')).toBeTruthy();

title1.trigger('click');

expect(content1.is(':visible')).toBeTruthy();
expect(content2.is(':hidden')).toBeTruthy();

accordion.accordion('destroy');

expect(accordion.is(':mage-accordion')).toBeFalsy();
});
it('check multi-collapsible element accordion', function () {
var accordion = $('<div/>');

$('<div data-role="collapsible"></div>').appendTo(accordion);

var content1 = $('<div data-role="content"></div>').appendTo(accordion),
title2 = $('<div data-role="collapsible"></div>').appendTo(accordion),
content2 = $('<div data-role="content"></div>').appendTo(accordion);

accordion.appendTo("body");

accordion.accordion({
multipleCollapsible: true
});

expect(accordion.is(':mage-accordion')).toBeTruthy();

expect(content1.is(':visible')).toBeTruthy();
expect(content2.is(':hidden')).toBeTruthy();

title2.trigger('click');

expect(content1.is(':visible')).toBeTruthy();
expect(content2.is(':visible')).toBeTruthy();

accordion.accordion('destroy');

expect(accordion.is(':mage-accordion')).toBeFalsy();
});
});
});

0 comments on commit ea56695

Please sign in to comment.