Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 2, 2024
2 parents 997c1f3 + 473f0cf commit 8fdced7
Show file tree
Hide file tree
Showing 35 changed files with 759 additions and 193 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tests/fixtures/development.json
.vscode
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
*.log

# sveltekit
/build
Expand Down
79 changes: 45 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const IMAGE_WIDTHS = IMAGE_WIDTHS_ENTRIES.map(([name, width]) => [

export const IMAGE_WIDTHS_MAP = new Map(IMAGE_WIDTHS_ENTRIES);

export const DEFAULT_PER_PAGE = 25;
export const MAX_PER_PAGE = 100;

export const PDF_SIZE_LIMIT = 525336576;
Expand Down
30 changes: 27 additions & 3 deletions src/lib/api/documents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, test as base, expect } from "vitest";
import { APP_URL, IMAGE_WIDTHS_ENTRIES } from "@/config/config.js";

import * as documents from "./documents";
import type { Document } from "./types";
import type { Document, sizes } from "./types";

type Use<T> = (value: T) => Promise<void>;

Expand Down Expand Up @@ -56,7 +56,9 @@ describe("document helper methods", () => {
test("pageImageUrl", ({ document }) => {
const page = 1;
IMAGE_WIDTHS_ENTRIES.forEach(([size, width]) => {
expect(documents.pageImageUrl(document, page, size)).toStrictEqual(
expect(
documents.pageImageUrl(document, page, size as sizes),
).toStrictEqual(
new URL(
`documents/${document.id}/pages/${document.slug}-p${page}-${size}.gif`,
document.asset_url,
Expand Down Expand Up @@ -92,5 +94,27 @@ describe("document helper methods", () => {
);
});

test.todo("userOrgString");
test("userOrgString", async ({ document }) => {
// user + org expanded
expect(documents.userOrgString(document)).toStrictEqual(
"Chris Amico (NewsHour)",
);

// user and org not expanded
const d2 = (await import("./fixtures/documents/document.json")) as Document;
expect(documents.userOrgString(d2)).toStrictEqual("");

// user, but no org
const d3 = { ...document, organization: 1 };
expect(documents.userOrgString(d3)).toStrictEqual("Chris Amico");
});

test("pdfUrl", ({ document }) => {
expect(documents.pdfUrl(document)).toStrictEqual(
new URL(
`documents/${document.id}/${document.slug}.pdf`,
document.asset_url,
),
);
});
});
Loading

0 comments on commit 8fdced7

Please sign in to comment.