]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/lexical/utils/__tests__/unit/mergeRegister.test.ts
Lexical: Imported core lexical libs
[bookstack] / resources / js / wysiwyg / lexical / utils / __tests__ / unit / mergeRegister.test.ts
1 /**
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  *
7  */
8 import {mergeRegister} from '@lexical/utils';
9
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);
15   });
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]);
20   });
21 });