init commentPreview migration (#19090)
This commit is contained in:
parent
a4a54efc34
commit
0c8f301227
4 changed files with 23 additions and 6 deletions
|
|
@ -3,8 +3,7 @@
|
|||
initializeAllTagEditButtons, initializeUserFollowButts,
|
||||
initializeCommentsPage,
|
||||
initializeArticleDate, initializeArticleReactions, initNotifications,
|
||||
initializeSettings,
|
||||
initializeCommentPreview, initializeRuntimeBanner,
|
||||
initializeSettings, initializeRuntimeBanner,
|
||||
initializeTimeFixer, initializeDashboardSort,
|
||||
initializeArchivedPostFilter, initializeCreditsPage,
|
||||
initializeProfileInfoToggle, initializeDrawerSliders,
|
||||
|
|
@ -21,7 +20,6 @@ function callInitializers() {
|
|||
initializeArticleReactions();
|
||||
initNotifications();
|
||||
initializeSettings();
|
||||
initializeCommentPreview();
|
||||
initializeTimeFixer();
|
||||
initializeDashboardSort();
|
||||
initializeArchivedPostFilter();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { initializeCommentDate } from "./initializers/initializeCommentDate";
|
||||
import { initializeCommentDate } from './initializers/initializeCommentDate';
|
||||
import { initializeCommentPreview } from './initializers/initializeCommentPreview';
|
||||
|
||||
initializeCommentDate();
|
||||
initializeCommentDate();
|
||||
initializeCommentPreview();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
import { initializeCommentPreview } from '../initializeCommentPreview';
|
||||
|
||||
describe('initializeCommentPreview', () => {
|
||||
beforeEach(() => {
|
||||
const button = document.createElement('button');
|
||||
button.classList.add('preview-toggle');
|
||||
});
|
||||
|
||||
test('should call event listener when preview button exist', async () => {
|
||||
const button = document.createElement('button');
|
||||
button.classList.add('preview-toggle');
|
||||
button.addEventListener = jest.fn();
|
||||
initializeCommentPreview();
|
||||
|
||||
expect(button.addEventListener).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
@ -57,7 +57,7 @@ function handleCommentPreview(event) {
|
|||
}
|
||||
}
|
||||
|
||||
function initializeCommentPreview() {
|
||||
export function initializeCommentPreview() {
|
||||
const previewButton = document.getElementsByClassName('preview-toggle')[0];
|
||||
|
||||
if (!previewButton) {
|
||||
Loading…
Add table
Reference in a new issue