This commit is contained in:
Sugui 2024-03-28 16:52:39 +01:00
parent 8b38f7bc1f
commit ba60669391
2 changed files with 3 additions and 2 deletions

View File

@ -5,7 +5,7 @@ import GelbooruApiService from "./GelbooruApiService";
class ImageService {
postsQueue: Image[] = [];
async get(): Promise<Image> {
while (this.postsQueue.length === 0) {
const validPosts = await this.getNewValidImages();
@ -13,6 +13,7 @@ class ImageService {
}
return this.postsQueue.pop() as Image;
}
private async getNewValidImages(): Promise<Image[]> {
const gelbooruResponse: GelbooruServiceResponse = await GelbooruApiService.get();
const posts = gelbooruResponse.posts;

View File

@ -1,4 +1,4 @@
import { afterEach, beforeAll, describe, expect, it, mock } from "bun:test";
import { describe, expect, it, mock } from "bun:test";
import Image from "../src/types/Image"
import ImageService from "../src/services/ImageService";
import GelbooruApiResponse from "../src/types/GelbooruServiceResponse";