Skip to content

Commit

Permalink
test: ✅ added more regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRill00 committed Mar 25, 2024
1 parent bf3f282 commit 7a44f79
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
47 changes: 46 additions & 1 deletion test/Batch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { client } from "./client";
import { BatchStatus } from "../src/enums/BatchStatus";
import * as fs from "fs";
import * as path from "path";
import { sleep } from "../src/utils";

let batch: Batch = null as unknown as Batch;
let template: Template = null as unknown as Template;
Expand Down Expand Up @@ -124,6 +125,7 @@ describe("createCsvOrder", function () {
expect(csvOrder.sendDate.getDay()).toEqual(new Date().getDay());
expect(csvOrder.friendlyStatus).toEqual(expect.any(String));
expect(csvOrder.sender).toEqual(undefined);
expect(csvOrder.format).toEqual(expect.any(String));
expect(csvOrder.recipientMapping).toEqual(mapping.recipient);
expect(csvOrder.templateId).toEqual(template.id);
expect(csvOrder.mergeVariableMapping).toStrictEqual({});
Expand Down Expand Up @@ -167,7 +169,7 @@ describe("getCsvOrder", function () {
// arrange

// act
const csvOrder = await client.getCsvOrder(csvOrderId);
const csvOrder = await batch.getCsvOrder(csvOrderId);

// assert
expect(csvOrder).toBeDefined();
Expand Down Expand Up @@ -403,3 +405,46 @@ describe("getOrders", function () {
expect(result.data).toBeArrayOfSize(1);
});
});

describe('BatchOrder', function () {
it('should be able to cancel Order', async function() {

Check failure on line 410 in test/Batch.spec.ts

View workflow job for this annotation

GitHub Actions / Test

BatchOrder › should be able to cancel Order

thrown: "Exceeded timeout of 5000 ms for a test. Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout." at test/Batch.spec.ts:410:3 at Object.<anonymous> (test/Batch.spec.ts:409:1)
// arrange
const order = await batch.createOrder({
recipient: {
name: "John Doe",
address: "123 Main Street",
postalCode: "1234 AB",
city: "Anytown",
country: "Nederland",
},
});

// act
await order.cancel();

// assert
expect(order.status).toEqual('order_cancelled');
})

it('should be able to refresh Order', async function () {
// arrange
const order = await batch.createOrder({
recipient: {
name: "John Doe",
address: "123 Main Street",
postalCode: "1234 AB",
city: "Anytown",
country: "Nederland",
},
});

// act
while (order.status === "order_created") {
await order.refresh();
await sleep(1000);
}

// assert
expect(order.status).not.toEqual("order_created");
}, 30000);
})
1 change: 1 addition & 0 deletions test/PrintOne.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ describe("createBatch", function () {
expect(batch.createdAt).toEqual(expect.any(Date));
expect(batch.updatedAt).toEqual(expect.any(Date));
expect(batch.finish).toEqual(Finish.GLOSSY);
expect(batch.format).toEqual(Format.POSTCARD_SQ15);
expect(batch.templateId).toEqual(template.id);
expect(batch.isBillable).toEqual(expect.any(Boolean));
expect(batch.estimatedPrice).toEqual(0);
Expand Down

0 comments on commit 7a44f79

Please sign in to comment.