UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

66 lines (56 loc) 1.7 kB
// @flow import * as React from 'react'; import { mount } from 'enzyme'; import { UnwrappedArticleContent } from '../ArticleContent'; import PageVariantContext from '../../../../SmartFAQ/context/PageVariant'; const mockRefType: any = null; const commonProps = { onLogin: jest.fn(), isInGuaranteeArticle: true, showGuaranteeChat: false, article: { $refType: mockRefType, id: 'abc123==', title: 'Kiwi.com Guarantee', perex: 'Perex for Kiwi.com Guarantee', content: 'Content of the article about Kiwi.com Guarantee', }, theme: { orbit: {}, }, }; describe('ArticleContent', () => { it('should show call to sign in for non-logged user in guarantee article', () => { const wrapper = mount( <PageVariantContext.Provider value={{ variant: 'sidebar' }}> <UnwrappedArticleContent {...commonProps} loginToken={null} simpleToken={null} /> </PageVariantContext.Provider>, ); expect(wrapper.find('.guaranteeLoggedOut').exists()).toBeTruthy(); }); it('should not show call to sign in in different article', () => { const wrapper = mount( <UnwrappedArticleContent {...commonProps} loginToken={null} simpleToken={null} isInGuaranteeArticle={false} />, ); expect(wrapper.find('.guaranteeLoggedOut').exists()).toBeFalsy(); }); it('should not show call to sign in for already logged user', () => { const wrapper = mount( <UnwrappedArticleContent {...commonProps} loginToken="token123" simpleToken={null} />, ); expect(wrapper.find('.guaranteeLoggedOut').exists()).toBeFalsy(); }); });