mirror of
				https://github.com/mathuo/dockview
				synced 2025-10-31 04:08:12 +00:00 
			
		
		
		
	chore: fix test
This commit is contained in:
		
							parent
							
								
									77bccb3f69
								
							
						
					
					
						commit
						4d71775804
					
				| @ -1,19 +1,16 @@ | |||||||
| import { DockviewApi } from '../../../../api/component.api'; | import { DockviewApi } from '../../../../api/component.api'; | ||||||
| import { Watermark } from '../../../../dockview/components/watermark/watermark'; | import { Watermark } from '../../../../dockview/components/watermark/watermark'; | ||||||
|  | import { fromPartial } from '@total-typescript/shoehorn'; | ||||||
| 
 | 
 | ||||||
| describe('watermark', () => { | describe('watermark', () => { | ||||||
|     test('that the group is closed when the close button is clicked', () => { |     test('that the group is closed when the close button is clicked', () => { | ||||||
|         const cut = new Watermark(); |         const cut = new Watermark(); | ||||||
| 
 |         const api = fromPartial<DockviewApi>({ | ||||||
|         const mockApi = jest.fn<Partial<DockviewApi>, any[]>(() => { |  | ||||||
|             return { |  | ||||||
|             removeGroup: jest.fn(), |             removeGroup: jest.fn(), | ||||||
|             }; |  | ||||||
|         }); |         }); | ||||||
|         const api = <DockviewApi>new mockApi(); |  | ||||||
|         const group = jest.fn() as any; |         const group = jest.fn() as any; | ||||||
| 
 | 
 | ||||||
|         cut.init({ containerApi: api }); |         cut.init({ containerApi: api, group }); | ||||||
| 
 | 
 | ||||||
|         const closeEl = cut.element.querySelector('.close-action')!; |         const closeEl = cut.element.querySelector('.close-action')!; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,8 +5,7 @@ import { | |||||||
| import { addDisposableListener } from '../../../events'; | import { addDisposableListener } from '../../../events'; | ||||||
| import { toggleClass } from '../../../dom'; | import { toggleClass } from '../../../dom'; | ||||||
| import { CompositeDisposable } from '../../../lifecycle'; | import { CompositeDisposable } from '../../../lifecycle'; | ||||||
| import { DockviewGroupPanel } from '../../dockviewGroupPanel'; | import { IDockviewGroupPanel } from '../../dockviewGroupPanel'; | ||||||
| import { PanelUpdateEvent } from '../../../panel/types'; |  | ||||||
| import { createCloseButton } from '../../../svg'; | import { createCloseButton } from '../../../svg'; | ||||||
| import { DockviewApi } from '../../../api/component.api'; | import { DockviewApi } from '../../../api/component.api'; | ||||||
| 
 | 
 | ||||||
| @ -15,7 +14,7 @@ export class Watermark | |||||||
|     implements IWatermarkRenderer |     implements IWatermarkRenderer | ||||||
| { | { | ||||||
|     private _element: HTMLElement; |     private _element: HTMLElement; | ||||||
|     private _group: DockviewGroupPanel | undefined; |     private _group: IDockviewGroupPanel | undefined; | ||||||
|     private _api: DockviewApi | undefined; |     private _api: DockviewApi | undefined; | ||||||
| 
 | 
 | ||||||
|     get element(): HTMLElement { |     get element(): HTMLElement { | ||||||
| @ -52,8 +51,9 @@ export class Watermark | |||||||
|         title.appendChild(actionsContainer); |         title.appendChild(actionsContainer); | ||||||
| 
 | 
 | ||||||
|         this.addDisposables( |         this.addDisposables( | ||||||
|             addDisposableListener(closeAnchor, 'click', (ev) => { |             addDisposableListener(closeAnchor, 'click', (event: MouseEvent) => { | ||||||
|                 ev.preventDefault(); |                 event.preventDefault(); | ||||||
|  | 
 | ||||||
|                 if (this._group) { |                 if (this._group) { | ||||||
|                     this._api?.removeGroup(this._group); |                     this._api?.removeGroup(this._group); | ||||||
|                 } |                 } | ||||||
| @ -61,29 +61,12 @@ export class Watermark | |||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     update(_event: PanelUpdateEvent): void { |  | ||||||
|         // noop
 |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     focus(): void { |  | ||||||
|         // noop
 |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     layout(_width: number, _height: number): void { |  | ||||||
|         // noop
 |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     init(_params: WatermarkRendererInitParameters): void { |     init(_params: WatermarkRendererInitParameters): void { | ||||||
|         this._api = _params.containerApi; |         this._api = _params.containerApi; | ||||||
|  |         this._group = _params.group; | ||||||
|         this.render(); |         this.render(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   |  | ||||||
| 
 |  | ||||||
|     dispose(): void { |  | ||||||
|         super.dispose(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private render(): void { |     private render(): void { | ||||||
|         const isOneGroup = !!(this._api && this._api.size <= 1); |         const isOneGroup = !!(this._api && this._api.size <= 1); | ||||||
|         toggleClass(this.element, 'has-actions', isOneGroup); |         toggleClass(this.element, 'has-actions', isOneGroup); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user