Skip to content

Commit 425befa

Browse files
committed
Add tests
1 parent 1050968 commit 425befa

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

extensions/ql-vscode/test/pure-tests/databases/db-item-selection.test.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,88 @@ describe("db item selection", () => {
191191
selected: true,
192192
});
193193
});
194+
195+
it("should handle arbitrary list of db items", () => {
196+
const dbItems: DbItem[] = [
197+
{
198+
kind: DbItemKind.RootRemote,
199+
children: [
200+
{
201+
kind: DbItemKind.RemoteSystemDefinedList,
202+
listName: "top_10",
203+
listDisplayName: "Top 10 repositories",
204+
listDescription: "Top 10 repositories of a language",
205+
selected: false,
206+
},
207+
{
208+
kind: DbItemKind.RemoteOwner,
209+
ownerName: "github",
210+
selected: false,
211+
},
212+
{
213+
kind: DbItemKind.RemoteUserDefinedList,
214+
listName: "my list",
215+
repos: [
216+
{
217+
kind: DbItemKind.RemoteRepo,
218+
repoFullName: "owner1/repo2",
219+
selected: false,
220+
},
221+
{
222+
kind: DbItemKind.RemoteRepo,
223+
repoFullName: "owner1/repo3",
224+
selected: false,
225+
},
226+
],
227+
selected: false,
228+
},
229+
],
230+
},
231+
{
232+
kind: DbItemKind.RemoteSystemDefinedList,
233+
listName: "top_10",
234+
listDisplayName: "Top 10 repositories",
235+
listDescription: "Top 10 repositories of a language",
236+
selected: true,
237+
},
238+
];
239+
240+
expect(getSelectedDbItem(dbItems)).toEqual({
241+
kind: DbItemKind.RemoteSystemDefinedList,
242+
listName: "top_10",
243+
listDisplayName: "Top 10 repositories",
244+
listDescription: "Top 10 repositories of a language",
245+
selected: true,
246+
});
247+
});
248+
249+
it("should handle empty db item lists", () => {
250+
const dbItems: DbItem[] = [
251+
{
252+
kind: DbItemKind.RootRemote,
253+
children: [
254+
{
255+
kind: DbItemKind.RemoteSystemDefinedList,
256+
listName: "top_10",
257+
listDisplayName: "Top 10 repositories",
258+
listDescription: "Top 10 repositories of a language",
259+
selected: false,
260+
},
261+
{
262+
kind: DbItemKind.RemoteOwner,
263+
ownerName: "github",
264+
selected: false,
265+
},
266+
{
267+
kind: DbItemKind.RemoteUserDefinedList,
268+
listName: "my list",
269+
repos: [],
270+
selected: false,
271+
},
272+
],
273+
},
274+
];
275+
276+
expect(getSelectedDbItem(dbItems)).toBeUndefined();
277+
});
194278
});

0 commit comments

Comments
 (0)