| 
 | 1 | +/*  | 
 | 2 | +Copyright 2023 Nordeck IT + Consulting 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 { RuntimeModule } from "../../src";  | 
 | 18 | +import { ViewRoomListener, ViewRoomOpts, RoomViewLifecycle } from "../../src/lifecycles/RoomViewLifecycle";  | 
 | 19 | + | 
 | 20 | +describe("RoomViewLifecycle", () => {  | 
 | 21 | +    const roomHeaderOpts: ViewRoomOpts = {  | 
 | 22 | +        buttons: [  | 
 | 23 | +            {  | 
 | 24 | +                icon: "test-icon",  | 
 | 25 | +                id: "test-id",  | 
 | 26 | +                label: () => "test-label",  | 
 | 27 | +                onClick: () => {},  | 
 | 28 | +            },  | 
 | 29 | +        ],  | 
 | 30 | +    };  | 
 | 31 | + | 
 | 32 | +    let module: RuntimeModule;  | 
 | 33 | + | 
 | 34 | +    beforeAll(() => {  | 
 | 35 | +        module = new (class extends RuntimeModule {  | 
 | 36 | +            public constructor() {  | 
 | 37 | +                super(undefined as any);  | 
 | 38 | + | 
 | 39 | +                this.on(RoomViewLifecycle.ViewRoom, this.renderRoomHeaderListener);  | 
 | 40 | +            }  | 
 | 41 | + | 
 | 42 | +            protected renderRoomHeaderListener: ViewRoomListener = (opts, roomId) => {  | 
 | 43 | +                opts.buttons = roomHeaderOpts.buttons;  | 
 | 44 | +            };  | 
 | 45 | +        })();  | 
 | 46 | +    });  | 
 | 47 | + | 
 | 48 | +    it("should handle additional buttons", () => {  | 
 | 49 | +        const opts: ViewRoomOpts = { buttons: [] };  | 
 | 50 | +        module.emit(RoomViewLifecycle.ViewRoom, opts);  | 
 | 51 | +        expect(opts).toEqual(roomHeaderOpts);  | 
 | 52 | +    });  | 
 | 53 | +});  | 
0 commit comments