import { download, downloadMultiple } from "../mod.ts";

const url = "https://picsum.photos/500/300";
const urls: string[] = [];
for (let i = 0; i < 25; i++) urls.push(url);

Deno.test({
  name: "Download file",
  async fn() {
    await download(url, { filename: "image.png" })
      .then((data) => console.log(data))
      .catch((err) => console.error(err));
  },
});

Deno.test({
  name: "Download file to folder",
  async fn() {
    await download(url, {
      filename: "image.png",
      folder: ["images", "picsum"],
    })
      .then((data) => console.log(data))
      .catch((err) => console.error(err));
  },
});

Deno.test({
  name: "Multiple download",
  async fn() {
    await downloadMultiple(
      urls,
      { filename: "image.png" },
    ).then((data) => console.log(data)).catch(
      (err) => console.error(err),
    );
  },
});

Deno.test({
  name: "Multiple download to folder",
  async fn() {
    await downloadMultiple(urls, {
      filename: "image.png",
      folder: ["images", "picsum"],
    }).then((data) => console.log(data)).catch(
      (err) => console.error(err),
    );
  },
});
