Skip to content

Commit

Permalink
Enhance Capture class with fetch methods
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunkomath committed Jan 12, 2025
1 parent a7c3283 commit ea9b5e1
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 198 deletions.
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

136 changes: 68 additions & 68 deletions __tests__/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,81 @@ import { Capture } from "../dist";

const capture = new Capture("test", "test");

describe("Capture URL Builder", function () {
describe("Image Requests", function () {
it("should be an object", function () {
expect(capture).toHaveProperty("buildImageUrl");
expect(capture.buildImageUrl).toBeInstanceOf(Function);
});
describe("Capture URL Builder", () => {
describe("Image Requests", () => {
it("should be an object", () => {
expect(capture).toHaveProperty("buildImageUrl");
expect(capture.buildImageUrl).toBeInstanceOf(Function);
});

it("buildImageUrl should return valid url", function () {
const url = capture.buildImageUrl("https://news.ycombinator.com/");
console.log(url);
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/image?url=https%3A%2F%2Fnews.ycombinator.com%2F"
);
});
it("buildImageUrl should return valid url", () => {
const url = capture.buildImageUrl("https://news.ycombinator.com/");
console.log(url);
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/image?url=https%3A%2F%2Fnews.ycombinator.com%2F",
);
});

it("buildImageUrl with options should return valid url", function () {
const url = capture.buildImageUrl("https://capture.techulus.in/", {
full: true,
delay: 3,
});
expect(url).toBe(
"https://cdn.capture.techulus.in/test/2cb8b7ed9dbdb5c0db4a5dc4523a0780/image?full=true&delay=3&url=https%3A%2F%2Fcapture.techulus.in%2F"
);
});
});
it("buildImageUrl with options should return valid url", () => {
const url = capture.buildImageUrl("https://capture.techulus.in/", {
full: true,
delay: 3,
});
expect(url).toBe(
"https://cdn.capture.techulus.in/test/2cb8b7ed9dbdb5c0db4a5dc4523a0780/image?full=true&delay=3&url=https%3A%2F%2Fcapture.techulus.in%2F",
);
});
});

describe("PDF Requests", () => {
it("should be an object", function () {
expect(capture).toHaveProperty("buildPdfUrl");
expect(capture.buildPdfUrl).toBeInstanceOf(Function);
});
describe("PDF Requests", () => {
it("should be an object", () => {
expect(capture).toHaveProperty("buildPdfUrl");
expect(capture.buildPdfUrl).toBeInstanceOf(Function);
});

it("buildPdfUrl should return valid url", function () {
const url = capture.buildPdfUrl("https://news.ycombinator.com/");
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/pdf?url=https%3A%2F%2Fnews.ycombinator.com%2F"
);
});
it("buildPdfUrl should return valid url", () => {
const url = capture.buildPdfUrl("https://news.ycombinator.com/");
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/pdf?url=https%3A%2F%2Fnews.ycombinator.com%2F",
);
});

it("buildPdfUrl with options should return valid url", function () {
const url = capture.buildPdfUrl("https://capture.techulus.in/", {
full: true,
delay: 3,
});
expect(url).toBe(
"https://cdn.capture.techulus.in/test/2cb8b7ed9dbdb5c0db4a5dc4523a0780/pdf?full=true&delay=3&url=https%3A%2F%2Fcapture.techulus.in%2F"
);
});
});
it("buildPdfUrl with options should return valid url", () => {
const url = capture.buildPdfUrl("https://capture.techulus.in/", {
full: true,
delay: 3,
});
expect(url).toBe(
"https://cdn.capture.techulus.in/test/2cb8b7ed9dbdb5c0db4a5dc4523a0780/pdf?full=true&delay=3&url=https%3A%2F%2Fcapture.techulus.in%2F",
);
});
});

describe("Content Requests", () => {
it("should be an object", function () {
expect(capture).toHaveProperty("buildContentUrl");
expect(capture.buildContentUrl).toBeInstanceOf(Function);
});
describe("Content Requests", () => {
it("should be an object", () => {
expect(capture).toHaveProperty("buildContentUrl");
expect(capture.buildContentUrl).toBeInstanceOf(Function);
});

it("buildContentUrl should return valid url", function () {
const url = capture.buildContentUrl("https://news.ycombinator.com/");
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/content?url=https%3A%2F%2Fnews.ycombinator.com%2F"
);
});
});
it("buildContentUrl should return valid url", () => {
const url = capture.buildContentUrl("https://news.ycombinator.com/");
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/content?url=https%3A%2F%2Fnews.ycombinator.com%2F",
);
});
});

describe("Metadata Requests", () => {
it("should be an object", function () {
expect(capture).toHaveProperty("buildMetadataUrl");
expect(capture.buildMetadataUrl).toBeInstanceOf(Function);
});
describe("Metadata Requests", () => {
it("should be an object", () => {
expect(capture).toHaveProperty("buildMetadataUrl");
expect(capture.buildMetadataUrl).toBeInstanceOf(Function);
});

it("buildMetadataUrl should return valid url", function () {
const url = capture.buildMetadataUrl("https://news.ycombinator.com/");
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/metadata?url=https%3A%2F%2Fnews.ycombinator.com%2F"
);
});
});
it("buildMetadataUrl should return valid url", () => {
const url = capture.buildMetadataUrl("https://news.ycombinator.com/");
expect(url).toBe(
"https://cdn.capture.techulus.in/test/f37d5fb3ee4540a05bf4ffeed6dffa28/metadata?url=https%3A%2F%2Fnews.ycombinator.com%2F",
);
});
});
});
10 changes: 5 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};
30 changes: 30 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist", "node_modules", "package.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
Loading

0 comments on commit ea9b5e1

Please sign in to comment.