Skip to content

Commit

Permalink
[test] 为tab通过浏览器关闭,后又双击打开报错的bug增加测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
GarinZ committed Mar 15, 2023
1 parent 182eeb8 commit fa1096f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/tree/fancy-tab-master-tree/browser-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,31 @@ describe('remove tab', () => {
});

it('remove tab with alias', async () => {
const treeData = new MockTreeBuilder().addTabChildren(1, 1, { alias: 'test' }).build();
const treeData = new MockTreeBuilder().addTabChildren(2, 1, { alias: 'test' }).build();
const tabMasterTree = initTabMasterTree(treeData);
browser.tabs.query.resolves(() => ({
tabs: [],
}));
browser.tabs.query.resolves([{ id: 12, active: true }]);
const tree = tabMasterTree.tree;
const sourceNode = tree.getNodeByKey(`11`);
console.log(toAsciiTree(tree.toDict(), ['expanded'], ['closed', 'windowId']));
await tabMasterTree.removeTab(sourceNode.data.id);
console.log(toAsciiTree(tree.toDict(), ['expanded'], ['closed', 'windowId']));
const windowNode = tree.getNodeByKey('1');
expect(windowNode.children.length).toEqual(1);
const secondNode = tree.getNodeByKey(`12`);
expect(windowNode.children.length).toEqual(2);
expect(windowNode.data.closed).toEqual(false);
expect(sourceNode.data.closed).toEqual(true);
expect(sourceNode.data.active).toEqual(false);
expect(secondNode.data.closed).toEqual(false);
expect(secondNode.data.active).toEqual(true);
browser.tabs.query.resolves([]);
await tabMasterTree.removeTab(secondNode.data.id);
expect(windowNode.children.length).toEqual(2);
expect(windowNode.data.closed).toEqual(true);
expect(sourceNode.data.closed).toEqual(true);
expect(sourceNode.data.active).toEqual(false);
expect(sourceNode.data.active).toEqual(false);
expect(secondNode.data.closed).toEqual(true);
expect(secondNode.data.active).toEqual(false);
});
});

Expand Down

0 comments on commit fa1096f

Please sign in to comment.