payments-ui/tests/test.card-listing.jsx

40 строки
1.0 KiB
React
Исходник Обычный вид История

import React from 'react';
import TestUtils from 'react/lib/ReactTestUtils';
import CardChoice from 'components/card-choice';
import CardListing from 'views/card-listing';
2015-06-19 02:11:28 +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'};
beforeEach(function() {
2015-06-27 23:54:19 +03:00
payWithNewCardSpy = sinon.spy();
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-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-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');
TestUtils.Simulate.click(addLink);
2015-06-27 23:54:19 +03:00
assert.ok(payWithNewCardSpy.called);
2015-06-19 02:11:28 +03:00
});
});