|
| 1 | +/* |
| 2 | + * Copyright 2023 Code Intelligence GmbH |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { |
| 18 | + getCallbacks, |
| 19 | + registerAfterEachCallback, |
| 20 | + registerBeforeEachCallback, |
| 21 | +} from "./callback"; |
| 22 | + |
| 23 | +describe("callbacks", () => { |
| 24 | + beforeEach(() => { |
| 25 | + globalThis.JazzerJS = new Map(); |
| 26 | + }); |
| 27 | + |
| 28 | + it("executes registered beforeEach callbacks", () => { |
| 29 | + const callback = jest.fn(); |
| 30 | + registerBeforeEachCallback(callback); |
| 31 | + registerBeforeEachCallback(callback); |
| 32 | + registerBeforeEachCallback(callback); |
| 33 | + const callbacks = getCallbacks(); |
| 34 | + callbacks.runBeforeEachCallbacks(); |
| 35 | + expect(callback).toBeCalledTimes(3); |
| 36 | + }); |
| 37 | + |
| 38 | + it("executes registered afterEach callbacks", () => { |
| 39 | + const callback = jest.fn(); |
| 40 | + registerAfterEachCallback(callback); |
| 41 | + registerAfterEachCallback(callback); |
| 42 | + registerAfterEachCallback(callback); |
| 43 | + const callbacks = getCallbacks(); |
| 44 | + callbacks.runAfterEachCallbacks(); |
| 45 | + expect(callback).toBeCalledTimes(3); |
| 46 | + }); |
| 47 | +}); |
0 commit comments