/* global beforeEach, describe, it, expect, jasmine, mw, $ */ describe('Portable Infobox', function () { describe('collapsible sections', function () { var portableInfoboxHtml = `

Bugged

`, div = document.createElement('div'); beforeEach(function () { div.innerHTML = portableInfoboxHtml; mw.hook('wikipage.content').fire($(div)); }); it('collapsed state is toggled on collapsible header click', function () { var portableInfoboxHeader = div.querySelector('.pi-header'); portableInfoboxHeader.click(); expect(div.querySelector('.pi-collapse').className).toContain('pi-collapse-closed'); portableInfoboxHeader.click(); expect(div.querySelector('.pi-collapse').className).not.toContain('pi-collapse-closed'); }); it('emit global scroll event on collapsible header click', function () { var portableInfoboxHeader = div.querySelector('.pi-header'), scrollSpy = jasmine.createSpy('scrollSpy'); $(window).on('scroll', scrollSpy); portableInfoboxHeader.click(); portableInfoboxHeader.click(); expect(scrollSpy).toHaveBeenCalledTimes(2); }); }); });