-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test and snapshot for ReceiptPage
- Loading branch information
1 parent
4287db8
commit 46f483b
Showing
3 changed files
with
133 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { Provider } from 'react-redux'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import { createMemoryHistory } from 'history'; | ||
|
||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
|
||
import ConnectedReceiptPage from './ReceiptPage'; | ||
|
||
const mockStore = configureMockStore(); | ||
const storeMocks = { | ||
// eslint-disable-next-line global-require | ||
ordersLoaded: require('./__mocks__/orderLoaded.mockStore.js'), | ||
}; | ||
const requiredReceiptPageProps = { | ||
fetchOrders: () => {}, | ||
}; | ||
|
||
describe('<ReceiptPage />', () => { | ||
describe('Renders correctly', () => { | ||
it('should render receipt page for an order', () => { | ||
const mockHistory = createMemoryHistory('/receipt'); | ||
|
||
const renderedComponent = mount( | ||
<IntlProvider locale="en"> | ||
<Provider store={mockStore(storeMocks.orderLoaded)}> | ||
<ConnectedReceiptPage {...requiredReceiptPageProps} history={mockHistory} /> | ||
</Provider> | ||
</IntlProvider>, | ||
); | ||
expect(renderedComponent).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
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,91 @@ | ||
module.exports = { | ||
receipt: { | ||
loadingReceipt: false, | ||
loadingReceiptError: null, | ||
order: { | ||
basket_discounts: [ | ||
{ | ||
amount: 14.9, | ||
benefit_value: 10, | ||
code: "12345", | ||
condition_name: "Cart includes 1 item(s) from range for coupon [14]", | ||
contains_offer: true, | ||
currency: "USD", | ||
enterprise_customer_name: null, | ||
offer_type: "Voucher", | ||
} | ||
], | ||
billing_address: { | ||
city: "Cambridge", | ||
country: "US", | ||
first_name: "Juliana", | ||
last_name: "TEST", | ||
line1: "123 Main Street", | ||
line2: "", | ||
postcode: "12346", | ||
state: "CA", | ||
}, | ||
currency: "USD", | ||
dashboard_url: "http://edx.devstack.lms:18000/dashboard", | ||
date_placed: "2022-06-21T16:43:02Z", | ||
discount: "14.90", | ||
enable_hoist_order_history: false, | ||
enterprise_customer_info: null, | ||
lines: [ | ||
{ | ||
title: 'Seat in edX Demonstration Course with verified certificate', | ||
quantity: 1, | ||
description: 'Seat in edX Demonstration Course with verified certificate', | ||
line_price_excl_tax: "134.10", | ||
product: { | ||
expires: "2023-05-06T21:19:31.037600Z", | ||
id: 3, | ||
is_available_to_buy: true, | ||
is_enrollment_code_product: false, | ||
price: "149.00", | ||
product_class: "Seat", | ||
title: "Seat in edX Demonstration Course with verified certificate", | ||
url: "http://localhost:18130/api/v2/products/", | ||
}, | ||
quantity: 1, | ||
status: "Complete", | ||
title: "Seat in edX Demonstration Course with verified certificate", | ||
unit_price_excl_tax: "149.00", | ||
number: "EDX-100005", | ||
offer_condition_name: null, | ||
order_product_ids: "3", | ||
payment_method: "Visa 411111XXXXXX1111", | ||
payment_processor: "cybersource-rest", | ||
status: "Complete", | ||
total_before_discounts_incl_tax: "149.00", | ||
total_excl_tax: "134.10", | ||
user: { | ||
email: "[email protected]", | ||
username: "edx", | ||
}, | ||
vouchers: [ | ||
{ | ||
benefit: { | ||
type: 'Percentage', | ||
value: 10 | ||
}, | ||
code: "12345", | ||
date_created: "2022-06-21T16:27:31.294837Z", | ||
end_datetime: "2024-04-01T00:00:00Z", | ||
id: 2, | ||
is_available_to_user: (2) [true, ''], | ||
is_public: false, | ||
num_basket_additions: 1, | ||
num_orders: 1, | ||
redeem_url: "http://localhost:18130/coupons/offer/?code=12345", | ||
start_datetime: "2022-06-21T00:00:00Z", | ||
total_discount: "14.90", | ||
usage: "Multi-use", | ||
} | ||
], | ||
} | ||
], | ||
}, | ||
} | ||
}; | ||
|
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,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ReceiptPage /> Renders correctly should render receipt page for an order 1`] = ` | ||
ReactWrapper { | ||
"length": 1, | ||
} | ||
`; |