2 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
8 import {mergeRegister} from '@lexical/utils';
10 describe('mergeRegister', () => {
11 it('calls all of the clean-up functions', () => {
12 const cleanup = jest.fn();
13 mergeRegister(cleanup, cleanup)();
14 expect(cleanup).toHaveBeenCalledTimes(2);
16 it('calls the clean-up functions in reverse order', () => {
17 const cleanup = jest.fn();
18 mergeRegister(cleanup.bind(null, 1), cleanup.bind(null, 2))();
19 expect(cleanup.mock.calls.map(([v]) => v)).toEqual([2, 1]);