Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[commerce-sdk-react] Fix Shopper Baskets Test case #1082

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,21 @@ const addTaxesForBasketItemTestCase = [
const nonEmptyResponseTestCases = Object.entries(testMap) as Array<
[NonEmptyResponseMutations, Argument<Client[NonEmptyResponseMutations]>]
>
// Most test cases only apply to non-delete test cases, some (error handling) can include deleteBasket
const allTestCases = [
...nonEmptyResponseTestCases,

// Endpoints returning void response on success
const emptyResponseTestCases = [
deleteTestCase,
addPriceBooksToBasketTestCase,
addTaxesForBasketTestCase,
addTaxesForBasketItemTestCase
]

// Most test cases only apply to non-empty response test cases, some (error handling) can include deleteBasket
const allTestCases = [
...nonEmptyResponseTestCases,
...emptyResponseTestCases
]

describe('ShopperBaskets mutations', () => {
const storedCustomerIdKey = `${DEFAULT_TEST_CONFIG.siteId}_customer_id`
beforeAll(() => {
Expand Down Expand Up @@ -254,14 +260,8 @@ describe('ShopperBaskets mutations', () => {
assertUpdateQuery(result.current.customerBaskets, oldCustomerBaskets)
}
)
test.each([
deleteTestCase,
addPriceBooksToBasketTestCase,
addTaxesForBasketTestCase,
addTaxesForBasketItemTestCase
])('`%s` returns void on success', async () => {
test.each(emptyResponseTestCases)('`%s` returns void on success', async (mutationName, options) => {
// Almost the standard 'returns data' test, just a different return type
const [mutationName, options] = deleteTestCase
mockMutationEndpoints(basketsEndpoint, oldBasket)
const {result, waitForValueToChange: wait} = renderHookWithProviders(() => {
return useShopperBasketsMutation(mutationName)
Expand Down