UNPKG

yt-dlx

Version:

Effortless Audio-Video Downloader And Streamer!

99 lines 4.75 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Single_1 = __importDefault(require("../../../../routes/Search/Video/Single")); const vitest = __importStar(require("vitest")); vitest.describe("videoData", () => { const rawVideoId = "dQw4w9WgXcQ"; const invalidVideoLink = "this is not a youtube link"; const shortenedVideoLink = "https://youtu.be/dQw4w9WgXcQ"; const validVideoLink = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; const nonexistentVideoLink = "https://www.youtube.com/watch?v=nonexistentvideoid123"; vitest.it("should handle basic video data fetch with standard link", async () => { try { const result = await (0, Single_1.default)({ videoLink: validVideoLink }); vitest.expect(result).toHaveProperty("id"); vitest.expect(typeof result.id).toBe("string"); vitest.expect(result).toHaveProperty("title"); vitest.expect(typeof result.title).toBe("string"); vitest.expect(result).toHaveProperty("duration"); vitest.expect(typeof result.duration).toBe("number"); vitest.expect(result).toHaveProperty("viewCount"); vitest.expect(typeof result.viewCount).toBe("number"); vitest.expect(result).toHaveProperty("channelid"); vitest.expect(typeof result.channelid).toBe("string"); vitest.expect(result).toHaveProperty("channelname"); vitest.expect(typeof result.channelname).toBe("string"); } catch (error) { console.warn(`Basic video data fetch failed for ${validVideoLink}. This might require a real video link.`, error); throw error; } }); vitest.it("should handle video data fetch with shortened link", async () => { try { const result = await (0, Single_1.default)({ videoLink: shortenedVideoLink }); vitest.expect(result).toHaveProperty("id"); vitest.expect(typeof result.id).toBe("string"); vitest.expect(result).toHaveProperty("title"); vitest.expect(typeof result.title).toBe("string"); vitest.expect(result).toHaveProperty("duration"); vitest.expect(typeof result.duration).toBe("number"); } catch (error) { console.warn(`Video data fetch failed for ${shortenedVideoLink}. This might require a real video link.`, error); throw error; } }); vitest.it("should handle video data fetch with raw video ID", async () => { try { const result = await (0, Single_1.default)({ videoLink: rawVideoId }); vitest.expect(result).toHaveProperty("id"); vitest.expect(typeof result.id).toBe("string"); vitest.expect(result).toHaveProperty("title"); vitest.expect(typeof result.title).toBe("string"); vitest.expect(result).toHaveProperty("duration"); vitest.expect(typeof result.duration).toBe("number"); } catch (error) { console.warn(`Video data fetch failed for ${rawVideoId}. This might require a real video ID.`, error); throw error; } }); }); //# sourceMappingURL=SIngle.test.js.map