UNPKG

@kiwicom/smart-faq

Version:

74 lines (64 loc) 2.14 kB
// @flow import * as React from 'react'; import { ThemeProvider } from 'styled-components'; import defaultTheme from '@kiwicom/orbit-components/lib/defaultTheme'; import { UnwrappedArticleContent } from '../ArticleContent'; import PageVariantContext from '../../../../SmartFAQ/context/PageVariant'; import getTestRenderer from '../../../../services/TestRenderer'; 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 = getTestRenderer(() => ( <ThemeProvider theme={defaultTheme}> <PageVariantContext.Provider value={{ variant: 'sidebar' }}> <UnwrappedArticleContent {...commonProps} loginToken={null} simpleToken={null} /> </PageVariantContext.Provider> </ThemeProvider> )); expect(wrapper.find('.guaranteeLoggedOut').exists()).toBeTruthy(); }); it('should not show call to sign in in different article', () => { const wrapper = getTestRenderer(() => ( <ThemeProvider theme={defaultTheme}> <UnwrappedArticleContent {...commonProps} loginToken={null} simpleToken={null} isInGuaranteeArticle={false} /> </ThemeProvider> )); expect(wrapper.find('.guaranteeLoggedOut').exists()).toBeFalsy(); }); it('should not show call to sign in for already logged user', () => { const wrapper = getTestRenderer(() => ( <ThemeProvider theme={defaultTheme}> <UnwrappedArticleContent {...commonProps} loginToken="token123" simpleToken={null} /> </ThemeProvider> )); expect(wrapper.find('.guaranteeLoggedOut').exists()).toBeFalsy(); }); });