2015-07-24 16:40:34 +03:00
|
|
|
import React from 'react';
|
|
|
|
import TestUtils from 'react/lib/ReactTestUtils';
|
2015-06-19 18:27:07 +03:00
|
|
|
|
2015-07-24 16:40:34 +03:00
|
|
|
import CardChoice from 'components/card-choice';
|
|
|
|
import CardListing from 'views/card-listing';
|
2015-06-19 18:27:07 +03:00
|
|
|
|
2015-06-19 02:11:28 +03:00
|
|
|
|
2015-06-19 18:27:07 +03:00
|
|
|
describe('CardListingView', function() {
|
|
|
|
|
2015-06-27 23:54:19 +03:00
|
|
|
var payWithNewCardSpy;
|
|
|
|
var View;
|
|
|
|
var savedVisa = {provider_id: '3vr3ym', type_name: 'Visa'};
|
2015-06-19 18:27:07 +03:00
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
2015-06-27 23:54:19 +03:00
|
|
|
payWithNewCardSpy = sinon.spy();
|
2015-06-19 18:27:07 +03:00
|
|
|
|
2015-06-27 23:54:19 +03:00
|
|
|
View = TestUtils.renderIntoDocument(
|
|
|
|
<CardListing payWithNewCard={payWithNewCardSpy}
|
|
|
|
paymentMethods={[savedVisa]}
|
|
|
|
productId='mozilla-concrete-brick' />
|
2015-06-25 23:49:13 +03:00
|
|
|
);
|
2015-06-19 18:27:07 +03:00
|
|
|
});
|
|
|
|
|
2015-06-27 23:54:19 +03:00
|
|
|
it('should show card choice', function() {
|
2015-06-25 23:49:13 +03:00
|
|
|
var card = TestUtils.findRenderedComponentWithType(
|
2015-06-27 23:54:19 +03:00
|
|
|
View, CardChoice
|
2015-06-25 23:49:13 +03:00
|
|
|
);
|
|
|
|
assert.deepEqual(card.props.cards, [savedVisa]);
|
2015-06-19 18:27:07 +03:00
|
|
|
});
|
|
|
|
|
2015-06-27 23:54:19 +03:00
|
|
|
it('should request to pay with new card when clicking link', function() {
|
2015-06-19 02:11:28 +03:00
|
|
|
var addLink = TestUtils.findRenderedDOMComponentWithTag(
|
2015-06-27 23:54:19 +03:00
|
|
|
View, 'a');
|
2015-07-25 01:28:36 +03:00
|
|
|
TestUtils.Simulate.click(addLink);
|
2015-06-27 23:54:19 +03:00
|
|
|
assert.ok(payWithNewCardSpy.called);
|
2015-06-19 02:11:28 +03:00
|
|
|
});
|
|
|
|
|
2015-06-19 18:27:07 +03:00
|
|
|
});
|