docbrown/app/javascript/admin/__tests__/controllers/config_controller.test.js
Arit Amana e00cb5df17
[Team Email Login] Genericize AdminConfig Modal (#11145)
* Genericize AdminConfig Modal

* Rename function, add JSDoc documentation

* Tests for modal-building function

* Still trying to get jest test to pass

* Fix failing jest test
2020-10-29 15:01:37 -04:00

33 lines
955 B
JavaScript

import { Application } from 'stimulus';
import ConfigController from '../../controllers/config_controller';
describe('ConfigController', () => {
beforeEach(() => {
document.body.innerHTML = `<div data-controller="config">
<button data-action="click->config#activateEmailAuthModal">
Disable
</button>
<div data-target="config.configModalAnchor"></div>
</div>`;
global.scrollTo = jest.fn();
const application = Application.start();
application.register('config', ConfigController);
});
describe('#activateEmailAuthModal', () => {
it('builds and adds a Modal to the page', () => {
const button = document.querySelector('button');
const modalAnchor = document.querySelector(
'[data-target="config.configModalAnchor"]',
);
button.click();
expect(
modalAnchor.firstElementChild.classList.contains('crayons-modal'),
).toBe(true);
});
});
});