Skip to content

Commit

Permalink
Removes test folder form gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredge committed May 20, 2024
1 parent f7c41ef commit d4a2e17
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/client-js/test/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {Onedoc} from "../src/client";
import fs from "fs";
import path from "path";
import process from "process";

const ONEDOC_API_KEY = process.env.ONEDOC;
(async () => {

const onedoc = new Onedoc(ONEDOC_API_KEY);

let doc = {
html: "<h1>Hello World</h1>",
title: "Hello",
test: true, // if true, produce a PDF in test mode with a Onedoc's watermark
save: false, // if true, host the document and provide a download link in the console and your Onedoc's dashboard
expiresIn: 30, // the number of day you want to host your document
assets: [
{
path: "./stylesheet.css",
content: fs.readFileSync(path.join(process.cwd(), "/test/stylesheet.css")).toString(),
},
],
};

const { file, link, error, info } = await onedoc.render(doc);

if (error) {
throw error;
}

fs.writeFileSync("./Test.pdf", Buffer.from(file));
})();
3 changes: 3 additions & 0 deletions packages/client-js/test/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body{
background-color: red;
}

0 comments on commit d4a2e17

Please sign in to comment.