Skip to content

Commit

Permalink
fix: configure tests and remove console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
lncitador committed Jul 7, 2024
1 parent 2857181 commit 8241223
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ node_modules
*.key
*.pem
*.crt
*.csr
*.csr

!certificate.p12
6 changes: 2 additions & 4 deletions src/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ export class SignatureEntityBuilder {
const filename = `${basename}.${extension}`;
const directory = await this.prepareFolder(this.#filePath, basename);

console.log({ directory });

const txt = resolve(directory, filename);
const p7s = resolve(directory, filename.concat(".p7s"));

Expand Down Expand Up @@ -118,7 +116,7 @@ export class SignatureEntityBuilder {
const directory = resolve(
__dirname,
filepath,
`${basename}-${Date.now()}`,
`${basename}-${Date.now()}`
);

try {
Expand All @@ -138,7 +136,7 @@ export class SignatureEntity implements ISignatureEntity {

constructor(
public readonly data: Buffer,
public readonly signature: Buffer,
public readonly signature: Buffer
) {
this.#builder = new SignatureEntityBuilder(data, signature);
}
Expand Down
Binary file added test/certificate.p12
Binary file not shown.
4 changes: 1 addition & 3 deletions test/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { resolve } from "node:path";

describe("SignatureProvider", async () => {
const data = Buffer.from("Test data", "utf8");
const signature = await readFile(
resolve(__dirname, "..", "certificate.p12")
);
const signature = await readFile(resolve(__dirname, "certificate.p12"));
const passphrase = "1234";

it("should sign the data and return a SignatureEntity", async () => {
Expand Down
8 changes: 5 additions & 3 deletions test/signature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SignatureEntity, SignatureEntityBuilder } from "../src/signature.js";
import { DataNotProvidedError } from "../src/errors/data_not_provided.error.js";
import { FilenameNotDefinedError } from "../src/errors/filename_not_defined.error.js";
import { FilepathNotDefinedError } from "../src/errors/filepath_not_defined.error.js";
import { SignatureNotProvidedError } from "../src/errors/signature_not_provided.error.js";

describe("SignatureEntity", () => {
describe("constructor", () => {
Expand Down Expand Up @@ -39,7 +40,8 @@ describe("SignatureEntity", () => {
undefined!
);
} catch (error) {
expect(error).toBeInstanceOf(DataNotProvidedError);
console.log(error);
expect(error).toBeInstanceOf(SignatureNotProvidedError);
}
});

Expand All @@ -51,7 +53,7 @@ describe("SignatureEntity", () => {
testSignature
);

const builder = signatureEntity.builder;
const builder = signatureEntity.builder();

expect(builder).toBeInstanceOf(SignatureEntityBuilder);
});
Expand All @@ -66,7 +68,7 @@ describe("SignatureEntity", () => {
testSignature
);

const builder = signatureEntity.builder;
const builder = signatureEntity.builder();

expect(builder).toBeInstanceOf(SignatureEntityBuilder);
});
Expand Down

0 comments on commit 8241223

Please sign in to comment.