From: David Epely Date: Fri, 13 May 2016 12:52:37 +0000 (+0200) Subject: [JS-dropdown] no-reggression unit test for getPosition() X-Git-Tag: v6.2.4-rc1~55^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8785%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git [JS-dropdown] no-reggression unit test for getPosition() --- diff --git a/test/javascript/components/dropdown.js b/test/javascript/components/dropdown.js index 18c62daa5..7c1bdf47f 100644 --- a/test/javascript/components/dropdown.js +++ b/test/javascript/components/dropdown.js @@ -1,20 +1,55 @@ describe('Dropdown', function() { - var plugin; - var $html; + let plugin; + let $dropdownController; + let $dropdownContainer; - // afterEach(function() { - // plugin.destroy(); - // $html.remove(); - // }); + const getDropdownController = (buttonClasses = '') => + ``; + const getDropdownContainer = (dropdownClasses = '') => + `
Dropdown
`; - describe('constructor()', function() { - // it('', function() { - // $html = $('').appendTo('body'); - // plugin = new Foundation.Dropdown($html, {}); + afterEach(function() { + plugin.destroy(); + $dropdownController.remove(); + $dropdownContainer.remove(); + }); - // plugin.$element.should.be.an('object'); - // plugin.options.should.be.an('object'); - // }); - }); + describe('constructor()', function() { + it('stores the element & plugin options', function() { + $dropdownController = $(getDropdownController()).appendTo('body'); + $dropdownContainer = $(getDropdownContainer()).appendTo('body'); + plugin = new Foundation.Dropdown($dropdownContainer, {}); -}); \ No newline at end of file + plugin.$element.should.be.an('object'); + plugin.options.should.be.an('object'); + }); + }); + + describe('getPositionClass()', function() { + it('has no orientation', function() { + $dropdownController = $(getDropdownController()).appendTo('body'); + $dropdownContainer = $(getDropdownContainer()).appendTo('body'); + plugin = new Foundation.Dropdown($dropdownContainer, {}); + + plugin.getPositionClass().trim().should.equal(''); + }); + + it('has vertical position', function() { + $dropdownController = $(getDropdownController()).appendTo('body'); + $dropdownContainer = $(getDropdownContainer('custom-style-before bottom custom-style-after')) + .appendTo('body'); + plugin = new Foundation.Dropdown($dropdownContainer, {}); + + plugin.getPositionClass().trim().should.equal('bottom'); + }); + + it('has horizontal position', function() { + $dropdownController = $(getDropdownController('custom-style-before float-right custom-style-after')) + .appendTo('body'); + $dropdownContainer = $(getDropdownContainer()).appendTo('body'); + plugin = new Foundation.Dropdown($dropdownContainer, {}); + + plugin.getPositionClass().trim().should.equal('right'); + }); + }); +});