Spaces:
Sleeping
Sleeping
File size: 4,412 Bytes
19e88d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | import { describe, expect, it } from "vitest";
import { listCollections } from "./list-collections";
import type { ApiCollectionInfo } from "../types/api/api-collection";
describe("listCollections", () => {
it("should list collections", async () => {
const results: ApiCollectionInfo[] = [];
for await (const entry of listCollections({
search: { owner: ["huggingfacejs"] },
})) {
results.push(entry);
}
expect(results.length).toBe(1);
const itemTypes = results[0].items.map((item) => item.type);
expect(itemTypes).toEqual(["dataset", "collection", "space", "paper"]);
expect(results).toEqual([
{
slug: "huggingfacejs/test-collection-690df2897fa1945492b8cf42",
title: "Test Collection",
description: "Only used in E2E tests",
gating: false,
lastUpdated: expect.any(String),
owner: {
_id: "6414d83b385a75d7790d5a58",
avatarUrl: expect.any(String),
fullname: "Huggingface.js",
name: "huggingfacejs",
type: "org",
followerCount: expect.any(Number),
isHf: false,
isHfAdmin: false,
isMod: false,
isUserFollowing: expect.any(Boolean),
},
items: [
{
_id: "690df2a467ea25a1a346d0ae",
author: "huggingfacejs",
datasetsServerInfo: {
formats: expect.any(Array),
libraries: expect.any(Array),
modalities: expect.any(Array),
numRows: expect.any(Number),
viewer: expect.any(String),
},
downloads: expect.any(Number),
gated: false,
id: "huggingfacejs/tasks",
isBenchmark: false,
isLikedByUser: false,
lastModified: expect.any(String),
likes: expect.any(Number),
position: 0,
private: false,
repoType: "dataset",
type: "dataset",
},
{
_id: "690df2b1954547dac9727da3",
description: "Only used in E2E tests",
id: "690df2897fa1945492b8cf42",
isUpvotedByUser: false,
lastUpdated: expect.any(String),
numberItems: 5,
owner: {
_id: "6414d83b385a75d7790d5a58",
avatarUrl: expect.any(String),
followerCount: expect.any(Number),
fullname: "Huggingface.js",
isHf: false,
isHfAdmin: false,
isMod: false,
isUserFollowing: expect.any(Boolean),
name: "huggingfacejs",
type: "org",
},
position: 1,
shareUrl: "https://hf.co/collections/huggingfacejs/test-collection",
slug: "huggingfacejs/test-collection-690df2897fa1945492b8cf42",
theme: "pink",
title: "Test Collection",
type: "collection",
upvotes: expect.any(Number),
},
{
_id: "690df2c49f252aa897a873b2",
ai_category: "Model Benchmarking",
ai_short_description: "Upload ML models to Hugging Face Hub from your browser",
author: "huggingfacejs",
authorData: {
_id: "6414d83b385a75d7790d5a58",
avatarUrl: expect.any(String),
followerCount: expect.any(Number),
fullname: "Huggingface.js",
isHf: false,
isHfAdmin: false,
isMod: false,
isUserFollowing: expect.any(Boolean),
name: "huggingfacejs",
type: "org",
},
colorFrom: "green",
colorTo: "green",
createdAt: "2023-03-17T21:33:16.000Z",
emoji: "🌎",
featured: false,
id: "huggingfacejs/push-model-from-web",
isLikedByUser: false,
lastModified: expect.any(String),
likes: 1,
pinned: false,
position: 2,
private: false,
repoType: "space",
runtime: {
hardware: {
current: null,
requested: null,
},
replicas: {
current: 1,
requested: 1,
},
stage: "RUNNING",
storage: null,
},
sdk: "static",
tags: ["static", "region:us"],
title: "Push Model From Web",
trendingScore: 0,
type: "space",
},
{
_id: "690df2d0c9390ed6ab0f88b1",
id: "2510.04871",
isUpvotedByUser: false,
position: 3,
publishedAt: "2025-10-06T14:58:08.000Z",
thumbnailUrl: "https://cdn-thumbnails.huggingface.co/social-thumbnails/papers/2510.04871.png",
title: "Less is More: Recursive Reasoning with Tiny Networks",
type: "paper",
upvotes: expect.any(Number),
},
],
theme: "pink",
private: false,
upvotes: expect.any(Number),
isUpvotedByUser: false,
},
]);
});
});
|