docbrown/app/javascript/admin/__tests__/controllers/config_controller.test.js
rhymes f9506affb5
Use faster JS selection methods (#11409)
* Add JS tips section to frontend documentation

* Replace document.getElementsByTagName('body') with document.body

* Replace querySelectorAll with faster selecting methods where appropriate

* Replace querySelector with faster selecting methods where appropriate

* Fix typo

* Fix forEach and getElementsByClassName

* Change querySelector* to faster methods in erb files

* Change querySelector* to faster methods in ruby files

* Fix runkit tag

* Various fixes

* Update app/assets/javascripts/initializers/initializeEllipsisMenu.js

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update app/assets/javascripts/utilities/slideSidebar.js

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Commenting out flaky spec

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2020-11-16 17:35:50 +01:00

33 lines
965 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.getElementsByTagName('button')[0];
const modalAnchor = document.querySelector(
'[data-target="config.configModalAnchor"]',
);
button.click();
expect(
modalAnchor.firstElementChild.classList.contains('crayons-modal'),
).toBe(true);
});
});
});