Skip to content

Commit 41256ec

Browse files
committed
Make it a little clearer which function the tests are checking
1 parent 74581fb commit 41256ec

1 file changed

Lines changed: 41 additions & 33 deletions

File tree

extensions/ql-vscode/test/vscode-tests/minimal-workspace/databases.test.ts

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,31 @@ describe("databases", () => {
122122
});
123123
});
124124

125-
it("should rename a db item and emit an event", async () => {
126-
const mockDbItem = createMockDB();
127-
const onDidChangeDatabaseItem = jest.fn();
128-
databaseManager.onDidChangeDatabaseItem(onDidChangeDatabaseItem);
129-
await (databaseManager as any).addDatabaseItem(
130-
{} as ProgressCallback,
131-
{} as CancellationToken,
132-
mockDbItem,
133-
);
125+
describe("renameDatabaseItem", () => {
126+
it("should rename a db item and emit an event", async () => {
127+
const mockDbItem = createMockDB();
128+
const onDidChangeDatabaseItem = jest.fn();
129+
databaseManager.onDidChangeDatabaseItem(onDidChangeDatabaseItem);
130+
await (databaseManager as any).addDatabaseItem(
131+
{} as ProgressCallback,
132+
{} as CancellationToken,
133+
mockDbItem,
134+
);
134135

135-
await databaseManager.renameDatabaseItem(mockDbItem, "new name");
136+
await databaseManager.renameDatabaseItem(mockDbItem, "new name");
136137

137-
expect(mockDbItem.name).toBe("new name");
138-
expect(updateSpy).toBeCalledWith("databaseList", [
139-
{
140-
options: { ...MOCK_DB_OPTIONS, displayName: "new name" },
141-
uri: dbLocationUri().toString(true),
142-
},
143-
]);
138+
expect(mockDbItem.name).toBe("new name");
139+
expect(updateSpy).toBeCalledWith("databaseList", [
140+
{
141+
options: { ...MOCK_DB_OPTIONS, displayName: "new name" },
142+
uri: dbLocationUri().toString(true),
143+
},
144+
]);
144145

145-
expect(onDidChangeDatabaseItem).toBeCalledWith({
146-
item: undefined,
147-
kind: DatabaseEventKind.Rename,
146+
expect(onDidChangeDatabaseItem).toBeCalledWith({
147+
item: undefined,
148+
kind: DatabaseEventKind.Rename,
149+
});
148150
});
149151
});
150152

@@ -378,20 +380,26 @@ describe("databases", () => {
378380
});
379381
});
380382

381-
it("should get the primary language", async () => {
382-
resolveDatabaseSpy.mockResolvedValue({
383-
languages: ["python"],
384-
} as unknown as DbInfo);
385-
const result = await (databaseManager as any).getPrimaryLanguage("hucairz");
386-
expect(result).toBe("python");
387-
});
383+
describe("getPrimaryLanguage", () => {
384+
it("should get the primary language", async () => {
385+
resolveDatabaseSpy.mockResolvedValue({
386+
languages: ["python"],
387+
} as unknown as DbInfo);
388+
const result = await (databaseManager as any).getPrimaryLanguage(
389+
"hucairz",
390+
);
391+
expect(result).toBe("python");
392+
});
388393

389-
it("should handle missing the primary language", async () => {
390-
resolveDatabaseSpy.mockResolvedValue({
391-
languages: [],
392-
} as unknown as DbInfo);
393-
const result = await (databaseManager as any).getPrimaryLanguage("hucairz");
394-
expect(result).toBe("");
394+
it("should handle missing the primary language", async () => {
395+
resolveDatabaseSpy.mockResolvedValue({
396+
languages: [],
397+
} as unknown as DbInfo);
398+
const result = await (databaseManager as any).getPrimaryLanguage(
399+
"hucairz",
400+
);
401+
expect(result).toBe("");
402+
});
395403
});
396404

397405
describe("isAffectedByTest", () => {

0 commit comments

Comments
 (0)