blob: ed47cdc2386538c423b7906038e2960b2afa9b6d [file] [log] [blame]
rniwa@webkit.org9c6a6402017-01-19 22:58:46 +00001
2describe('CloseButton', () => {
rniwa@webkit.org3ac7cd52018-06-07 18:25:35 +00003 const scripts = ['instrumentation.js', '../shared/common-component-base.js', 'components/base.js', 'components/button-base.js', 'components/close-button.js'];
rniwa@webkit.org9c6a6402017-01-19 22:58:46 +00004
5 it('must dispatch "activate" action when the anchor is clicked', () => {
6 const context = new BrowsingContext();
7 return context.importScripts(scripts, 'CloseButton').then((CloseButton) => {
8 const closeButton = new CloseButton;
9 context.document.body.appendChild(closeButton.element());
10
11 closeButton.content().querySelector('a').click();
12
13 let activateCount = 0;
14 closeButton.listenToAction('activate', () => {
15 activateCount++;
16 });
rniwa@webkit.orgd8153312017-02-17 05:36:05 +000017 expect(activateCount).to.be(0);
rniwa@webkit.org9c6a6402017-01-19 22:58:46 +000018 closeButton.content().querySelector('a').click();
rniwa@webkit.orgd8153312017-02-17 05:36:05 +000019 expect(activateCount).to.be(1);
rniwa@webkit.org9c6a6402017-01-19 22:58:46 +000020 closeButton.content().querySelector('a').click();
rniwa@webkit.orgd8153312017-02-17 05:36:05 +000021 expect(activateCount).to.be(2);
rniwa@webkit.org9c6a6402017-01-19 22:58:46 +000022 });
23 });
24
25});