-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from macder/tests
Tests
- Loading branch information
Showing
63 changed files
with
1,828 additions
and
739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
node_modules | ||
.DS_store | ||
.env* | ||
.idea/ | ||
!index.js | ||
!.eslintrc.js | ||
yarn.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { addressSchema } from "./schema" | ||
export { addressState } from "./state" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const addressState = (key) => | ||
({ | ||
empty: { | ||
is_empty: true, | ||
}, | ||
complete: { | ||
is_empty: false, | ||
}, | ||
}[key]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export { cartMock } from "./mock" | ||
export { cartStub } from "./stub" | ||
export { cartSchema } from "./schema" | ||
export { cartServiceMock } from "./service" | ||
export { cartState } from "./state" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { cartMock } from "./mock" | ||
import { cartStub } from "./stub" | ||
|
||
export const cartServiceMock = (state) => ({ | ||
retrieve: jest.fn(async (id) => cartMock(state)(id)), | ||
retrieve: jest.fn(async (id) => cartStub(state)), | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { addressSchema } from "../address" | ||
import { cartSchema } from "./schema" | ||
import { lineItemStub } from "../line-item" | ||
|
||
export const cartStub = ({ ...state }) => | ||
cartSchema({ | ||
...state, | ||
id: state.cart_id, | ||
address: addressSchema({ ...state.address }), | ||
items: state.line_items.map((item) => lineItemStub({ ...state, ...item })), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { fulfillmentMock } from "./mock" | ||
export { fulfillmentStub } from "./stub" | ||
export { fulfillmentRepoMock } from "./repo" | ||
export { fulfillmentServiceMock } from "./service" | ||
export { fulfillmentSchema, fulfillmentItemSchema } from "./schema" | ||
export { fulfillmentState } from "./state" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
import { MockRepository } from "medusa-test-utils" | ||
import { fulfillmentMock } from "./mock" | ||
import { fulfillmentStub } from "./stub" | ||
|
||
export const fulfillmentRepoMock = ({ ...state }) => | ||
MockRepository({ | ||
find: async (params) => | ||
state.fulfillments.map(({ items, shippo_order_id, id, tracking_links }) => | ||
fulfillmentMock({ ...state, shippo_order_id })(items, tracking_links)( | ||
id | ||
) | ||
), | ||
state.fulfillments.map((ful) => fulfillmentStub({ ...state, ...ful })), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export const fulfillmentState = (key) => | ||
({ | ||
no_shippo_order: { | ||
id: "ful_no_shippo_order", | ||
// shippo_order_id: "shippo_order_no_transactions", | ||
items: ["item_123", "item_321"], | ||
tracking_links: [], | ||
}, | ||
has_shippo_order: { | ||
id: "ful_has_shippo_order", | ||
shippo_order_id: "shippo_order_no_transactions", | ||
items: ["item_123", "item_321"], | ||
tracking_links: [], | ||
}, | ||
no_transaction: { | ||
id: "ful_no_transactions", | ||
shippo_order_id: "shippo_order_no_transactions", | ||
items: ["item_123", "item_321"], | ||
tracking_links: [], | ||
}, | ||
|
||
has_transaction_for_label: { | ||
id: "ful_has_transaction_for_label", | ||
shippo_order_id: "shippo_order_has_transaction_for_label", | ||
items: ["item_123", "item_321"], | ||
tracking_links: ["track_label_01234567890"], | ||
}, | ||
|
||
has_transaction_for_label_with_return: { | ||
id: "ful_has_transaction_for_label_and_return_label", | ||
shippo_order_id: | ||
"shippo_order_has_transaction_for_label_and_return_label", | ||
items: ["item_123", "item_321"], | ||
tracking_links: [ | ||
"track_label_01234567890", | ||
"track_return_label_01234567890", | ||
], | ||
}, | ||
}[key]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { fulfillmentSchema, fulfillmentItemSchema } from "./schema" | ||
import { trackingLinkSchema } from "../tracking-link" | ||
|
||
export const fulfillmentStub = ({ ...state }) => | ||
fulfillmentSchema({ | ||
...state, | ||
items: state.items.map((item_id) => | ||
fulfillmentItemSchema({ | ||
item_id, | ||
fulfillment_id: state.id, | ||
quantity: 2, | ||
}) | ||
), | ||
tracking_links: state.tracking_links.map((track) => | ||
trackingLinkSchema({ | ||
tracking_number: track, | ||
fulfillment_id: state.id, | ||
}) | ||
), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { lineItemMock } from "./mock" | ||
export { lineItemStub } from "./stub" | ||
export { lineItemServiceMock } from "./service" | ||
export { lineItemSchema } from "./schema" | ||
export { lineItemState } from "./state" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { lineItemMock } from "./mock" | ||
import { lineItemStub } from "./stub" | ||
|
||
export const lineItemServiceMock = ({ ...state }) => ({ | ||
list: jest.fn(), | ||
retrieve: jest.fn(async (id) => | ||
lineItemMock(state)({ id: "product_id" })({ id: "variant_id" })(id) | ||
), | ||
retrieve: jest.fn(async (id) => lineItemStub(state)), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const lineItemState = ({ quantity = 1 }) => ({ | ||
quantity, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { lineItemSchema } from "./schema" | ||
import { variantStub } from "../variant" | ||
|
||
export const lineItemStub = ({ ...state }) => | ||
lineItemSchema({ | ||
...state, | ||
variant: variantStub({ | ||
id: state.variant_id, | ||
product_id: state.product_id, | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export { orderMock } from "./mock" | ||
export { orderStub } from "./stub" | ||
export { orderSchema } from "./schema" | ||
export { orderServiceMock } from "./service" | ||
export { orderState } from "./state" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
import { orderMock } from "./mock" | ||
import { orderStub } from "./stub" | ||
|
||
export const orderServiceMock = (state) => { | ||
const order = orderMock(state) | ||
|
||
return { | ||
list: jest.fn(async ({ display_id }) => [order(state.order_id)]), | ||
retrieve: jest.fn(async (id) => order(id)), | ||
} | ||
} | ||
export const orderServiceMock = (state) => ({ | ||
list: jest.fn(async ({ display_id }) => [orderStub(state)]), | ||
retrieve: jest.fn(async (id) => orderStub(state)), | ||
}) |
Oops, something went wrong.