mirror of
https://github.com/mathuo/dockview
synced 2025-03-10 07:52:07 +00:00
Merge pull request #655 from mathuo/654-resize
bug: fix layout force flag
This commit is contained in:
commit
0211148b66
@ -66,6 +66,8 @@ class TestPanel implements IGridPanelView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ClassUnderTest extends BaseGrid<TestPanel> {
|
class ClassUnderTest extends BaseGrid<TestPanel> {
|
||||||
|
readonly gridview = this.gridview;
|
||||||
|
|
||||||
constructor(options: BaseGridOptions) {
|
constructor(options: BaseGridOptions) {
|
||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
@ -103,6 +105,31 @@ class ClassUnderTest extends BaseGrid<TestPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('baseComponentGridview', () => {
|
describe('baseComponentGridview', () => {
|
||||||
|
test('that .layout(...) force flag works', () => {
|
||||||
|
const cut = new ClassUnderTest({
|
||||||
|
parentElement: document.createElement('div'),
|
||||||
|
orientation: Orientation.HORIZONTAL,
|
||||||
|
proportionalLayout: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const spy = jest.spyOn(cut.gridview, 'layout');
|
||||||
|
|
||||||
|
cut.layout(100, 100);
|
||||||
|
expect(spy).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
cut.layout(100, 100, false);
|
||||||
|
expect(spy).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
cut.layout(100, 100, true);
|
||||||
|
expect(spy).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
|
cut.layout(150, 150, false);
|
||||||
|
expect(spy).toHaveBeenCalledTimes(3);
|
||||||
|
|
||||||
|
cut.layout(150, 150, true);
|
||||||
|
expect(spy).toHaveBeenCalledTimes(4);
|
||||||
|
});
|
||||||
|
|
||||||
test('can add group', () => {
|
test('can add group', () => {
|
||||||
const cut = new ClassUnderTest({
|
const cut = new ClassUnderTest({
|
||||||
parentElement: document.createElement('div'),
|
parentElement: document.createElement('div'),
|
||||||
|
@ -323,7 +323,7 @@ export abstract class BaseGrid<T extends IGridPanelView>
|
|||||||
|
|
||||||
public layout(width: number, height: number, forceResize?: boolean): void {
|
public layout(width: number, height: number, forceResize?: boolean): void {
|
||||||
const different =
|
const different =
|
||||||
forceResize ?? (width !== this.width || height !== this.height);
|
forceResize || width !== this.width || height !== this.height;
|
||||||
|
|
||||||
if (!different) {
|
if (!different) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user