Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Sep 30, 2023
1 parent 4c142b9 commit fc1c747
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions packages/dockview-core/src/__tests__/splitview/splitview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,100 @@ describe('splitview', () => {
expect(addEventListenerSpy).toBeCalledTimes(3);
expect(removeEventListenerSpy).toBeCalledTimes(3);
});

test('setViewVisible', () => {
const splitview = new Splitview(container, {
orientation: Orientation.HORIZONTAL,
proportionalLayout: false,
});
splitview.layout(900, 500);

const view1 = new Testview(0, 1000);
const view2 = new Testview(0, 1000);
const view3 = new Testview(0, 1000);

splitview.addView(view1);
splitview.addView(view2);
splitview.addView(view3);

expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);

splitview.setViewVisible(0, false);
expect([view1.size, view2.size, view3.size]).toEqual([0, 300, 600]);

splitview.setViewVisible(0, true);
expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);
});

test('setViewVisible with one view having high layout priority', () => {
const splitview = new Splitview(container, {
orientation: Orientation.HORIZONTAL,
proportionalLayout: false,
});
splitview.layout(900, 500);

const view1 = new Testview(0, 1000);
const view2 = new Testview(0, 1000, LayoutPriority.High);
const view3 = new Testview(0, 1000);

splitview.addView(view1);
splitview.addView(view2);
splitview.addView(view3);

expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);

splitview.setViewVisible(0, false);
expect([view1.size, view2.size, view3.size]).toEqual([0, 600, 300]);

splitview.setViewVisible(0, true);
expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);
});

test('set view size', () => {
const splitview = new Splitview(container, {
orientation: Orientation.HORIZONTAL,
proportionalLayout: false,
});
splitview.layout(900, 500);

const view1 = new Testview(0, 1000);
const view2 = new Testview(0, 1000);
const view3 = new Testview(0, 1000);

splitview.addView(view1);
splitview.addView(view2);
splitview.addView(view3);

expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);

view1.fireChangeEvent({ size: 0 });
expect([view1.size, view2.size, view3.size]).toEqual([0, 300, 600]);

view1.fireChangeEvent({ size: 300 });
expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);
});

test('set view size with one view having high layout priority', () => {
const splitview = new Splitview(container, {
orientation: Orientation.HORIZONTAL,
proportionalLayout: false,
});
splitview.layout(900, 500);

const view1 = new Testview(0, 1000);
const view2 = new Testview(0, 1000, LayoutPriority.High);
const view3 = new Testview(0, 1000);

splitview.addView(view1);
splitview.addView(view2);
splitview.addView(view3);

expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);

view1.fireChangeEvent({ size: 0 });
expect([view1.size, view2.size, view3.size]).toEqual([0, 600, 300]);

view1.fireChangeEvent({ size: 300 });
expect([view1.size, view2.size, view3.size]).toEqual([300, 300, 300]);
});
});

0 comments on commit fc1c747

Please sign in to comment.