Split removal tests based on state of query
We now have special behaviour for removing an "in progress" query so the tests will be different. Let's have a separate section for "in progress" queries. We'll add extra behaviour testing in the next commit.
This commit is contained in:
Родитель
fa1f355b93
Коммит
ab0e67c251
|
@ -589,6 +589,7 @@ describe("query-history", () => {
|
|||
});
|
||||
|
||||
describe("when the item is a variant analysis", () => {
|
||||
describe("when in progress", () => {
|
||||
describe("when the item being removed is not selected", () => {
|
||||
let toDelete: VariantAnalysisHistoryItem;
|
||||
let selected: VariantAnalysisHistoryItem;
|
||||
|
@ -684,6 +685,104 @@ describe("query-history", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when not in progress", () => {
|
||||
describe("when the item being removed is not selected", () => {
|
||||
let toDelete: VariantAnalysisHistoryItem;
|
||||
let selected: VariantAnalysisHistoryItem;
|
||||
|
||||
beforeEach(async () => {
|
||||
// deleting the first item when a different item is selected
|
||||
// will not change the selection
|
||||
toDelete = variantAnalysisHistory[2];
|
||||
selected = variantAnalysisHistory[3];
|
||||
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
// initialize the selection
|
||||
await queryHistoryManager.treeView.reveal(
|
||||
variantAnalysisHistory[0],
|
||||
{
|
||||
select: true,
|
||||
},
|
||||
);
|
||||
|
||||
// select the item we want
|
||||
await queryHistoryManager.treeView.reveal(selected, {
|
||||
select: true,
|
||||
});
|
||||
|
||||
// should be selected
|
||||
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
|
||||
selected,
|
||||
);
|
||||
|
||||
// remove an item
|
||||
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
|
||||
toDelete,
|
||||
]);
|
||||
});
|
||||
|
||||
it("should remove the item", () => {
|
||||
expect(
|
||||
variantAnalysisManagerStub.removeVariantAnalysis,
|
||||
).toHaveBeenCalledWith(toDelete.variantAnalysis);
|
||||
expect(
|
||||
queryHistoryManager.treeDataProvider.allHistory,
|
||||
).not.toContain(toDelete);
|
||||
});
|
||||
|
||||
it("should not change the selection", () => {
|
||||
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
|
||||
selected,
|
||||
);
|
||||
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
|
||||
selected.variantAnalysis.id,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the item being removed is selected", () => {
|
||||
let toDelete: VariantAnalysisHistoryItem;
|
||||
let newSelected: VariantAnalysisHistoryItem;
|
||||
|
||||
beforeEach(async () => {
|
||||
// deleting the selected item automatically selects next item
|
||||
toDelete = variantAnalysisHistory[0];
|
||||
newSelected = variantAnalysisHistory[2];
|
||||
|
||||
queryHistoryManager = await createMockQueryHistory(
|
||||
variantAnalysisHistory,
|
||||
);
|
||||
|
||||
// select the item we want
|
||||
await queryHistoryManager.treeView.reveal(toDelete, {
|
||||
select: true,
|
||||
});
|
||||
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
|
||||
toDelete,
|
||||
]);
|
||||
});
|
||||
|
||||
it("should remove the item", () => {
|
||||
expect(
|
||||
variantAnalysisManagerStub.removeVariantAnalysis,
|
||||
).toHaveBeenCalledWith(toDelete.variantAnalysis);
|
||||
expect(
|
||||
queryHistoryManager.treeDataProvider.allHistory,
|
||||
).not.toContain(toDelete);
|
||||
});
|
||||
|
||||
it.skip("should change the selection", () => {
|
||||
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
|
||||
newSelected,
|
||||
);
|
||||
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
|
||||
newSelected.variantAnalysis.id,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleCancel", () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче