Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
run-tests-with-optional-dependencies:
name: Run Integration Tests With Optional Dependencies
name: Integration Tests With Optional Dependencies
timeout-minutes: 30
strategy:
matrix:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:


run-tests-without-optional-dependencies:
name: Run Integration Tests Without Optional Dependencies
name: Integration Tests Without Optional Dependencies
timeout-minutes: 30
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

jobs:
build:
name: Run Tests
name: Smoke Tests
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
run-tests-with-optional-dependencies:
name: Run Tests With Optional Dependencies
name: Tests With Optional Dependencies
strategy:
matrix:
os:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
run: npm run test

run-tests-without-optional-dependencies:
name: Run Tests Without Optional Dependencies
name: Tests Without Optional Dependencies
strategy:
matrix:
os:
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
"build": "tsc --build && tsc-alias",
"build-for-dist": "tsc --build && tsc-alias && cp LICENSE README.md CHANGELOG.md ./dist",
"clean": "rm -rf ./dist ./docs/_build",
"test": "mocha --grep \"#omitOptionalDeps\" --invert \"tests/**/*.spec.ts\"",
"test-light": "mocha --grep \"#includeOptionalDeps\" --invert \"tests/**/*.spec.ts\"",
"test-integration": "mocha --grep \"#omitOptionalDeps\" --invert \"tests/**/*.integration.ts\"",
"test-integration-light": "mocha --grep \"#includeOptionalDeps\" --invert \"tests/**/*.integration.ts\"",
"test-v1": "mocha --grep \"#omitOptionalDeps\" --invert \"tests/v1/**/*.spec.ts\"",
"test-v1-light": "mocha --grep \"#includeOptionalDeps\" --invert \"tests/v1/**/*.spec.ts\"",
"test-v2": "mocha --grep \"#omitOptionalDeps\" --invert \"tests/v2/**/*.spec.ts\"",
"test-v2-light": "mocha --grep \"#includeOptionalDeps\" --invert \"tests/v2/**/*.spec.ts\"",
"test": "mocha --grep '#OptionalDepsRemoved' --invert 'tests/**/*.spec.ts'",
"test-light": "mocha --grep '#OptionalDepsRequired' --invert 'tests/**/*.spec.ts'",
"test-integration": "mocha --grep '#OptionalDepsRemoved' --invert 'tests/**/*.integration.ts'",
"test-integration-light": "mocha --grep '#OptionalDepsRequired' --invert 'tests/**/*.integration.ts'",
"test-v2": "tsc --noEmit && node --import tsx --test 'tests/v2/**/*.spec.ts'",
"lint": "tsc --noEmit && eslint --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
"lint-fix": "eslint --fix --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
"docs": "typedoc --out docs/_build ./src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion tests/dependency/missingDependencies.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import assert from "node:assert/strict";
import path from "path";
import { V1_PRODUCT_PATH } from "../index.js";

describe("Light Environment Sanity Check #omitOptionalDeps", function () {
describe("MindeeV1 - Integration - Optional Dependencies #OptionalDepsRemoved", function () {
let client: mindee.v1.Client;

beforeEach(() => {
Expand Down
3 changes: 2 additions & 1 deletion tests/dependency/missingDependencies.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";

describe("Light Environment Sanity Check #omitOptionalDeps", function () {
describe("MindeeV1 - Optional Dependencies #OptionalDepsRemoved", function () {

it("should NOT have sharp installed", async function () {
try {
Expand Down
1 change: 1 addition & 0 deletions tests/geometry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as geometry from "@/geometry/index.js";
import { describe, it } from "node:test";
import assert from "node:assert/strict";

describe("Geometry functions", () => {
Expand Down
15 changes: 7 additions & 8 deletions tests/input/compression.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {
PathInput,
} from "@/input/index.js";
import { after, before, describe, it } from "node:test";
import * as fs from "fs";
import * as path from "path";
import assert from "node:assert/strict";
import { PathInput } from "@/input/index.js";
import { compressImage } from "@/image/index.js";
import { compressPdf } from "@/pdf/index.js";
import { extractTextFromPdf } from "@/pdf/pdfUtils.js";
import { logger } from "@/logger.js";
import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../index.js";

describe("Input Sources - compression and resize #includeOptionalDeps", () => {
describe("Input Sources - compression and resize #OptionalDepsRequired", () => {
const outputPath = path.join(RESOURCE_PATH, "output");

before(async () => {
Expand Down Expand Up @@ -131,7 +130,7 @@ describe("Input Sources - compression and resize #includeOptionalDeps", () => {
path.join(outputPath, "resize_indirect.pdf")
);
assert.ok(renderedFileStats.size < initialFileStats.size);
}).timeout(10000);
});

it("PDF Compress From Compressor", async () => {
const pdfResizeInput = new PathInput(
Expand Down Expand Up @@ -162,7 +161,7 @@ describe("Input Sources - compression and resize #includeOptionalDeps", () => {
assert.ok(renderedFileStats[0].size > renderedFileStats[1].size);
assert.ok(renderedFileStats[1].size > renderedFileStats[2].size);
assert.ok(renderedFileStats[2].size > renderedFileStats[3].size);
}).timeout(20000);
});

it("PDF Compress With Text Keeps Text", async () => {
const initialWithText = new PathInput(
Expand All @@ -177,7 +176,7 @@ describe("Input Sources - compression and resize #includeOptionalDeps", () => {
const compressedText = (await extractTextFromPdf(compressedWithText)).getConcatenatedText();

assert.strictEqual(compressedText, originalText);
}).timeout(60000);
});

it("PDF Compress With Text Does Not Compress", async () => {
const initialWithText = new PathInput(
Expand All @@ -188,7 +187,7 @@ describe("Input Sources - compression and resize #includeOptionalDeps", () => {
const compressedWithText = await compressPdf(initialWithText.fileObject, 50);

assert.deepStrictEqual(compressedWithText, initialWithText.fileObject);
}).timeout(10000);
});

after(async function () {
const createdFiles: string[] = [
Expand Down
3 changes: 2 additions & 1 deletion tests/input/pageOperations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
} from "@/input/index.js";
import * as fs from "fs";
import * as path from "path";
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { RESOURCE_PATH } from "../index.js";

describe("Input Sources - high level multi-page operations #includeOptionalDeps", () => {
describe("Input Sources - high level multi-page operations #OptionalDepsRequired", () => {
it("should cut a PDF", async () => {
const input = new PathInput({
inputPath: path.join(RESOURCE_PATH, "file_types/pdf/multipage.pdf"),
Expand Down
16 changes: 8 additions & 8 deletions tests/input/sources.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import * as fs from "fs";
import * as path from "path";
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { Buffer } from "node:buffer";
import { Readable } from "stream";
import {
Base64Input,
Expand All @@ -11,14 +16,10 @@ import {
PathInput,
StreamInput,
} from "@/input/index.js";
import * as fs from "fs";
import * as path from "path";
import assert from "node:assert/strict";
import { Buffer } from "node:buffer";
import { MindeeInputSourceError } from "@/errors/index.js";
import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../index.js";

describe("Input Sources: - load different types of input", () => {
describe("Input Sources - load different types of input", () => {

it("should accept base64 inputs", async () => {
const b64Input = await fs.promises.readFile(
Expand Down Expand Up @@ -240,10 +241,9 @@ describe("Input Sources: - load different types of input", () => {
assert.strictEqual(inputSource.inputType, INPUT_TYPE_BUFFER);
assert.strictEqual(inputSource.filename, filename);
assert.ok(inputSource.isPdf());
it("#includeOptionalDeps", async () => {
assert.ok(inputSource.fileObject instanceof Buffer);
await it("getPageCount #OptionalDepsRequired", async () => {
assert.strictEqual(await inputSource.getPageCount(), 10);
});
assert.ok(inputSource.fileObject instanceof Buffer);
});

});
3 changes: 2 additions & 1 deletion tests/input/urlInputSource.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { BytesInput, UrlInput } from "@/index.js";
import { LocalInputSource } from "@/input/index.js";
import assert from "node:assert/strict";
import { MockAgent, setGlobalDispatcher } from "undici";

const mockAgent = new MockAgent();
Expand Down
3 changes: 2 additions & 1 deletion tests/pdf/pdfOperation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import * as pdf from "@/pdf/index.js";
import * as path from "path";
import * as fs from "fs";
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { PageOptions, PageOptionsOperation } from "@/index.js";
import { PathInput } from "@/index.js";
import { RESOURCE_PATH } from "../index.js";

describe("Test pdf operation #includeOptionalDeps", () => {
describe("Test PDF operation #OptionalDepsRequired", () => {
it("should cut a PDF to get 2 pages", async () => {
const inputSource = new PathInput({
inputPath: path.join(RESOURCE_PATH, "file_types/pdf/multipage.pdf"),
Expand Down
4 changes: 2 additions & 2 deletions tests/pdf/pdfTypes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import path from "path";
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import * as pdf from "@/pdf/index.js";
import { PageOptions } from "@/input/index.js";
import { PageOptionsOperation, PathInput } from "@/index.js";
import { RESOURCE_PATH } from "../index.js";

describe("Test pdf lib #includeOptionalDeps", () => {
describe("Test pdf lib #OptionalDepsRequired", () => {

it("should open a simple XFA form PDF.", async () => {
const inputDoc = new PathInput(
Expand All @@ -23,7 +24,6 @@ describe("Test pdf lib #includeOptionalDeps", () => {
assert.strictEqual(await pdf.countPages(inputDoc.fileObject), 15);
});


it("should be able to perform page operations on an encrypted XFA form PDF.", async () => {
const inputDoc = new PathInput(
{ inputPath: path.join(RESOURCE_PATH, "file_types/pdf/XfaForm_15p_encrypted.pdf") }
Expand Down
5 changes: 3 additions & 2 deletions tests/v1/api/asyncResponse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import path from "path";
import * as fs from "node:fs/promises";
import { AsyncPredictResponse } from "@/v1/index.js";
import { promises as fs } from "fs";
import * as path from "path";
import { StringDict } from "@/v1/parsing/common/index.js";
import { InvoiceSplitterV1 } from "@/v1/product/index.js";
import { cleanRequestData, isValidAsyncResponse } from "@/http/index.js";
Expand Down
5 changes: 3 additions & 2 deletions tests/v1/api/endpoint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import assert from "node:assert/strict";
import { afterEach, beforeEach, describe, it } from "node:test";
import path from "path";
import * as fs from "node:fs";
import * as path from "path";
import { MockAgent, setGlobalDispatcher } from "undici";
import { PathInput } from "@/index.js";
import { Client, product } from "@/v1/index.js";
import { RESOURCE_PATH, V1_RESOURCE_PATH } from "../../index.js";
import assert from "node:assert/strict";
import {
MindeeHttp400Error, MindeeHttp401Error, MindeeHttp429Error, MindeeHttp500Error
} from "@/v1/http/index.js";
Expand Down
5 changes: 3 additions & 2 deletions tests/v1/api/feedbackResponse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import assert from "node:assert/strict";
import { promises as fs } from "fs";
import { describe, it } from "node:test";
import path from "path";
import * as fs from "node:fs/promises";
import { FeedbackResponse } from "@/v1/parsing/common/index.js";
import { V1_PRODUCT_PATH } from "../../index.js";

Expand Down
5 changes: 3 additions & 2 deletions tests/v1/api/response.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { promises as fs } from "fs";
import * as path from "path";
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import path from "path";
import * as fs from "node:fs/promises";
import { PredictResponse } from "@/v1/index.js";
import { InvoiceV4, ReceiptV5 } from "@/v1/product/index.js";
import { V1_PRODUCT_PATH } from "../../index.js";
Expand Down
10 changes: 7 additions & 3 deletions tests/v1/clientInit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Client } from "@/v1/index.js";
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { Client } from "@/v1/index.js";
import { MindeeError } from "@/errors/index.js";

describe("Test client initialization", () => {
it("should not create an empty client", () => {
it("should not create a client without an API key", () => {
delete process.env.MINDEE_API_KEY;
assert.throws(
() => {
new Client({});
}
},
MindeeError
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as mindee from "@/index.js";
import { InvoiceSplitterV1 } from "@/v1/product/index.js";
import assert from "node:assert/strict";
import { levenshteinRatio } from "../../../testingUtilities.js";
import { promises as fs } from "fs";
import path from "path";
import { V1_PRODUCT_PATH } from "../../../index.js";
import * as mindee from "@/index.js";
import { InvoiceSplitterV1 } from "@/v1/product/index.js";
import { levenshteinRatio } from "../../testingUtilities.js";
import { V1_PRODUCT_PATH } from "../../index.js";

describe("MindeeV1 - InvoiceSplitterV1 Integration Tests #includeOptionalDeps", async () => {
describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", async () => {
let client: mindee.v1.Client;

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import assert from "node:assert/strict";
import { promises as fs } from "fs";
import * as path from "path";
import { describe, it } from "node:test";
import path from "path";
import * as fs from "node:fs/promises";
import { Document } from "@/v1/index.js";
import { InvoiceSplitterV1 } from "@/v1/product/index.js";
import { extractInvoices } from "@/v1/extraction/index.js";
import { PathInput } from "@/index.js";
import { V1_PRODUCT_PATH } from "../../index.js";

describe("MindeeV1 - A Multipage Invoice Document #includeOptionalDeps", () => {
describe("MindeeV1 - Invoice Splitter Extraction #OptionalDepsRequired", () => {
it("should be split into the proper invoices", async () => {
const jsonData = await fs.readFile(
path.join(V1_PRODUCT_PATH, "invoice_splitter/response_v1/complete.json")
Expand Down
33 changes: 0 additions & 33 deletions tests/v1/extraction/invoiceSplitterExtractor.spec.ts

This file was deleted.

Loading