Skip to content

Commit

Permalink
add test for order confirmed event (#1607)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkostrowski authored Oct 2, 2024
1 parent d36e79a commit 2b55c83
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions apps/avatax/src/modules/saleor/order-confirmed/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ describe("SaleorOrderConfirmedEvent", () => {
});

describe("isStrategyFlatRates method", () => {
it("should return false if order has tax calculation startegy set to TAX_APP", () => {
it("should return false if order has tax calculation strategy set to TAX_APP", () => {
const payload = SaleorOrderConfirmedEventMockFactory.getGraphqlPayload();
const event = SaleorOrderConfirmedEvent.createFromGraphQL(payload)._unsafeUnwrap();

expect(event.isStrategyFlatRates()).toBe(false);
});

it("should return true if order has tax calculation startegy set to FLAT_RATES", () => {
it("should return true if order has tax calculation strategy set to FLAT_RATES", () => {
const payload = SaleorOrderConfirmedEventMockFactory.getGraphqlPayload();
const event = SaleorOrderConfirmedEvent.createFromGraphQL({
...payload,
Expand Down Expand Up @@ -175,4 +175,40 @@ describe("SaleorOrderConfirmedEvent", () => {
expect(result._unsafeUnwrap().resolveUserEmailOrEmpty()).toBe("");
});
});

describe("Resolving addresses", () => {
const payload = SaleorOrderConfirmedEventMockFactory.getGraphqlPayload();

payload.order.shippingAddress = {
streetAddress2: "streetAddress2-shipping",
city: "city-shipping",
postalCode: "postalCode-shipping",
country: {
code: "US",
},
countryArea: "countryArea-shipping",
streetAddress1: "streetAddress1-shipping",
};

payload.order.billingAddress = {
streetAddress2: "streetAddress2-billing",
city: "city-billing",
postalCode: "postalCode-billing",
country: {
code: "US",
},
countryArea: "countryArea-billing",
streetAddress1: "streetAddress1-billing",
};

const event = SaleorOrderConfirmedEvent.createFromGraphQL(payload)._unsafeUnwrap();

it("Returns shipping address", () => {
expect(event.getOrderShippingAddress()).toEqual(payload.order.shippingAddress);
});

it("Returns billing address", () => {
expect(event.getOrderBillingAddress()).toEqual(payload.order.billingAddress);
});
});
});

0 comments on commit 2b55c83

Please sign in to comment.