diff --git a/src/receipt/ReceiptPage.test.jsx b/src/receipt/ReceiptPage.test.jsx new file mode 100644 index 000000000..521e535da --- /dev/null +++ b/src/receipt/ReceiptPage.test.jsx @@ -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('', () => { + describe('Renders correctly', () => { + it('should render receipt page for an order', () => { + const mockHistory = createMemoryHistory('/receipt'); + + const renderedComponent = mount( + + + + + , + ); + expect(renderedComponent).toMatchSnapshot(); + }); + }); +}); diff --git a/src/receipt/__mocks__/orderLoaded.mockStore.js b/src/receipt/__mocks__/orderLoaded.mockStore.js new file mode 100644 index 000000000..98c968a71 --- /dev/null +++ b/src/receipt/__mocks__/orderLoaded.mockStore.js @@ -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: "edx@example.com", + 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", + } + ], + } + ], + }, + } + }; + \ No newline at end of file diff --git a/src/receipt/__snapshots__/ReceiptPage.test.jsx.snap b/src/receipt/__snapshots__/ReceiptPage.test.jsx.snap new file mode 100644 index 000000000..3c6e76b52 --- /dev/null +++ b/src/receipt/__snapshots__/ReceiptPage.test.jsx.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` Renders correctly should render receipt page for an order 1`] = ` +ReactWrapper { + "length": 1, +} +`;