@@ -159,7 +159,11 @@ describe('Grid3 Wordlist Helpers', () => {
159159 expect ( wordlists . size ) . toBe ( 1 ) ;
160160 expect ( wordlists . has ( 'Greetings' ) ) . toBe ( true ) ;
161161
162- const wordlist = wordlists . get ( 'Greetings' ) ! ;
162+ const wordlist = wordlists . get ( 'Greetings' ) ;
163+ expect ( wordlist ) . toBeDefined ( ) ;
164+ if ( ! wordlist ) {
165+ return ;
166+ }
163167 expect ( wordlist . items ) . toHaveLength ( 2 ) ;
164168 expect ( wordlist . items [ 0 ] . text ) . toBe ( 'hello' ) ;
165169 expect ( wordlist . items [ 0 ] . image ) . toBe ( '[WIDGIT]hello.emf' ) ;
@@ -205,8 +209,14 @@ describe('Grid3 Wordlist Helpers', () => {
205209</Grid>` ;
206210 } ;
207211
208- zip . addFile ( 'Grids/Greetings/grid.xml' , Buffer . from ( createGrid ( 'Greetings' , [ 'hello' , 'hi' ] ) , 'utf8' ) ) ;
209- zip . addFile ( 'Grids/Farewells/grid.xml' , Buffer . from ( createGrid ( 'Farewells' , [ 'goodbye' , 'bye' ] ) , 'utf8' ) ) ;
212+ zip . addFile (
213+ 'Grids/Greetings/grid.xml' ,
214+ Buffer . from ( createGrid ( 'Greetings' , [ 'hello' , 'hi' ] ) , 'utf8' )
215+ ) ;
216+ zip . addFile (
217+ 'Grids/Farewells/grid.xml' ,
218+ Buffer . from ( createGrid ( 'Farewells' , [ 'goodbye' , 'bye' ] ) , 'utf8' )
219+ ) ;
210220
211221 const wordlists = extractWordlists ( zip . toBuffer ( ) ) ;
212222
@@ -243,7 +253,9 @@ describe('Grid3 Wordlist Helpers', () => {
243253 function createTestGridset ( gridName : string , initialWordlistXml ?: string ) : Buffer {
244254 const zip = new AdmZip ( ) ;
245255
246- const wordlistSection = initialWordlistXml || `<WordList>
256+ const wordlistSection =
257+ initialWordlistXml ||
258+ `<WordList>
247259 <Items>
248260 <WordListItem>
249261 <Text><s><r>old</r></s></Text>
@@ -285,7 +297,11 @@ describe('Grid3 Wordlist Helpers', () => {
285297 const wordlists = extractWordlists ( updated ) ;
286298
287299 expect ( wordlists . has ( 'Greetings' ) ) . toBe ( true ) ;
288- const wordlist = wordlists . get ( 'Greetings' ) ! ;
300+ const wordlist = wordlists . get ( 'Greetings' ) ;
301+ expect ( wordlist ) . toBeDefined ( ) ;
302+ if ( ! wordlist ) {
303+ return ;
304+ }
289305 expect ( wordlist . items ) . toHaveLength ( 3 ) ;
290306 expect ( wordlist . items . map ( ( i ) => i . text ) ) . toEqual ( [ 'hello' , 'hi' , 'hey' ] ) ;
291307 } ) ;
@@ -300,7 +316,11 @@ describe('Grid3 Wordlist Helpers', () => {
300316 const updated = updateWordlist ( gridset , 'Greetings' , newWordlist ) ;
301317 const wordlists = extractWordlists ( updated ) ;
302318
303- const wordlist = wordlists . get ( 'Greetings' ) ! ;
319+ const wordlist = wordlists . get ( 'Greetings' ) ;
320+ expect ( wordlist ) . toBeDefined ( ) ;
321+ if ( ! wordlist ) {
322+ return ;
323+ }
304324 expect ( wordlist . items [ 0 ] . image ) . toBe ( '[WIDGIT]hello.emf' ) ;
305325 expect ( wordlist . items [ 0 ] . partOfSpeech ) . toBe ( 'Interjection' ) ;
306326 } ) ;
@@ -363,4 +383,3 @@ describe('Grid3 Wordlist Helpers', () => {
363383 } ) ;
364384 } ) ;
365385} ) ;
366-
0 commit comments