Skip to content

Commit

Permalink
refactor: adjust the search request to allow nullable values as well …
Browse files Browse the repository at this point in the history
…as undefined
  • Loading branch information
c43721 committed Nov 16, 2024
1 parent 9f81e96 commit d0700a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion javascript-sdk/logstf/api/logstf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function search(
params.append("map", map);
}

if (player.length > 0) {
if (player && player.length > 0) {
params.append("player", player.join(","));
}

Expand Down
11 changes: 8 additions & 3 deletions javascript-sdk/logstf/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ Deno.test("Getting an invalid log fails", async () => {
});

Deno.test("Searching logs works as expected", async () => {
const log = await search({ limit: 1 });
const searchA = await search({ limit: 1 });

assertEquals(log.success, true);
assertEquals(1, log.logs.length);
assertEquals(searchA.success, true);
assertEquals(1, searchA.logs.length);

const searchB = await search({ limit: 1, map: null });

assertEquals(searchB.success, true);
assertEquals(1, searchB.logs.length);
});
9 changes: 5 additions & 4 deletions javascript-sdk/logstf/types/endpoints/logSearchRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ export type LogSearchRequest = {
/**
* The title of the log
*/
title?: string;
title?: string | null;

/**
* The map of the log
*/
map?: string;
map?: string | null;

/**
* The steamid of the uploader
*/
uploader?: string;
uploader?: string | null;

/**
* The list of steamids that played in the log
*/
player?: string[];
player?: string[] | null;

/**
* The number of entries to return
Expand Down

0 comments on commit d0700a6

Please sign in to comment.