@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
31 lines (30 loc) • 1.25 kB
JavaScript
import '../../actions/print-action';
import { ESLShareActionRegistry } from '../../core/esl-share-action-registry';
import { ESLShareButton } from '../../core/esl-share-button';
describe('ESLShare: "print" action import', () => {
test('"print" action was registered when importing', () => {
expect(ESLShareActionRegistry.instance.has('print')).toBe(true);
});
});
describe('ESLShare: "print" action public API', () => {
const printAction = ESLShareActionRegistry.instance.get('print');
const $button = ESLShareButton.create();
beforeAll(() => {
ESLShareButton.register();
document.body.appendChild($button);
$button.setAttribute('share-title', 'Test button title');
$button.setAttribute('share-url', '/test/button/url');
});
afterEach(() => {
jest.clearAllMocks();
});
afterAll(() => {
document.body.innerHTML = '';
jest.restoreAllMocks();
});
test('should call window.print() when share() calls', () => {
const mockPrint = jest.spyOn(window, 'print').mockImplementation(() => null);
printAction === null || printAction === void 0 ? void 0 : printAction.share($button);
expect(mockPrint).toBeCalled();
});
});