UNPKG

@financial-times/n-conversion-forms

Version:

Containing jsx components and styles for forms included on Accounts and Acquisition apps (next-signup, next-profile, next-retention, etc).

59 lines (46 loc) 2.65 kB
import React from 'react'; import { mount } from 'enzyme'; import { AcceptTermsSubscriptionUpdatedUI } from './index'; describe('AcceptTermsSubscriptionUpdatedUI', () => { it('renders with "o-forms-input--invalid" class when hasError prop is true', () => { const props = { hasError: true }; const component = mount(<AcceptTermsSubscriptionUpdatedUI {...props} />); const labelElement = component.find('label'); expect(labelElement.hasClass('o-forms-input--invalid')).toBe(true); }); it('renders with additional classes when additionalClassNames is provided', () => { const props = { additionalClassNames: ['foo', 'bar'], }; const component = mount(<AcceptTermsSubscriptionUpdatedUI {...props} />); const divElement = component.find('div#acceptTermsField'); expect(divElement.hasClass('foo')).toBe(true); expect(divElement.hasClass('bar')).toBe(true); }); it('renders the terms for the updated transition UI with end of term transition', () => { const props = { transitionType: 'endOfTerm', }; const component = mount(<AcceptTermsSubscriptionUpdatedUI {...props} />); const updatedUITransitionTerms = component.find( '.terms-updated-ui-transition--end-of-term' ); expect(updatedUITransitionTerms.exists()).toBe(true); expect(updatedUITransitionTerms.text()).toBe( 'I consent to payment being taken at the end of each subscription term until I cancel. By placing my order, I acknowledge that my subscription will start on the date given above. I understand and agree that I will lose my statutory right to cancel within 14 days of accepting my order, and that any notice to cancel will only take effect at the end of my subscription period. Previously paid amounts are non-refundable, except in the event of a fault in the provision of services.' ); }); it('renders the terms for the updated transition UI with immediate transition', () => { const props = { transitionType: 'immediate', }; const component = mount(<AcceptTermsSubscriptionUpdatedUI {...props} />); const updatedUITransitionTerms = component.find( '.terms-updated-ui-transition--immediate' ); expect(updatedUITransitionTerms.exists()).toBe(true); expect(updatedUITransitionTerms.text()).toBe( 'I consent to payment being taken at the end of each subscription term until I cancel. I understand and agree that I will lose my statutory right to cancel within 14 days of accepting my order, and that any notice to cancel will only take effect at the end of my subscription period. Previously paid amounts are non-refundable, except in the event of a fault in the provision of services.' ); }); });