File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 1+ // details-tab is dynamically loaded, so needs to be tested separately
2+ import React from 'react' ;
3+ import { render , screen } from '@testing-library/preact' ;
4+ import DetailsTab from '~/pages/details/desktop-view/details-tab/details-tab' ;
5+ import { LanguageContextProvider } from '~/contexts/language' ;
6+
7+ type Props = Parameters < typeof DetailsTab > [ 0 ] ;
8+
9+ jest . mock ( '~/pages/details/common/get-this-title' ) ;
10+
11+ const model = {
12+ id : 2 ,
13+ title : 'model-title' ,
14+ description : 'model-description' ,
15+ adoptions : 69 ,
16+ slug : 'whatever'
17+ } as Props [ 'model' ] ;
18+
19+ function Component ( props : Props ) {
20+ return (
21+ < LanguageContextProvider >
22+ < DetailsTab { ...props } />
23+ </ LanguageContextProvider >
24+ ) ;
25+ }
26+
27+ describe ( 'details-tab' , ( ) => {
28+ it ( 'renders (English)' , ( ) => {
29+ render ( < Component model = { model } polish = { false } /> ) ;
30+ screen . getByRole ( 'heading' , { level : 3 , name : 'Summary' } ) ;
31+ } ) ;
32+ it ( 'renders (Polish)' , ( ) => {
33+ render ( < Component model = { model } polish = { true } /> ) ;
34+ screen . getByRole ( 'heading' , { level : 3 , name : 'Przejdź do książki' } ) ;
35+ } ) ;
36+ } ) ;
Original file line number Diff line number Diff line change @@ -19,8 +19,11 @@ describe('left-content', () => {
1919 comingSoon : false ,
2020 iconType : 'lock' ,
2121 heading : 'heading' ,
22- double : false
23- } as unknown as ModelType ; // incomplete, but it's enough for testing
22+ double : false ,
23+ bookModel : {
24+ id : 1
25+ }
26+ } as ModelType ; // incomplete, but it's enough for testing
2427 const link = { url : '#good-url' , text : 'button-label' } ;
2528 // Setup option prevents await click from hanging when using faketimers
2629 const user = userEvent . setup ( { advanceTimers : jest . advanceTimersByTime } ) ;
You can’t perform that action at this time.
0 commit comments