Fix errors in Sale page tests

This commit is contained in:
Kimmo Puputti 2017-08-04 10:13:02 +03:00
parent 325acedf1b
commit 808e5d014f
5 changed files with 23 additions and 5 deletions

View file

@ -257,7 +257,7 @@ SaleDetailsPanel.propTypes = {
transaction: propTypes.transaction.isRequired,
onAcceptSale: func.isRequired,
onRejectSale: func.isRequired,
acceptOrRejectInProgress: bool,
acceptOrRejectInProgress: bool.isRequired,
};
export default SaleDetailsPanel;

View file

@ -6,10 +6,12 @@ import { renderShallow } from '../../util/test-helpers';
import { BookingBreakdown } from '../../components';
import SaleDetailsPanel from './SaleDetailsPanel.js';
const noop = () => null;
describe('SaleDetailsPanel', () => {
it('matches snapshot', () => {
const { Money } = types;
const tx = createTransaction({
const transaction = createTransaction({
id: 'sale-tx',
state: 'state/preauthorized',
total: new Money(16500, 'USD'),
@ -23,12 +25,18 @@ describe('SaleDetailsPanel', () => {
customer: createUser('customer1'),
lastTransitionedAt: new Date(Date.UTC(2017, 5, 10)),
});
const tree = renderShallow(<SaleDetailsPanel transaction={tx} />);
const props = {
transaction,
onAcceptSale: noop,
onRejectSale: noop,
acceptOrRejectInProgress: false,
};
const tree = renderShallow(<SaleDetailsPanel {...props} />);
expect(tree).toMatchSnapshot();
});
it('renders correct total price', () => {
const { Money } = types;
const tx = createTransaction({
const transaction = createTransaction({
id: 'sale-tx',
state: 'state/preauthorized',
total: new Money(16500, 'USD'),
@ -42,7 +50,13 @@ describe('SaleDetailsPanel', () => {
customer: createUser('customer1'),
lastTransitionedAt: new Date(Date.UTC(2017, 5, 10)),
});
const panel = shallow(<SaleDetailsPanel transaction={tx} />);
const props = {
transaction,
onAcceptSale: noop,
onRejectSale: noop,
acceptOrRejectInProgress: false,
};
const panel = shallow(<SaleDetailsPanel {...props} />);
const breakdownProps = panel.find(BookingBreakdown).props();
// Total price for the provider should be transaction total minus the commission.

View file

@ -63,12 +63,14 @@ exports[`SaleDetailsPanel matches snapshot 1`] = `
</p>
<div>
<SecondaryButton
disabled={false}
onClick={[Function]}>
<FormattedMessage
id="SalePage.rejectButton"
values={Object {}} />
</SecondaryButton>
<PrimaryButton
disabled={false}
onClick={[Function]}>
<FormattedMessage
id="SalePage.acceptButton"

View file

@ -35,6 +35,7 @@ describe('SalePage', () => {
push: () => console.log('HistoryPush called'),
},
authInProgress: false,
acceptOrRejectInProgress: false,
currentUserHasListings: false,
isAuthenticated: false,
onLogout: noop,

View file

@ -39,6 +39,7 @@ exports[`SalePage matches snapshot 1`] = `
onManageDisableScrolling={[Function]} />
<div>
<SaleDetailsPanel
acceptOrRejectInProgress={false}
className="undefined"
lastTransition={null}
onAcceptSale={[Function]}