@@ -112,12 +112,47 @@ describe('ThemeInitializer', () => {
112
112
it ( 'should return early if no .slides elements' , async ( ) => {
113
113
document . body . innerHTML = '' ;
114
114
115
- await ThemeInitializer . init ( mockOptions ) ;
115
+ try {
116
+ await ThemeInitializer . init ( mockOptions ) ;
117
+ } catch ( e ) {
118
+ expect ( e ) . toBeInstanceOf ( Error ) ;
119
+ expect ( ( e as Error ) . message ) . toBe ( 'No slides found' ) ;
120
+ }
121
+ } ) ;
122
+ it ( 'should return early if no slidesFactory' , async ( ) => {
123
+ document . body . innerHTML = '' ;
116
124
117
- expect ( Reveal . initialize ) . not . toHaveBeenCalled ( ) ;
118
- expect ( render ) . not . toHaveBeenCalled ( ) ;
125
+ try {
126
+ // Use any here to force giving an incomplete parameters (method ask in javascript)
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ await ( ThemeInitializer as any ) . init ( { } ) ;
129
+ } catch ( e ) {
130
+ expect ( e ) . toBeInstanceOf ( Error ) ;
131
+ expect ( ( e as Error ) . message ) . toBe ( 'No slide factory function' ) ;
132
+ }
119
133
} ) ;
120
134
135
+ it ( 'should init Reveal.js with correct default options even if there is just the slide factory' , async ( ) => {
136
+ await ThemeInitializer . init ( {
137
+ slidesFactory : mockSlidesFactory ,
138
+ } ) ;
139
+
140
+ expect ( Reveal . initialize ) . toHaveBeenCalledWith (
141
+ expect . objectContaining ( {
142
+ controls : true ,
143
+ progress : true ,
144
+ history : true ,
145
+ center : false ,
146
+ width : 1920 ,
147
+ height : 1080 ,
148
+ slideNumber : 'c/t' ,
149
+ showSlideNumber : 'speaker' ,
150
+ showNotes : false ,
151
+ pdfMaxPagesPerSlide : 1 ,
152
+ pdfSeparateFragments : true ,
153
+ } )
154
+ ) ;
155
+ } ) ;
121
156
it ( 'should init Reveal.js with correct default options' , async ( ) => {
122
157
await ThemeInitializer . init ( mockOptions ) ;
123
158
0 commit comments